From 18e78bb1b9bfd93a8bbe1a21446b0a3f5e6b12b7 Mon Sep 17 00:00:00 2001 From: Patrick Pircher Date: Sun, 7 Jul 2024 23:52:34 +0200 Subject: [PATCH] wip Signed-off-by: Patrick Pircher --- carbon-components-ember/.eslintrc.cjs | 1 + .../src/components/accordion.gts | 2 +- .../src/components/breadcrumbs.gts | 2 +- .../src/components/button.gts | 12 +- .../src/components/checkbox.gts | 4 +- .../src/components/code-snippet.gts | 8 +- .../src/components/copy-button.gts | 4 +- .../src/components/data-table.gts | 18 +- .../src/components/dialogs/confirm.gts | 4 +- .../src/components/form-input.gts | 2 +- .../src/components/icon.gts | 12 +- .../src/services/dialog-manager.ts | 5 +- carbon-components-ember/tsconfig.json | 8 +- carbon-components-ember/types/glint.d.ts | 28 +- doc-app/.eslintrc.js | 79 +- doc-app/app/pods/application/route.gts | 25 +- .../pods/docs/components/accordion/route.gts | 4 +- .../docs/components/breadcrumbs/route.gts | 4 +- .../app/pods/docs/components/charts/route.gts | 9 +- .../pods/docs/components/checkbox/route.gts | 10 +- .../confirm/{controller.js => controller.ts} | 2 +- .../pods/docs/components/confirm/route.gts | 11 +- .../docs/components/data-table/controller.ts | 2 +- .../pods/docs/components/data-table/route.gts | 9 +- .../app/pods/docs/components/icon/route.gts | 5 +- .../app/pods/docs/components/modal/route.gts | 7 +- .../docs/components/notification/route.gts | 5 +- .../docs/components/progress-bar/route.gts | 4 - .../pods/docs/components/select/controller.ts | 2 +- .../app/pods/docs/components/select/route.gts | 12 +- .../app/pods/docs/components/tag/route.gts | 31 +- .../docs/components/ui-shell/controller.js | 39 - .../docs/components/ui-shell/controller.ts | 42 + .../pods/docs/components/ui-shell/route.gts | 26 +- doc-app/app/pods/docs/index/route.gts | 4 +- doc-app/app/pods/index/route.gts | 5 +- doc-app/package.json | 10 +- doc-app/tsconfig.json | 4 + doc-app/types/ember.d.ts | 2 +- doc-app/types/glint.d.ts | 184 +- package.json | 3 +- pnpm-lock.yaml | 3896 +++++++++++++---- test-app/package.json | 6 +- 43 files changed, 3441 insertions(+), 1111 deletions(-) rename doc-app/app/pods/docs/components/confirm/{controller.js => controller.ts} (71%) delete mode 100644 doc-app/app/pods/docs/components/ui-shell/controller.js create mode 100644 doc-app/app/pods/docs/components/ui-shell/controller.ts diff --git a/carbon-components-ember/.eslintrc.cjs b/carbon-components-ember/.eslintrc.cjs index d2e5254f..f7f5a4ee 100644 --- a/carbon-components-ember/.eslintrc.cjs +++ b/carbon-components-ember/.eslintrc.cjs @@ -14,6 +14,7 @@ module.exports = { extends: ['plugin:ember/recommended', 'plugin:prettier/recommended'], globals: { WithRequired: true, + 'ensure-safe-component': true }, env: { browser: true, diff --git a/carbon-components-ember/src/components/accordion.gts b/carbon-components-ember/src/components/accordion.gts index ebdfe159..a237cd1b 100644 --- a/carbon-components-ember/src/components/accordion.gts +++ b/carbon-components-ember/src/components/accordion.gts @@ -3,7 +3,7 @@ import { guidFor } from '@ember/object/internals'; import { type WithBoundArgs } from '@glint/template'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; -import or from '/helpers/or.ts'; +import or from '../helpers/or.ts'; import { on } from '@ember/modifier'; import { fn } from '@ember/helper'; diff --git a/carbon-components-ember/src/components/breadcrumbs.gts b/carbon-components-ember/src/components/breadcrumbs.gts index 2f6efbb5..e2e3ff43 100644 --- a/carbon-components-ember/src/components/breadcrumbs.gts +++ b/carbon-components-ember/src/components/breadcrumbs.gts @@ -1,5 +1,5 @@ import Component from '@glimmer/component'; -import { defaultArgs } from '/utils/decorators.ts'; +import { defaultArgs } from '../utils/decorators.ts'; import { action } from '@ember/object'; import eq from 'ember-truth-helpers/helpers/eq'; import { on } from '@ember/modifier'; diff --git a/carbon-components-ember/src/components/button.gts b/carbon-components-ember/src/components/button.gts index e5ad24e5..acf3155b 100644 --- a/carbon-components-ember/src/components/button.gts +++ b/carbon-components-ember/src/components/button.gts @@ -1,13 +1,13 @@ import Component from '@glimmer/component'; -import { bxClassNames, classPrefix, defaultArgs } from '/utils/decorators.ts'; -import DialogManagerService from '/services/dialog-manager.js'; +import { bxClassNames, classPrefix, defaultArgs } from '../utils/decorators.ts'; +import DialogManagerService from '../services/dialog-manager.ts'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; -import ConfirmDialogComponent from '/components/dialogs/confirm.gts'; -import or from '/helpers/or.ts'; -import Confirm from '/components/dialogs/confirm.gts'; -import Loading from '/components/loading.gts'; +import ConfirmDialogComponent from './dialogs/confirm.gts'; +import or from '../helpers/or.ts'; +import Confirm from './dialogs/confirm.gts'; +import Loading from './loading.gts'; import { stylesheet } from 'astroturf'; /** @documenter yuidoc */ diff --git a/carbon-components-ember/src/components/checkbox.gts b/carbon-components-ember/src/components/checkbox.gts index 7d0f1c6a..f01e15e7 100644 --- a/carbon-components-ember/src/components/checkbox.gts +++ b/carbon-components-ember/src/components/checkbox.gts @@ -2,11 +2,11 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; import { guidFor } from '@ember/object/internals'; -import { defaultArgs } from '/utils/decorators.ts'; +import { defaultArgs } from '../utils/decorators.ts'; import didInsert from '@ember/render-modifiers/modifiers/did-insert'; import { on } from '@ember/modifier'; import { fn } from '@ember/helper'; -import set from '/helpers/set.ts'; +import set from '../helpers/set.ts'; type Args = { name?: string; diff --git a/carbon-components-ember/src/components/code-snippet.gts b/carbon-components-ember/src/components/code-snippet.gts index 4319857c..b6c80154 100644 --- a/carbon-components-ember/src/components/code-snippet.gts +++ b/carbon-components-ember/src/components/code-snippet.gts @@ -1,14 +1,14 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; -import { defaultArgs } from '/utils/decorators.ts'; -import CopyButton from '/components/copy-button.gts'; +import { defaultArgs } from '../utils/decorators.ts'; +import CopyButton from '../components/copy-button.gts'; import { concat, fn } from '@ember/helper'; import didInsert from '@ember/render-modifiers/modifiers/did-insert'; import eq from 'ember-truth-helpers/helpers/eq'; import { on } from '@ember/modifier'; -import set from '/helpers/set.ts'; +import set from '../helpers/set.ts'; import not from 'ember-truth-helpers/helpers/not'; -import htmlSafe from '/helpers/html-safe.ts'; +import htmlSafe from '../helpers/html-safe.ts'; import { type TemplateOnlyComponent } from '@ember/component/template-only'; type Args = { diff --git a/carbon-components-ember/src/components/copy-button.gts b/carbon-components-ember/src/components/copy-button.gts index 86cc0047..48b488d6 100644 --- a/carbon-components-ember/src/components/copy-button.gts +++ b/carbon-components-ember/src/components/copy-button.gts @@ -3,8 +3,8 @@ import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; import didInsert from '@ember/render-modifiers/modifiers/did-insert'; import EmberTooltip from 'ember-tooltips/components/ember-tooltip'; -import Button from '/components/button.gts'; -import or from '/helpers/or.ts'; +import Button from '../components/button.gts'; +import or from '../helpers/or.ts'; type Args = { targetElementId?: string; diff --git a/carbon-components-ember/src/components/data-table.gts b/carbon-components-ember/src/components/data-table.gts index 1826542b..848c2c5b 100644 --- a/carbon-components-ember/src/components/data-table.gts +++ b/carbon-components-ember/src/components/data-table.gts @@ -10,20 +10,20 @@ import { default as didInsert } from '@ember/render-modifiers/modifiers/did-inse import Component from '@glimmer/component'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; -import { defaultArgs } from '/utils/decorators.ts'; +import { defaultArgs } from '../utils/decorators.ts'; import { A, type NativeArray } from '@ember/array'; import { task } from 'ember-concurrency'; -import TableToolbarComponent from '/components/data-table/-toolbar.gts'; -import TableSearchComponent from '/components/data-table/-search-input.gts'; -import CarbonPagination from '/components/pagination.gts'; -import TableComponent from '/components/data-table/-table.gts'; -import DataTableBody from '/components/data-table/-body.gts'; -import TableMenuComponent from '/components/data-table/-menu.gts'; -import TableColumn from '/components/data-table/-column.gts'; +import TableToolbarComponent from '../components/data-table/-toolbar.gts'; +import TableSearchComponent from '../components/data-table/-search-input.gts'; +import CarbonPagination from '../components/pagination.gts'; +import TableComponent from '../components/data-table/-table.gts'; +import DataTableBody from '../components/data-table/-body.gts'; +import TableMenuComponent from '../components/data-table/-menu.gts'; +import TableColumn from '../components/data-table/-column.gts'; import { type WithBoundArgs } from '@glint/template'; import ListHeaderComponent, { type Header, -} from '/components/data-table/-header.gts'; +} from '../components/data-table/-header.gts'; import { hash } from '@ember/helper'; import { runTask } from 'ember-lifeline'; diff --git a/carbon-components-ember/src/components/dialogs/confirm.gts b/carbon-components-ember/src/components/dialogs/confirm.gts index b0459fb2..ff8b3e06 100644 --- a/carbon-components-ember/src/components/dialogs/confirm.gts +++ b/carbon-components-ember/src/components/dialogs/confirm.gts @@ -9,8 +9,8 @@ import type DialogManagerService from '/services/dialog-manager'; type Args = { onAccept: () => void; onCancel: () => void; - body: string; - header: string; + body?: string; + header?: string; type: string; cancelText?: string; label?: string; diff --git a/carbon-components-ember/src/components/form-input.gts b/carbon-components-ember/src/components/form-input.gts index db616e7b..c18bdf41 100644 --- a/carbon-components-ember/src/components/form-input.gts +++ b/carbon-components-ember/src/components/form-input.gts @@ -1,4 +1,4 @@ -import { default as defaultTo } from '/helpers/default-to.ts'; +import { default as defaultTo } from '../helpers/default-to.ts'; import { on } from '@ember/modifier'; import Component from '@glimmer/component'; import { guidFor } from '@ember/object/internals'; diff --git a/carbon-components-ember/src/components/icon.gts b/carbon-components-ember/src/components/icon.gts index 54c5d718..253254bb 100644 --- a/carbon-components-ember/src/components/icon.gts +++ b/carbon-components-ember/src/components/icon.gts @@ -3,15 +3,15 @@ import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; import * as icons from '@carbon/icons/es/index.js'; -import { bxClassNames, classPrefix } from '/utils/decorators.ts'; +import { bxClassNames, classPrefix } from '../utils/decorators.ts'; import { on } from '@ember/modifier'; -import Loading from '/components/loading.gts'; -import or from '/helpers/or.ts'; -import renderSvgPart from '/components/icon/render-svg-part.ts'; +import Loading from '../components/loading.gts'; +import or from '../helpers/or.ts'; +import renderSvgPart from '../components/icon/render-svg-part.ts'; import { array } from '@ember/helper'; -import htmlSafe from '/helpers/html-safe.ts'; +import htmlSafe from '../helpers/html-safe.ts'; import { stylesheet } from 'astroturf'; -import type DialogManagerService from '/services/dialog-manager'; +import type DialogManagerService from '../services/dialog-manager'; type Icon = { name: IconNames; size: number }; diff --git a/carbon-components-ember/src/services/dialog-manager.ts b/carbon-components-ember/src/services/dialog-manager.ts index bbf14bf7..49e2b716 100644 --- a/carbon-components-ember/src/services/dialog-manager.ts +++ b/carbon-components-ember/src/services/dialog-manager.ts @@ -1,8 +1,9 @@ import Service from '@ember/service'; import { tracked } from '@glimmer/tracking'; +import type Component from '@glimmer/component'; export default class DialogManagerService extends Service { - @tracked currentDialog = null; + @tracked currentDialog?: typeof Component; @tracked options = null; id = 'carbon-components-dialog-id'; @@ -16,7 +17,7 @@ export default class DialogManagerService extends Service { } close() { - this.currentDialog = null; + this.currentDialog = undefined; this.options = null; } } diff --git a/carbon-components-ember/tsconfig.json b/carbon-components-ember/tsconfig.json index 1b4b44d8..6618e71f 100644 --- a/carbon-components-ember/tsconfig.json +++ b/carbon-components-ember/tsconfig.json @@ -44,14 +44,8 @@ We want our tooling to know how to resolve our custom files so the appropriate plugins can do the proper transformations on those files. */ - "allowImportingTsExtensions": true, - "paths": { - "/*": ["./src/*", "./src/*.gts", "./src/*.gjsyml"] - } + "allowImportingTsExtensions": true }, - "exclude": [ - "../node_modules/.pnpm/ember-basic-dropdown@7.3.0_@babel+core@7.24.0_@ember+string@3.1.1_@glint+environment-ember-lo_xalztx43ppp5parmi4bzokibly/node_modules/ember-basic-dropdown/addon/components/basic-dropdown.ts" - ], "include": [ "node_modules/@gavant/glint-template-types/types/ember-power-select/components/power-select.d.ts", "node_modules/@gavant/glint-template-types/types/ember-power-select/components/power-select-multiple.d.ts", diff --git a/carbon-components-ember/types/glint.d.ts b/carbon-components-ember/types/glint.d.ts index 769b1e08..b0e382fb 100644 --- a/carbon-components-ember/types/glint.d.ts +++ b/carbon-components-ember/types/glint.d.ts @@ -1,24 +1,3 @@ -declare module 'ember-cli-addon-docs/components/docs-demo' { - import Component from '@glimmer/component'; - export default class extends Component {} -} - -declare module 'ember-cli-addon-docs/components/docs-viewer' { - import Component from '@glimmer/component'; - export default class extends Component {} -} - -declare module 'ember-cli-addon-docs/components/docs-hero' { - import Component from '@glimmer/component'; - type Args = { - prefix: string; - heading: string; - byline: string; - }; - - export default class extends Component {} -} - declare module 'ember-tooltips/components/ember-tooltip' { import Component from '@glimmer/component'; type Args = { @@ -102,3 +81,10 @@ declare module '@ember/render-modifiers/modifiers/will-destroy' { } declare module '@carbon/icons/es/index.js'; + +declare module '@glint/environment-ember-loose/registry' { + import type { EmbroiderUtilRegistry } from '@embroider/util'; + export default interface Registry extends EmbroiderUtilRegistry { + // ... + } +} diff --git a/doc-app/.eslintrc.js b/doc-app/.eslintrc.js index 29eac66b..d2e5254f 100644 --- a/doc-app/.eslintrc.js +++ b/doc-app/.eslintrc.js @@ -2,45 +2,74 @@ module.exports = { root: true, - parser: '@babel/eslint-parser', + parser: 'ember-eslint-parser', parserOptions: { ecmaVersion: 'latest', sourceType: 'module', - requireConfigFile: false, babelOptions: { - plugins: [ - ['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }], - ], + root: __dirname, }, }, plugins: ['ember'], - extends: [ - 'eslint:recommended', - 'plugin:ember/recommended', - 'plugin:prettier/recommended', - ], + extends: ['plugin:ember/recommended', 'plugin:prettier/recommended'], + globals: { + WithRequired: true, + }, env: { browser: true, }, - rules: {}, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + }, overrides: [ { - files: ['**/*.{gts,gjs}'], + files: ['**/*.ts'], + parser: '@typescript-eslint/parser', + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:ember/recommended', + ], + rules: { + 'ember/no-at-ember-render-modifiers': 'off', + '@typescript-eslint/no-explicit-any': 'off', + 'ember/no-empty-glimmer-component-classes': 'off', + }, + }, + { + files: ['**/*.gts'], parser: 'ember-eslint-parser', + plugins: ['ember'], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:ember/recommended', + 'plugin:ember/recommended-gts', + ], + rules: { + 'ember/no-at-ember-render-modifiers': 'off', + '@typescript-eslint/no-explicit-any': 'off', + 'ember/no-empty-glimmer-component-classes': 'off', + }, + }, + { + files: ['**/*.gjs'], + parser: 'ember-eslint-parser', + plugins: ['ember'], + extends: [ + 'eslint:recommended', + 'plugin:ember/recommended', + 'plugin:ember/recommended-gjs', + ], }, // node files { files: [ - './.eslintrc.js', - './.prettierrc.js', - './.stylelintrc.js', - './.template-lintrc.js', - './ember-cli-build.js', - './testem.js', - './blueprints/*/index.js', - './config/**/*.js', - './lib/*/index.js', - './server/**/*.js', + './.eslintrc.cjs', + './.prettierrc.cjs', + './.template-lintrc.cjs', + './addon-main.cjs', + './babel.config.js', ], parserOptions: { sourceType: 'script', @@ -49,12 +78,8 @@ module.exports = { browser: false, node: true, }, + plugins: ['n'], extends: ['plugin:n/recommended'], }, - { - // test files - files: ['tests/**/*-test.{js,ts}'], - extends: ['plugin:qunit/recommended'], - }, ], }; diff --git a/doc-app/app/pods/application/route.gts b/doc-app/app/pods/application/route.gts index 4d870af7..76bbb197 100644 --- a/doc-app/app/pods/application/route.gts +++ b/doc-app/app/pods/application/route.gts @@ -3,9 +3,23 @@ import Notification from 'carbon-components-ember/components/notification'; import RouteTemplate from 'ember-routable-component'; import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; +import Controller from '@ember/controller'; +import DialogManagerService from 'carbon-components-ember/services/dialog-manager'; -class RouteComponent extends Component { - @service('carbon-components-ember@dialog-manager') dialogManager; +interface Signature { + Args: { + controller: typeof Controller; + model: T; + }; + Blocks: { + default: []; + outlet: []; + }; +} + +class RouteComponent extends Component> { + @service('carbon-components-ember@dialog-manager') + dialogManager: DialogManagerService; @service('carbon-components-ember@notifications') notifications; diff --git a/doc-app/app/pods/docs/components/accordion/route.gts b/doc-app/app/pods/docs/components/accordion/route.gts index 4aa40dbd..f7d78616 100644 --- a/doc-app/app/pods/docs/components/accordion/route.gts +++ b/doc-app/app/pods/docs/components/accordion/route.gts @@ -10,10 +10,10 @@ import Toggle from 'carbon-components-ember/components/toggle'; import Select from 'carbon-components-ember/components/select'; import RadioButtonGroup from 'carbon-components-ember/components/radio/group'; import Radio from 'carbon-components-ember/components/radio'; -import RouteTemplate from 'ember-routable-component'; +import RouteTemplate, { RoutableComponent } from 'ember-routable-component'; import Component from '@glimmer/component'; -class RouteComponent extends Component { +class RouteComponent extends RoutableComponent {