Skip to content

Commit

Permalink
don't use the initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryD committed Feb 14, 2024
1 parent dd50bae commit 251d0ff
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 83 deletions.
12 changes: 2 additions & 10 deletions ember-flatpickr/addon-main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,5 @@

const { addonV1Shim } = require("@embroider/addon-shim");

module.exports = {
...addonV1Shim(__dirname),
options: {
"@embroider/macros": {
setOwnConfig: {
initializeFlatpickr: true,
},
},
}
};
module.exports = addonV1Shim(__dirname);

6 changes: 2 additions & 4 deletions ember-flatpickr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"dependencies": {
"@ember/render-modifiers": "^2.0.3",
"@ember/test-helpers": "~3.3.0",
"@embroider/addon-shim": "^1.8.7",
"@embroider/macros": "^1.13.5"
"@embroider/addon-shim": "^1.8.7"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Expand Down Expand Up @@ -89,8 +88,7 @@
},
"ember-addon": {
"app-js": {
"./components/ember-flatpickr.js": "./dist/_app_/components/ember-flatpickr.js",
"./initializers/ember-flatpickr.js": "./dist/_app_/initializers/ember-flatpickr.js"
"./components/ember-flatpickr.js": "./dist/_app_/components/ember-flatpickr.js"
},
"main": "addon-main.cjs",
"type": "addon",
Expand Down
6 changes: 5 additions & 1 deletion ember-flatpickr/src/components/ember-flatpickr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class EmberFlatpickr extends Component<EmberFlatpickrArgs> {
scheduleOnce('afterRender', this, this._setFlatpickrOptions, element);
}

_setFlatpickrOptions(element: HTMLInputElement): void {
async _setFlatpickrOptions(element: HTMLInputElement): Promise<void> {
const fastboot = getOwner(this)?.lookup('service:fastboot') as unknown as
| FastbootService
| undefined;
Expand All @@ -133,6 +133,10 @@ export default class EmberFlatpickr extends Component<EmberFlatpickrArgs> {
Object.entries(rest).filter((entry) => entry[1] !== undefined),
);

if (typeof this.args.locale === 'string') {
await import(`flatpickr/dist/l10n/${this.args.locale}.js`);
}

this.flatpickrRef = flatpickr(element, {
onChange,
onClose: onClose || this.onClose,
Expand Down
21 changes: 0 additions & 21 deletions ember-flatpickr/src/initializers/ember-flatpickr.ts

This file was deleted.

3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test-app/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from 'test-app/config/environment';
import 'flatpickr/dist/flatpickr.css';
import 'flatpickr/dist/l10n';

export default class App extends Application {
modulePrefix = config.modulePrefix;
Expand Down
4 changes: 0 additions & 4 deletions test-app/app/controllers/docs/components/ember-flatpickr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { next } from '@ember/runloop';
import 'flatpickr/dist/l10n/fr';
import 'flatpickr/dist/l10n/de';
import 'flatpickr/dist/l10n/ru';
import 'flatpickr/dist/l10n/uk';

export default class EmberFlatpickr extends Controller {
@tracked dateValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
find,
findAll,
triggerEvent,
waitFor,
} from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import {
Expand All @@ -15,7 +16,6 @@ import {
setFlatpickrDate,
} from 'ember-flatpickr/test-support/helpers';
import langs from 'flatpickr/dist/l10n';
import 'flatpickr/dist/l10n/fr';

const clickDay = async (index) => {
await triggerEvent(findAll('.flatpickr-days .flatpickr-day')[index], 'click');
Expand Down Expand Up @@ -475,6 +475,8 @@ module('Integration | Component | ember flatpickr', function (hooks) {
placeholder="Pick date"
/>`);

await waitFor('.flatpickr-current-month .flatpickr-monthDropdown-month');

assert.strictEqual(
find(
'.flatpickr-current-month .flatpickr-monthDropdown-month',
Expand Down
38 changes: 0 additions & 38 deletions test-app/tests/unit/initializers/ember-flatpickr-test.js

This file was deleted.

0 comments on commit 251d0ff

Please sign in to comment.