ember-freestyle 0.15.0 → 0.17.0-alpha-css-vars-api.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -2
  3. package/addon/components/freestyle/usage/argument/index.ts +28 -0
  4. package/addon/components/freestyle/usage/array/index.ts +57 -0
  5. package/addon/components/freestyle/usage/basic-css-variable/index.hbs +34 -0
  6. package/addon/components/freestyle/usage/basic-css-variable/index.ts +28 -0
  7. package/addon/components/freestyle/usage/bool/control/index.ts +19 -0
  8. package/addon/components/freestyle/usage/bool/index.ts +25 -0
  9. package/addon/components/freestyle/usage/index.hbs +27 -1
  10. package/addon/components/freestyle/usage/index.ts +84 -0
  11. package/addon/components/freestyle/usage/number/control/index.ts +30 -0
  12. package/addon/components/freestyle/usage/number/index.ts +20 -0
  13. package/addon/components/freestyle/usage/object/control/{index.js → index.ts} +13 -4
  14. package/addon/components/freestyle/usage/object/index.ts +19 -0
  15. package/addon/components/freestyle/usage/string/control/index.ts +24 -0
  16. package/addon/components/freestyle/usage/string/index.hbs +0 -1
  17. package/addon/components/freestyle/usage/string/index.ts +18 -0
  18. package/addon/components/freestyle-annotation/index.hbs +1 -1
  19. package/addon/components/freestyle-annotation/index.ts +26 -0
  20. package/addon/components/freestyle-collection/index.hbs +1 -1
  21. package/addon/components/freestyle-collection/index.ts +61 -0
  22. package/addon/components/freestyle-dynamic/index.hbs +0 -1
  23. package/addon/components/freestyle-dynamic/index.ts +79 -0
  24. package/addon/components/freestyle-dynamic-input/index.hbs +1 -1
  25. package/addon/components/freestyle-dynamic-input/index.ts +59 -0
  26. package/addon/components/freestyle-dynamic-input-select-option/index.hbs +1 -1
  27. package/addon/components/freestyle-dynamic-input-select-option/index.ts +18 -0
  28. package/addon/components/freestyle-focus-button/index.ts +11 -0
  29. package/addon/components/freestyle-guide/index.ts +64 -0
  30. package/addon/components/freestyle-menu/index.ts +20 -0
  31. package/addon/components/freestyle-palette/index.hbs +1 -1
  32. package/addon/components/freestyle-palette/index.ts +42 -0
  33. package/addon/components/freestyle-palette-item/index.hbs +1 -1
  34. package/addon/components/freestyle-palette-item/index.ts +20 -0
  35. package/addon/components/freestyle-section/index.hbs +1 -1
  36. package/addon/components/freestyle-section/index.ts +26 -0
  37. package/addon/components/freestyle-source/index.hbs +1 -1
  38. package/addon/components/freestyle-source/index.ts +89 -0
  39. package/addon/components/freestyle-subsection/index.ts +24 -0
  40. package/addon/components/freestyle-typeface/index.hbs +1 -1
  41. package/addon/components/freestyle-typeface/index.ts +17 -0
  42. package/addon/components/freestyle-usage/index.hbs +6 -2
  43. package/addon/components/freestyle-usage/index.ts +63 -0
  44. package/addon/components/freestyle-usage-controls/index.hbs +2 -2
  45. package/addon/components/freestyle-usage-controls/index.ts +69 -0
  46. package/addon/components/freestyle-variant/index.hbs +1 -1
  47. package/addon/components/freestyle-variant/index.ts +33 -0
  48. package/addon/components/freestyle-variant-list/index.hbs +2 -2
  49. package/addon/components/freestyle-variant-list/index.ts +15 -0
  50. package/addon/controllers/freestyle.ts +26 -0
  51. package/addon/decorators/css-variable.ts +155 -0
  52. package/addon/glint.ts +77 -0
  53. package/addon/index.ts +2 -0
  54. package/addon/modifiers/freestyle-highlight.ts +17 -0
  55. package/addon/services/{ember-freestyle.js → ember-freestyle.ts} +52 -31
  56. package/addon/utils/css-rules.ts +61 -0
  57. package/app/components/freestyle/usage/basic-css-variable.js +1 -0
  58. package/app/styles/components/freestyle/usage.scss +12 -4
  59. package/app/styles/components/freestyle-guide.scss +4 -0
  60. package/blueprints/ember-freestyle/index.js +1 -0
  61. package/components/freestyle/usage/argument/index.d.ts +20 -0
  62. package/components/freestyle/usage/array/index.d.ts +28 -0
  63. package/components/freestyle/usage/basic-css-variable/index.d.ts +19 -0
  64. package/components/freestyle/usage/bool/control/index.d.ts +11 -0
  65. package/components/freestyle/usage/bool/index.d.ts +19 -0
  66. package/components/freestyle/usage/index.d.ts +46 -0
  67. package/components/freestyle/usage/number/control/index.d.ts +18 -0
  68. package/components/freestyle/usage/number/index.d.ts +18 -0
  69. package/components/freestyle/usage/object/control/index.d.ts +11 -0
  70. package/components/freestyle/usage/object/index.d.ts +15 -0
  71. package/components/freestyle/usage/string/control/index.d.ts +14 -0
  72. package/components/freestyle/usage/string/index.d.ts +16 -0
  73. package/components/freestyle-annotation/index.d.ts +16 -0
  74. package/components/freestyle-collection/index.d.ts +33 -0
  75. package/components/freestyle-dynamic/index.d.ts +38 -0
  76. package/components/freestyle-dynamic-input/index.d.ts +30 -0
  77. package/components/freestyle-dynamic-input-select-option/index.d.ts +15 -0
  78. package/components/freestyle-focus-button/index.d.ts +8 -0
  79. package/components/freestyle-guide/index.d.ts +28 -0
  80. package/components/freestyle-menu/index.d.ts +15 -0
  81. package/components/freestyle-palette/index.d.ts +27 -0
  82. package/components/freestyle-palette-item/index.d.ts +15 -0
  83. package/components/freestyle-section/index.d.ts +22 -0
  84. package/components/freestyle-source/index.d.ts +20 -0
  85. package/components/freestyle-subsection/index.d.ts +17 -0
  86. package/components/freestyle-typeface/index.d.ts +14 -0
  87. package/components/freestyle-usage/index.d.ts +31 -0
  88. package/components/freestyle-usage-controls/index.d.ts +25 -0
  89. package/components/freestyle-variant/index.d.ts +20 -0
  90. package/components/freestyle-variant-list/index.d.ts +12 -0
  91. package/controllers/freestyle.d.ts +14 -0
  92. package/decorators/css-variable.d.ts +24 -0
  93. package/glint.d.ts +76 -0
  94. package/index.d.ts +2 -0
  95. package/lib/ast-transform.js +3 -2
  96. package/modifiers/freestyle-highlight.d.ts +11 -0
  97. package/package.json +52 -14
  98. package/services/ember-freestyle.d.ts +43 -0
  99. package/tsconfig.json +74 -0
  100. package/types/ember-truth-helpers/helpers/-private/shared.d.ts +24 -0
  101. package/types/ember-truth-helpers/helpers/and.d.ts +27 -0
  102. package/types/ember-truth-helpers/helpers/eq.d.ts +9 -0
  103. package/types/ember-truth-helpers/helpers/gt.d.ts +9 -0
  104. package/types/ember-truth-helpers/helpers/lt.d.ts +9 -0
  105. package/types/ember-truth-helpers/helpers/not.d.ts +9 -0
  106. package/types/ember-truth-helpers/helpers/or.d.ts +29 -0
  107. package/types/global.d.ts +24 -0
  108. package/types/globals.d.ts +7 -0
  109. package/utils/css-rules.d.ts +2 -0
  110. package/vendor/ember-freestyle.css +27 -13
  111. package/addon/components/freestyle/usage/argument/index.js +0 -12
  112. package/addon/components/freestyle/usage/array/index.js +0 -32
  113. package/addon/components/freestyle/usage/bool/control/index.js +0 -9
  114. package/addon/components/freestyle/usage/bool/index.js +0 -8
  115. package/addon/components/freestyle/usage/index.js +0 -46
  116. package/addon/components/freestyle/usage/number/control/index.js +0 -14
  117. package/addon/components/freestyle/usage/string/control/index.js +0 -13
  118. package/addon/components/freestyle-annotation/index.js +0 -23
  119. package/addon/components/freestyle-collection/index.js +0 -41
  120. package/addon/components/freestyle-dynamic/index.js +0 -47
  121. package/addon/components/freestyle-dynamic-input/index.js +0 -39
  122. package/addon/components/freestyle-dynamic-input-select-option/index.js +0 -9
  123. package/addon/components/freestyle-guide/index.js +0 -42
  124. package/addon/components/freestyle-menu/index.js +0 -9
  125. package/addon/components/freestyle-palette/index.js +0 -17
  126. package/addon/components/freestyle-palette-item/index.js +0 -12
  127. package/addon/components/freestyle-section/index.js +0 -9
  128. package/addon/components/freestyle-source/index.js +0 -83
  129. package/addon/components/freestyle-subsection/index.js +0 -12
  130. package/addon/components/freestyle-typeface/index.js +0 -10
  131. package/addon/components/freestyle-usage/index.js +0 -53
  132. package/addon/components/freestyle-usage-controls/index.js +0 -37
  133. package/addon/components/freestyle-variant/index.js +0 -22
  134. package/addon/components/freestyle-variant-list/index.js +0 -10
  135. package/addon/controllers/freestyle.js +0 -21
  136. package/addon/modifiers/freestyle-highlight.js +0 -10
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
5
 
6
+
7
+
8
+ ## v0.17.0-alpha-css-vars-api.0 (2022-10-17)
9
+
10
+ #### :rocket: Enhancement
11
+ * [#856](https://github.com/chrislopresto/ember-freestyle/pull/856) Make the navigation menu sticky ([@bertdeblock](https://github.com/bertdeblock))
12
+
13
+ #### Committers: 1
14
+ - Bert De Block ([@bertdeblock](https://github.com/bertdeblock))
15
+
16
+ ## v0.16.0-beta.0 (2022-09-22)
17
+
18
+ #### :boom: Breaking Change
19
+ * [#847](https://github.com/chrislopresto/ember-freestyle/pull/847) Convert to Glimmer, Typescript, & Glint ([@lukemelia](https://github.com/lukemelia))
20
+
21
+ #### Committers: 1
22
+ - Luke Melia ([@lukemelia](https://github.com/lukemelia))
23
+
6
24
  ## v0.15.0 (2022-09-14)
7
25
 
8
26
  #### :rocket: Enhancement
package/README.md CHANGED
@@ -23,11 +23,13 @@ To see Ember Freestyle in action, visit [https://chrislopresto.github.io/ember-f
23
23
 
24
24
  ## Compatibility
25
25
 
26
- * Ember.js v3.16 or above
27
- * Ember CLI v3.16 or above
26
+ * Ember.js v3.24 or above
27
+ * Ember CLI v3.24 or above
28
28
  * Node.js v14 or above
29
29
  * Ember Auto Import v2 or above
30
30
 
31
+ ember-freestyle includes Typescript types and provides `addon/glint.ts` for Glint usage
32
+
31
33
  ## Installation
32
34
 
33
35
  This installation process is opinionated in order to get you going quickly.
@@ -0,0 +1,28 @@
1
+ import { isPresent } from '@ember/utils';
2
+ import Component from '@glimmer/component';
3
+
4
+ interface Signature {
5
+ Args: {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ defaultValue?: any;
8
+ description?: string;
9
+ name?: string;
10
+ type?: string;
11
+ typeLabel?: string;
12
+ required?: boolean;
13
+ hideControls?: boolean;
14
+ };
15
+ Blocks: {
16
+ default: [];
17
+ };
18
+ }
19
+
20
+ export default class FreestyleUsageArgumentComponent extends Component<Signature> {
21
+ get shouldRenderDefaultValue(): boolean {
22
+ return isPresent(this.args.defaultValue);
23
+ }
24
+
25
+ get typeLabel(): string | undefined {
26
+ return this.args.typeLabel || this.args.type;
27
+ }
28
+ }
@@ -0,0 +1,57 @@
1
+ import Component from '@glimmer/component';
2
+ import MutableArray from '@ember/array/mutable';
3
+
4
+ /* eslint-disable @typescript-eslint/no-unused-vars */
5
+ import { action } from '@ember/object';
6
+ import { equal } from 'macro-decorators';
7
+
8
+ const STRING = 'String';
9
+ const BOOL = 'Boolean';
10
+ const NUMBER = 'Number';
11
+ const OBJECT = 'Object';
12
+ /* eslint-enable @typescript-eslint/no-unused-vars */
13
+
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ type ItemArray = MutableArray<any>;
16
+
17
+ interface Signature {
18
+ Args: {
19
+ items: ItemArray;
20
+ identity?: string;
21
+ type: string;
22
+ name?: string;
23
+ description?: string;
24
+ required?: boolean;
25
+ defaultValue?: unknown;
26
+ hideControls?: boolean;
27
+ readOnly?: boolean;
28
+ jsonCollapseDepth?: number;
29
+ onChange: (items: ItemArray) => void;
30
+ };
31
+ }
32
+
33
+ export default class FreestyleUsageArrayComponent extends Component<Signature> {
34
+ @action addItem(): void {
35
+ const { onChange, items } = this.args;
36
+ items.pushObject('');
37
+ onChange && onChange(items);
38
+ }
39
+
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
41
+ @action updateItem(index: number, value: any): void {
42
+ const { onChange, items } = this.args;
43
+ items.replace(index, 1, [value]);
44
+ onChange && onChange(items);
45
+ }
46
+
47
+ @action removeItem(index: number): void {
48
+ const { onChange, items } = this.args;
49
+ items.removeAt(index, 1);
50
+ onChange && onChange(items);
51
+ }
52
+
53
+ @equal('args.type', STRING) declare useStringControl: boolean;
54
+ @equal('args.type', BOOL) declare useBooleanControl: boolean;
55
+ @equal('args.type', NUMBER) declare useNumberControl: boolean;
56
+ @equal('args.type', OBJECT) declare useObjectControl: boolean;
57
+ }
@@ -0,0 +1,34 @@
1
+ <tr class="FreestyleUsageCssVar">
2
+ <td class="FreestyleUsageCssVar-name">
3
+ {{@name}}
4
+ </td>
5
+
6
+ <td class="FreestyleUsageCssVar-description">
7
+ <span class="FreestyleUsageCssVar-type u-codePill">
8
+ {{@type}}
9
+ </span>
10
+
11
+ {{@description}}
12
+ </td>
13
+
14
+ <td class="FreestyleUsageCssVar-details">
15
+ {{#if this.shouldRenderDefaultValue}}
16
+ <span class="FreestyleUsageCssVar-default u-codePill">
17
+ {{@defaultValue.raw}}
18
+ </span>
19
+ {{#if this.shouldRenderDefaultComputed}}
20
+ ({{@defaultValue.computed}})
21
+ {{/if}}
22
+ {{/if}}
23
+ </td>
24
+
25
+ <td class="FreestyleUsageCssVar-controls FreestyleUsageCssVar-controls--string">
26
+ {{#unless @hideControls}}
27
+ <Freestyle::Usage::String::Control
28
+ @options={{@options}}
29
+ @value={{@value}}
30
+ @onInput={{@onInput}}
31
+ />
32
+ {{/unless}}
33
+ </td>
34
+ </tr>
@@ -0,0 +1,28 @@
1
+ import Component from '@glimmer/component';
2
+ import { type CSSVariableDefaults } from 'ember-freestyle';
3
+
4
+ interface Signature {
5
+ Args: {
6
+ name?: string;
7
+ description?: string;
8
+ defaultValue?: CSSVariableDefaults;
9
+ type?: string;
10
+ hideControls?: boolean;
11
+ value?: string;
12
+ options?: string[];
13
+ onInput: (val: string | null | undefined) => void;
14
+ };
15
+ }
16
+
17
+ export default class FreestyleUsageBasicCssVariableComponent extends Component<Signature> {
18
+ get shouldRenderDefaultValue(): boolean {
19
+ return this.args.defaultValue !== undefined;
20
+ }
21
+ get shouldRenderDefaultComputed(): boolean {
22
+ const { defaultValue } = this.args;
23
+ return (
24
+ defaultValue?.computed !== undefined &&
25
+ defaultValue.computed !== defaultValue.raw
26
+ );
27
+ }
28
+ }
@@ -0,0 +1,19 @@
1
+ import Component from '@glimmer/component';
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ import { action } from '@ember/object';
4
+
5
+ interface Signature {
6
+ Args: {
7
+ value?: boolean;
8
+ onInput: (val: boolean) => void;
9
+ };
10
+ }
11
+
12
+ export default class FreestyleUsageBoolControlComponent extends Component<Signature> {
13
+ @action
14
+ callOnInput(event: InputEvent): void {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const eventTarget = event.target as any;
17
+ this.args.onInput(eventTarget.checked);
18
+ }
19
+ }
@@ -0,0 +1,25 @@
1
+ import Component from '@glimmer/component';
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ import { action } from '@ember/object';
4
+
5
+ interface Signature {
6
+ Args: {
7
+ name?: string;
8
+ description?: string;
9
+ required?: boolean;
10
+ defaultValue?: boolean;
11
+ hideControls?: boolean;
12
+ value?: boolean;
13
+ onInput: (val: boolean) => void;
14
+ };
15
+ Blocks: {
16
+ default: [];
17
+ };
18
+ }
19
+ export default class FreestyleUsageBoolComponent extends Component<Signature> {
20
+ @action onInput(event: InputEvent): void {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ const eventTarget = event.target as any;
23
+ this.args.onInput(eventTarget.checked);
24
+ }
25
+ }
@@ -56,9 +56,35 @@
56
56
  {{/if}}
57
57
  {{/if}}
58
58
 
59
+ {{#if (has-block 'cssVars')}}
60
+ {{#if this.showApi}}
61
+ <div class="FreestyleUsage-cssVars">
62
+ <h3 class="FreestyleUsage-cssVarsTitle">CSS Variables API</h3>
63
+
64
+ <table class="FreestyleUsage-cssVarsTable">
65
+ <thead>
66
+ <tr>
67
+ <th>Variable</th>
68
+ <th>Description</th>
69
+ <th>Default</th>
70
+ <th>Value</th>
71
+ </tr>
72
+ </thead>
73
+ <tbody>
74
+ {{yield
75
+ (hash
76
+ Basic=(component 'freestyle/usage/basic-css-variable' )
77
+ )
78
+ to="cssVars"}}
79
+ </tbody>
80
+ </table>
81
+ </div>
82
+ {{/if}}
83
+ {{/if}}
84
+
59
85
  {{#if this.showSource}}
60
86
  <div class="FreestyleUsage-sourceContainer" {{did-insert this.highlightSource}}>
61
- <FreestyleSource @source={{@source}} @title="Source" />
87
+ <FreestyleSource @source={{@source}} />
62
88
  </div>
63
89
  {{/if}}
64
90
  </div>
@@ -0,0 +1,84 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import Component from '@glimmer/component';
3
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4
+ import { inject as service } from '@ember/service';
5
+ import { action } from '@ember/object';
6
+ /* eslint-enable @typescript-eslint/no-unused-vars */
7
+ import type EmberFreestyleService from '../../../services/ember-freestyle';
8
+
9
+ interface Signature {
10
+ Element: HTMLDivElement;
11
+ Args: {
12
+ name?: string;
13
+ description?: string;
14
+ slug?: string;
15
+ source?: string;
16
+ highlightJsTheme?: string;
17
+ };
18
+ Blocks: {
19
+ description: [];
20
+ example: [];
21
+ api: [
22
+ {
23
+ Array: any;
24
+ Base: any;
25
+ Bool: any;
26
+ Number: any;
27
+ Object: any;
28
+ String: any;
29
+ Action: any;
30
+ Yield: any;
31
+ }
32
+ ];
33
+ cssVars: [
34
+ {
35
+ Basic: any;
36
+ }
37
+ ];
38
+ };
39
+ }
40
+
41
+ export default class extends Component<Signature> {
42
+ @service('ember-freestyle') declare emberFreestyle: EmberFreestyleService;
43
+
44
+ get showName(): boolean {
45
+ return this.emberFreestyle.showLabels && !!this.args.name;
46
+ }
47
+ get showNotes(): boolean {
48
+ return this.emberFreestyle.showNotes;
49
+ }
50
+ get showSource(): boolean {
51
+ return !!this.args.source && this.emberFreestyle.showCode;
52
+ }
53
+ get showApi(): boolean {
54
+ return this.emberFreestyle.showApi;
55
+ }
56
+ get show(): boolean {
57
+ const {
58
+ effectiveSlug,
59
+ emberFreestyle: { focus },
60
+ } = this;
61
+
62
+ if (effectiveSlug && focus) {
63
+ return !!effectiveSlug.match(focus);
64
+ } else {
65
+ return true;
66
+ }
67
+ }
68
+
69
+ get effectiveSlug(): string | undefined {
70
+ return this.args.slug || this.args.name;
71
+ }
72
+
73
+ get computedTheme(): string {
74
+ return this.args.highlightJsTheme || this.emberFreestyle.defaultTheme;
75
+ }
76
+
77
+ @action highlightSource(): void {
78
+ this.emberFreestyle.ensureHljsTheme(this.computedTheme);
79
+ }
80
+
81
+ @action setFocus(): void {
82
+ this.emberFreestyle.focus = this.effectiveSlug ?? null;
83
+ }
84
+ }
@@ -0,0 +1,30 @@
1
+ import Component from '@glimmer/component';
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ import { action } from '@ember/object';
4
+ import { isPresent } from '@ember/utils';
5
+
6
+ interface Signature {
7
+ Args: {
8
+ value?: number;
9
+ min?: number;
10
+ max?: number;
11
+ step?: number;
12
+ onInput: (val: number | null) => void;
13
+ };
14
+ Blocks: {
15
+ default: [];
16
+ };
17
+ }
18
+
19
+ export default class FreestyleUsageNumberControlComponent extends Component<Signature> {
20
+ get shouldRenderRangeInput(): boolean {
21
+ return isPresent(this.args.min) && isPresent(this.args.max);
22
+ }
23
+
24
+ @action onInput(event: InputEvent): void {
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ const eventTarget = event.target as any;
27
+ const value = eventTarget?.value;
28
+ this.args.onInput(value ? parseFloat(value) : null);
29
+ }
30
+ }
@@ -0,0 +1,20 @@
1
+ import templateOnlyComponent from '@ember/component/template-only';
2
+ import { type EmptyObject } from '@ember/component/helper';
3
+
4
+ interface Signature {
5
+ Args: {
6
+ name?: string;
7
+ description?: string;
8
+ required?: boolean;
9
+ defaultValue?: number;
10
+ hideControls?: boolean;
11
+ value?: number;
12
+ min?: number;
13
+ max?: number;
14
+ step?: number;
15
+ onInput: (val: number) => void;
16
+ };
17
+ Blocks: EmptyObject;
18
+ }
19
+ const FreestyleUsageNumberComponent = templateOnlyComponent<Signature>();
20
+ export default FreestyleUsageNumberComponent;
@@ -1,14 +1,23 @@
1
1
  import Component from '@glimmer/component';
2
- import JsonFormatter from 'json-formatter-js';
2
+ import JsonFormatter, {
3
+ type JSONFormatterConfiguration,
4
+ } from 'json-formatter-js';
3
5
 
4
- const OPTIONS = {
6
+ const OPTIONS: JSONFormatterConfiguration = {
5
7
  animateClose: false,
6
8
  animateOpen: false,
7
9
  theme: 'dark',
8
10
  };
9
11
 
10
- export default class FreestyleUsageObjectControlComponent extends Component {
11
- get jsonTree() {
12
+ interface Signature {
13
+ Args: {
14
+ value: Record<string, unknown>;
15
+ jsonCollapseDepth?: number;
16
+ };
17
+ }
18
+
19
+ export default class FreestyleUsageObjectControlComponent extends Component<Signature> {
20
+ get jsonTree(): HTMLDivElement {
12
21
  const json = this.args.value;
13
22
  const openDepth = this.args.jsonCollapseDepth;
14
23
  const jsonFormatter = new JsonFormatter(json, openDepth, OPTIONS);
@@ -0,0 +1,19 @@
1
+ import templateOnlyComponent from '@ember/component/template-only';
2
+ import { type EmptyObject } from '@ember/component/helper';
3
+
4
+ interface Signature {
5
+ Args: {
6
+ name?: string;
7
+ description?: string;
8
+ required?: boolean;
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ value?: any;
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ defaultValue?: any;
13
+ hideControls?: boolean;
14
+ jsonCollapseDepth?: number;
15
+ };
16
+ Blocks: EmptyObject;
17
+ }
18
+ const FreestyleUsageObjectComponent = templateOnlyComponent<Signature>();
19
+ export default FreestyleUsageObjectComponent;
@@ -0,0 +1,24 @@
1
+ import Component from '@glimmer/component';
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ import { action } from '@ember/object';
4
+
5
+ interface Signature {
6
+ Args: {
7
+ value?: string;
8
+ inputEvent?: string;
9
+ onInput: (s: string | null) => void;
10
+ options?: string[];
11
+ };
12
+ }
13
+ export default class FreestyleUsageStringControlComponent extends Component<Signature> {
14
+ get inputEvent(): string {
15
+ return this.args.inputEvent || 'input';
16
+ }
17
+
18
+ @action
19
+ callOnInput(event: InputEvent): void {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ const eventTarget = event.target as any;
22
+ this.args.onInput(eventTarget?.value);
23
+ }
24
+ }
@@ -3,7 +3,6 @@
3
3
  @name={{@name}}
4
4
  @description={{@description}}
5
5
  @required={{@required}}
6
- @array={{@array}}
7
6
  @defaultValue={{@defaultValue}}
8
7
  @hideControls={{@hideControls}}
9
8
  >
@@ -0,0 +1,18 @@
1
+ import templateOnlyComponent from '@ember/component/template-only';
2
+ import { type EmptyObject } from '@ember/component/helper';
3
+
4
+ interface Signature {
5
+ Args: {
6
+ name?: string;
7
+ description?: string;
8
+ required?: boolean;
9
+ defaultValue?: string;
10
+ hideControls?: boolean;
11
+ value?: string;
12
+ options?: string[];
13
+ onInput: (val: string | null | undefined) => void;
14
+ };
15
+ Blocks: EmptyObject;
16
+ }
17
+ const FreestyleUsageStringComponent = templateOnlyComponent<Signature>();
18
+ export default FreestyleUsageStringComponent;
@@ -1,4 +1,4 @@
1
- <div class="FreestyleAnnotation {{if this.showNotes 'is-showing' 'is-hidden'}}">
1
+ <div class="FreestyleAnnotation {{if this.showNotes 'is-showing' 'is-hidden'}}" ...attributes>
2
2
  {{#if this.showNotes}}
3
3
  {{yield}}
4
4
  {{/if}}
@@ -0,0 +1,26 @@
1
+ import Component from '@glimmer/component';
2
+ import EmberFreestyleService from '../../services/ember-freestyle';
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+ import { inject as service } from '@ember/service';
5
+
6
+ interface Signature {
7
+ Element: HTMLDivElement;
8
+ Args: {
9
+ slug?: string;
10
+ };
11
+ Blocks: {
12
+ default: [];
13
+ };
14
+ }
15
+ export default class FreestyleAnnotation extends Component<Signature> {
16
+ @service('ember-freestyle') declare emberFreestyle: EmberFreestyleService;
17
+
18
+ get showNotes(): boolean {
19
+ const slug = this.args.slug;
20
+ const focus = this.emberFreestyle.focus;
21
+ if (focus && slug) {
22
+ return !!slug.match(focus);
23
+ }
24
+ return this.emberFreestyle.showNotes;
25
+ }
26
+ }
@@ -1,4 +1,4 @@
1
- <div class="FreestyleCollection {{if @inline 'FreestyleCollection--inline'}}">
1
+ <div class="FreestyleCollection {{if @inline 'FreestyleCollection--inline'}}" ...attributes>
2
2
  {{#if this.hasLabels}}
3
3
  <div class="FreestyleCollection-title">
4
4
  {{@title}}
@@ -0,0 +1,61 @@
1
+ import Component from '@glimmer/component';
2
+ import { next } from '@ember/runloop';
3
+ import type EmberFreestyleService from '../../services/ember-freestyle';
4
+ import { TrackedArray } from 'tracked-built-ins';
5
+ import type { WithBoundArgs } from '@glint/template';
6
+ import type FreestyleVariant from '../freestyle-variant';
7
+ /* eslint-disable @typescript-eslint/no-unused-vars */
8
+ import { inject as service } from '@ember/service';
9
+ import { tracked } from '@glimmer/tracking';
10
+ import { and, not, reads } from 'macro-decorators';
11
+ import { action } from '@ember/object';
12
+ /* eslint-enable @typescript-eslint/no-unused-vars */
13
+
14
+ interface Signature {
15
+ Element: HTMLDivElement;
16
+ Args: {
17
+ inline?: boolean;
18
+ title?: string;
19
+ defaultKey?: string;
20
+ };
21
+ Blocks: {
22
+ default: [
23
+ { variant: WithBoundArgs<typeof FreestyleVariant, 'collection'> }
24
+ ];
25
+ };
26
+ }
27
+
28
+ export default class FreestyleCollection extends Component<Signature> {
29
+ @service('ember-freestyle') declare emberFreestyle: EmberFreestyleService;
30
+ @and('emberFreestyle.notFocused', 'emberFreestyle.showLabels')
31
+ declare showLabels: boolean;
32
+ @and('showLabels', 'args.title') declare hasLabels: boolean;
33
+ @not('emberFreestyle.focus') declare showVariantList: boolean;
34
+ @reads('args.defaultKey', 'all') declare defaultKey: string;
35
+
36
+ @tracked key: string | null = null;
37
+ @tracked variants = new TrackedArray(['all']);
38
+
39
+ get activeKey(): string {
40
+ if (this.emberFreestyle.focus) {
41
+ return 'all';
42
+ }
43
+ return this.key || this.defaultKey;
44
+ }
45
+
46
+ registerVariant(variantKey: string): void {
47
+ next(() => {
48
+ if (this.isDestroyed) {
49
+ return;
50
+ }
51
+ if (!this.variants.includes(variantKey)) {
52
+ this.variants.push(variantKey);
53
+ }
54
+ });
55
+ }
56
+
57
+ @action
58
+ setKey(key: string): void {
59
+ this.key = key;
60
+ }
61
+ }
@@ -21,7 +21,6 @@
21
21
  @slug={{@slug}}
22
22
  @title={{@title}}
23
23
  @isDynamic={{true}}
24
- @componentName={{@componentName}}
25
24
  @source={{@source}}
26
25
  @dynamicProperties={{@dynamicProperties}}
27
26
  >