ember-primitives 0.52.0 → 0.53.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.
- package/declarations/components/-private/utils.d.ts +1 -1
- package/declarations/components/-private/utils.d.ts.map +1 -1
- package/declarations/components/breadcrumb.d.ts +1 -1
- package/declarations/components/switch.d.ts +18 -3
- package/declarations/components/switch.d.ts.map +1 -1
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/switch.js +8 -4
- package/dist/components/switch.js.map +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/{utils-D0v9WKmV.js → utils-BBQjrXDg.js} +2 -2
- package/dist/utils-BBQjrXDg.js.map +1 -0
- package/package.json +7 -7
- package/src/components/-private/utils.ts +2 -3
- package/src/components/breadcrumb.gts +1 -1
- package/src/components/switch.gts +41 -22
- package/dist/utils-D0v9WKmV.js.map +0 -1
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* If the user provides an onChange or similar function, use that,
|
|
3
3
|
* otherwise fallback to the uncontrolled toggle
|
|
4
4
|
*/
|
|
5
|
-
export declare function toggleWithFallback(uncontrolledToggle: (...args:
|
|
5
|
+
export declare function toggleWithFallback(uncontrolledToggle: undefined | ((...args: any[]) => void) | (() => void), controlledToggle?: (...args: any[]) => void, ...args: unknown[]): void;
|
|
6
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/-private/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,CAAC,GAAG,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/-private/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,EACzE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAC3C,GAAG,IAAI,EAAE,OAAO,EAAE,QAOnB"}
|
|
@@ -16,7 +16,7 @@ export interface Signature {
|
|
|
16
16
|
/**
|
|
17
17
|
* A separator component to place between breadcrumb items.
|
|
18
18
|
* Typically renders as "/" or ">" and is decorative (aria-hidden="true").
|
|
19
|
-
* Pre-configured to render as an
|
|
19
|
+
* Pre-configured to render as an `<li>` element for proper HTML structure.
|
|
20
20
|
*/
|
|
21
21
|
Separator: WithBoundArgs<typeof Separator, "as" | "decorative">;
|
|
22
22
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cell } from "ember-resources";
|
|
1
2
|
import { Label } from './-private/typed-elements';
|
|
2
3
|
import type { TOC } from "@ember/component/template-only";
|
|
3
4
|
import type { WithBoundArgs } from "@glint/template";
|
|
@@ -18,13 +19,27 @@ export interface Signature {
|
|
|
18
19
|
Blocks: {
|
|
19
20
|
default?: [
|
|
20
21
|
{
|
|
22
|
+
/**
|
|
23
|
+
* The current state of the Switch.
|
|
24
|
+
*
|
|
25
|
+
* ```gjs
|
|
26
|
+
* import { Switch } from 'ember-primitives/components/switch';
|
|
27
|
+
*
|
|
28
|
+
* <template>
|
|
29
|
+
* <Switch as |s|>
|
|
30
|
+
* {{s.isChecked}}
|
|
31
|
+
* </Switch>
|
|
32
|
+
* </template>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
isChecked: boolean;
|
|
21
36
|
/**
|
|
22
37
|
* The Switch Element.
|
|
23
38
|
* It has a pre-wired `id` so that the relevant Label is
|
|
24
39
|
* appropriately associated via the `for` property of the Label.
|
|
25
40
|
*
|
|
26
41
|
* ```gjs
|
|
27
|
-
* import { Switch } from 'ember-primitives';
|
|
42
|
+
* import { Switch } from 'ember-primitives/components/switch';
|
|
28
43
|
*
|
|
29
44
|
* <template>
|
|
30
45
|
* <Switch as |s|>
|
|
@@ -39,7 +54,7 @@ export interface Signature {
|
|
|
39
54
|
* the association to the Control by setting the `for` attribute to the `id` of the Control
|
|
40
55
|
*
|
|
41
56
|
* ```gjs
|
|
42
|
-
* import { Switch } from 'ember-
|
|
57
|
+
* import { Switch } from 'ember-primitive/components/switchs';
|
|
43
58
|
*
|
|
44
59
|
* <template>
|
|
45
60
|
* <Switch as |s|>
|
|
@@ -57,7 +72,7 @@ interface ControlSignature {
|
|
|
57
72
|
Element: HTMLInputElement;
|
|
58
73
|
Args: {
|
|
59
74
|
id: string;
|
|
60
|
-
checked?: boolean
|
|
75
|
+
checked?: ReturnType<typeof cell<boolean>>;
|
|
61
76
|
onChange: () => void;
|
|
62
77
|
};
|
|
63
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/components/switch.gts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/components/switch.gts"],"names":[],"mappings":"AA6HA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAGtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,IAAI,EAAE;QACJ;;;;WAIG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;WAEG;QACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KACrD,CAAC;IACF,MAAM,EAAE;QACN,OAAO,CAAC,EAAE;YACR;gBACE;;;;;;;;;;;;mBAYG;gBACH,SAAS,EAAE,OAAO,CAAC;gBACnB;;;;;;;;;;;;;;mBAcG;gBACH,OAAO,EAAE,aAAa,CAAC,OAAO,QAAQ,EAAE,SAAS,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC;gBACvE;;;;;;;;;;;;;mBAaG;gBACH,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC;aAC3C;SACF,CAAC;KACH,CAAC;CACH;AAED,UAAU,gBAAgB;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CACxF;AAED,QAAA,MAAM,QAAQ,EAAE,GAAG,CAAC,gBAAgB,CAsBlC,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,GAAG,CAAC,SAAS,CAgChC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumb.js","sources":["../../src/components/breadcrumb.gts"],"sourcesContent":["import { hash } from \"@ember/helper\";\n\nimport { Separator } from \"./separator.gts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type { WithBoundArgs } from \"@glint/template\";\n\nexport interface Signature {\n Element: HTMLElement;\n Args: {\n /**\n * The accessible label for the breadcrumb navigation.\n * Defaults to \"Breadcrumb\"\n */\n label?: string;\n };\n Blocks: {\n default: [\n {\n /**\n * A separator component to place between breadcrumb items.\n * Typically renders as \"/\" or \">\" and is decorative (aria-hidden=\"true\").\n * Pre-configured to render as an
|
|
1
|
+
{"version":3,"file":"breadcrumb.js","sources":["../../src/components/breadcrumb.gts"],"sourcesContent":["import { hash } from \"@ember/helper\";\n\nimport { Separator } from \"./separator.gts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type { WithBoundArgs } from \"@glint/template\";\n\nexport interface Signature {\n Element: HTMLElement;\n Args: {\n /**\n * The accessible label for the breadcrumb navigation.\n * Defaults to \"Breadcrumb\"\n */\n label?: string;\n };\n Blocks: {\n default: [\n {\n /**\n * A separator component to place between breadcrumb items.\n * Typically renders as \"/\" or \">\" and is decorative (aria-hidden=\"true\").\n * Pre-configured to render as an `<li>` element for proper HTML structure.\n */\n Separator: WithBoundArgs<typeof Separator, \"as\" | \"decorative\">;\n },\n ];\n };\n}\n\n/**\n * A breadcrumb navigation component that displays the current page's location within a navigational hierarchy.\n *\n * Breadcrumbs help users understand their current location and provide a way to navigate back through the hierarchy.\n *\n * For example:\n *\n * ```gjs live preview\n * import { Breadcrumb } from 'ember-primitives';\n *\n * <template>\n * <Breadcrumb as |b|>\n * <li>\n * <a href=\"/\">Home</a>\n * </li>\n * <b.Separator>/</b.Separator>\n * <li>\n * <a href=\"/docs\">Docs</a>\n * </li>\n * <b.Separator>/</b.Separator>\n * <li aria-current=\"page\">\n * Breadcrumb\n * </li>\n * </Breadcrumb>\n * </template>\n * ```\n */\nexport const Breadcrumb: TOC<Signature> = <template>\n <nav aria-label={{if @label @label \"Breadcrumb\"}} ...attributes>\n <ol>\n {{yield (hash Separator=(component Separator as=\"li\" decorative=true))}}\n </ol>\n </nav>\n</template>;\n\nexport default Breadcrumb;\n"],"names":["Breadcrumb","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Separator","templateOnly"],"mappings":";;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BC;MACYA,UAAgB,GAAAC,oBAAA,CAAaC,kBAAA,CAAA,6KAAA,EAM1C;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,IAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;;;"}
|
|
@@ -5,7 +5,7 @@ import { uniqueId } from '../utils.js';
|
|
|
5
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
6
6
|
import { setComponentTemplate } from '@ember/component';
|
|
7
7
|
import templateOnly from '@ember/component/template-only';
|
|
8
|
-
import { t as toggleWithFallback } from '../utils-
|
|
8
|
+
import { t as toggleWithFallback } from '../utils-BBQjrXDg.js';
|
|
9
9
|
|
|
10
10
|
setComponentTemplate(precompileTemplate("<div ...attributes>{{yield}}</div>", {
|
|
11
11
|
strictMode: true
|
|
@@ -14,22 +14,26 @@ const Label = setComponentTemplate(precompileTemplate("<label for={{@for}} ...at
|
|
|
14
14
|
strictMode: true
|
|
15
15
|
}), templateOnly());
|
|
16
16
|
|
|
17
|
-
const Checkbox = setComponentTemplate(precompileTemplate("
|
|
17
|
+
const Checkbox = setComponentTemplate(precompileTemplate("<input id={{@id}} type=\"checkbox\" role=\"switch\" checked={{@checked.current}} aria-checked={{@checked.current}} data-state={{if @checked.current \"on\" \"off\"}} {{on \"click\" (fn toggleWithFallback @checked.toggle @onChange)}} ...attributes />", {
|
|
18
18
|
strictMode: true,
|
|
19
19
|
scope: () => ({
|
|
20
|
-
cell,
|
|
21
20
|
on,
|
|
22
21
|
fn,
|
|
23
22
|
toggleWithFallback
|
|
24
23
|
})
|
|
25
24
|
}), templateOnly());
|
|
25
|
+
function defaultFalse(value) {
|
|
26
|
+
return value ?? false;
|
|
27
|
+
}
|
|
26
28
|
/**
|
|
27
29
|
* @public
|
|
28
30
|
*/
|
|
29
|
-
const Switch = setComponentTemplate(precompileTemplate("<div ...attributes data-prim-switch>\n {{
|
|
31
|
+
const Switch = setComponentTemplate(precompileTemplate("<div ...attributes data-prim-switch>\n {{#let (uniqueId) as |id|}}\n {{#let (cell (defaultFalse @checked)) as |checked|}}\n {{!-- @glint-nocheck --}}\n {{yield (hash isChecked=checked.current Control=(component Checkbox checked=checked id=id onChange=@onChange) Label=(component Label for=id))}}\n {{/let}}\n {{/let}}\n</div>", {
|
|
30
32
|
strictMode: true,
|
|
31
33
|
scope: () => ({
|
|
32
34
|
uniqueId,
|
|
35
|
+
cell,
|
|
36
|
+
defaultFalse,
|
|
33
37
|
hash,
|
|
34
38
|
Checkbox,
|
|
35
39
|
Label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sources":["../../src/components/-private/typed-elements.gts","../../src/components/switch.gts"],"sourcesContent":["import type { TOC } from \"@ember/component/template-only\";\n\nexport const Div: TOC<{ Element: HTMLDivElement; Blocks: { default: [] } }> = <template>\n <div ...attributes>{{yield}}</div>\n</template>;\n\nexport const Label: TOC<{\n Element: HTMLLabelElement;\n Args: { for: string };\n Blocks: { default: [] };\n}> = <template>\n <label for={{@for}} ...attributes>{{yield}}</label>\n</template>;\n","import { fn, hash } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\n\nimport { cell } from \"ember-resources\";\n\nimport { uniqueId } from \"../utils.ts\";\nimport { Label } from \"./-private/typed-elements.gts\";\nimport { toggleWithFallback } from \"./-private/utils.ts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type { WithBoundArgs } from \"@glint/template\";\n\nexport interface Signature {\n Element: HTMLInputElement;\n Args: {\n /**\n * The initial checked value of the Switch.\n * This value is reactive, so if the value that\n * `@checked` is set to updates, the state of the Switch will also update.\n */\n checked?: boolean;\n /**\n * Callback when the Switch state is toggled\n */\n onChange?: (checked: boolean, event: Event) => void;\n };\n Blocks: {\n default?: [\n {\n /**\n * The Switch Element.\n * It has a pre-wired `id` so that the relevant Label is\n * appropriately associated via the `for` property of the Label.\n *\n * ```gjs\n * import { Switch } from 'ember-primitives';\n *\n * <template>\n * <Switch as |s|>\n * <s.Control />\n * </Switch>\n * </template>\n * ```\n */\n Control: WithBoundArgs<typeof Checkbox, \"checked\" | \"id\" | \"onChange\">;\n /**\n * The Switch element requires a label, and this label already has\n * the association to the Control by setting the `for` attribute to the `id` of the Control\n *\n * ```gjs\n * import { Switch } from 'ember-
|
|
1
|
+
{"version":3,"file":"switch.js","sources":["../../src/components/-private/typed-elements.gts","../../src/components/switch.gts"],"sourcesContent":["import type { TOC } from \"@ember/component/template-only\";\n\nexport const Div: TOC<{ Element: HTMLDivElement; Blocks: { default: [] } }> = <template>\n <div ...attributes>{{yield}}</div>\n</template>;\n\nexport const Label: TOC<{\n Element: HTMLLabelElement;\n Args: { for: string };\n Blocks: { default: [] };\n}> = <template>\n <label for={{@for}} ...attributes>{{yield}}</label>\n</template>;\n","import { fn, hash } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\n\nimport { cell } from \"ember-resources\";\n\nimport { uniqueId } from \"../utils.ts\";\nimport { Label } from \"./-private/typed-elements.gts\";\nimport { toggleWithFallback } from \"./-private/utils.ts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type { WithBoundArgs } from \"@glint/template\";\n\nexport interface Signature {\n Element: HTMLInputElement;\n Args: {\n /**\n * The initial checked value of the Switch.\n * This value is reactive, so if the value that\n * `@checked` is set to updates, the state of the Switch will also update.\n */\n checked?: boolean;\n /**\n * Callback when the Switch state is toggled\n */\n onChange?: (checked: boolean, event: Event) => void;\n };\n Blocks: {\n default?: [\n {\n /**\n * The current state of the Switch.\n *\n * ```gjs\n * import { Switch } from 'ember-primitives/components/switch';\n *\n * <template>\n * <Switch as |s|>\n * {{s.isChecked}}\n * </Switch>\n * </template>\n * ```\n */\n isChecked: boolean;\n /**\n * The Switch Element.\n * It has a pre-wired `id` so that the relevant Label is\n * appropriately associated via the `for` property of the Label.\n *\n * ```gjs\n * import { Switch } from 'ember-primitives/components/switch';\n *\n * <template>\n * <Switch as |s|>\n * <s.Control />\n * </Switch>\n * </template>\n * ```\n */\n Control: WithBoundArgs<typeof Checkbox, \"checked\" | \"id\" | \"onChange\">;\n /**\n * The Switch element requires a label, and this label already has\n * the association to the Control by setting the `for` attribute to the `id` of the Control\n *\n * ```gjs\n * import { Switch } from 'ember-primitive/components/switchs';\n *\n * <template>\n * <Switch as |s|>\n * <s.Label />\n * </Switch>\n * </template>\n * ```\n */\n Label: WithBoundArgs<typeof Label, \"for\">;\n },\n ];\n };\n}\n\ninterface ControlSignature {\n Element: HTMLInputElement;\n Args: { id: string; checked?: ReturnType<typeof cell<boolean>>; onChange: () => void };\n}\n\nconst Checkbox: TOC<ControlSignature> = <template>\n <input\n id={{@id}}\n type=\"checkbox\"\n role=\"switch\"\n checked={{@checked.current}}\n aria-checked={{@checked.current}}\n data-state={{if @checked.current \"on\" \"off\"}}\n {{on \"click\" (fn toggleWithFallback @checked.toggle @onChange)}}\n ...attributes\n />\n</template>;\n\nfunction defaultFalse(value: unknown) {\n return value ?? false;\n}\n\n/**\n * @public\n */\nexport const Switch: TOC<Signature> = <template>\n <div ...attributes data-prim-switch>\n {{#let (uniqueId) as |id|}}\n {{#let (cell (defaultFalse @checked)) as |checked|}}\n {{! @glint-nocheck }}\n {{yield\n (hash\n isChecked=checked.current\n Control=(component Checkbox checked=checked id=id onChange=@onChange)\n Label=(component Label for=id)\n )\n }}\n {{/let}}\n {{/let}}\n </div>\n</template>;\n\nexport default Switch;\n"],"names":["precompileTemplate","strictMode","templateOnly","Label","Checkbox","setComponentTemplate","scope","on","fn","toggleWithFallback","defaultFalse","value","Switch","uniqueId","cell","hash"],"mappings":";;;;;;;;;qBAE8EA,kBAAA,CAAA,oCAAA,EAE9E;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;AAEH,MAAMC,6BAIRH,kBAAA,CAAA,qDAAA,EAEL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;;ACwEV,MAAME,QAAc,GAAAC,oBAAA,CAAoBL,kBAAA,CAAA,0PAAA,EAWxC;EAAAC,UAAA,EAAA,IAAA;AAAAK,EAAAA,KAAA,EAAAA,OAAA;IAAAC,EAAA;IAAAC,EAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAP,YAAA,EAAA,CAAA;AAEV,SAASQ,YAAAA,CAAaC,KAAc,EAAA;EAClC,OAAOA,KAAA,IAAS,KAAA;AAClB;AAEA;;AAEC;MACYC,MAAY,GAAAP,oBAAA,CAAaL,kBAAA,CAAA,yVAAA,EAetC;EAAAC,UAAA,EAAA,IAAA;AAAAK,EAAAA,KAAA,EAAAA,OAAA;IAAAO,QAAA;IAAAC,IAAA;IAAAJ,YAAA;IAAAK,IAAA;IAAAX,QAAA;AAAAD,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAD,YAAA,EAAA;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fn } from '@ember/helper';
|
|
2
2
|
import { on } from '@ember/modifier';
|
|
3
3
|
import { cell } from 'ember-resources';
|
|
4
|
-
import { t as toggleWithFallback } from '../utils-
|
|
4
|
+
import { t as toggleWithFallback } from '../utils-BBQjrXDg.js';
|
|
5
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
6
6
|
import { setComponentTemplate } from '@ember/component';
|
|
7
7
|
import templateOnly from '@ember/component/template-only';
|
|
@@ -6,8 +6,8 @@ function toggleWithFallback(uncontrolledToggle, controlledToggle, ...args) {
|
|
|
6
6
|
if (controlledToggle) {
|
|
7
7
|
return controlledToggle(...args);
|
|
8
8
|
}
|
|
9
|
-
uncontrolledToggle(...args);
|
|
9
|
+
uncontrolledToggle?.(...args);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { toggleWithFallback as t };
|
|
13
|
-
//# sourceMappingURL=utils-
|
|
13
|
+
//# sourceMappingURL=utils-BBQjrXDg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-BBQjrXDg.js","sources":["../src/components/-private/utils.ts"],"sourcesContent":["/**\n * If the user provides an onChange or similar function, use that,\n * otherwise fallback to the uncontrolled toggle\n */\nexport function toggleWithFallback(\n uncontrolledToggle: undefined | ((...args: any[]) => void) | (() => void),\n controlledToggle?: (...args: any[]) => void,\n ...args: unknown[]\n) {\n if (controlledToggle) {\n return controlledToggle(...args);\n }\n\n uncontrolledToggle?.(...args);\n}\n"],"names":["toggleWithFallback","uncontrolledToggle","controlledToggle","args"],"mappings":"AAAA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,kBAAyE,EACzEC,gBAA2C,EAC3C,GAAGC,IAAe,EAClB;AACA,EAAA,IAAID,gBAAgB,EAAE;AACpB,IAAA,OAAOA,gBAAgB,CAAC,GAAGC,IAAI,CAAC;AAClC,EAAA;EAEAF,kBAAkB,GAAG,GAAGE,IAAI,CAAC;AAC/B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "Making apps easier to build",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"should-handle-link": "^1.2.2",
|
|
29
29
|
"tabster": "^8.7.0",
|
|
30
30
|
"tracked-built-ins": "^4.1.0",
|
|
31
|
-
"tracked-toolbox": "^2.
|
|
32
|
-
"which-heading-do-i-need": "0.2.
|
|
31
|
+
"tracked-toolbox": "^2.2.0",
|
|
32
|
+
"which-heading-do-i-need": "0.2.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@arethetypeswrong/cli": "^0.18.0",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@embroider/addon-dev": "^8.2.0",
|
|
49
49
|
"@glimmer/component": "^2.0.0",
|
|
50
50
|
"@glimmer/tracking": "^1.1.2",
|
|
51
|
-
"@glint/ember-tsc": "^1.0.
|
|
51
|
+
"@glint/ember-tsc": "^1.0.9",
|
|
52
52
|
"@glint/template": "^1.7.3",
|
|
53
|
-
"@glint/tsserver-plugin": "^2.0.
|
|
53
|
+
"@glint/tsserver-plugin": "^2.0.9",
|
|
54
54
|
"@nullvoxpopuli/eslint-configs": "^5.5.0",
|
|
55
55
|
"@rollup/plugin-babel": "^6.1.0",
|
|
56
56
|
"@tsconfig/ember": "^3.0.12",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"concurrently": "^9.2.1",
|
|
59
59
|
"ember-modifier": "^4.2.2",
|
|
60
60
|
"ember-resources": "^7.0.7",
|
|
61
|
-
"ember-source": "^6.
|
|
61
|
+
"ember-source": "^6.10.0",
|
|
62
62
|
"ember-template-lint": "^7.9.3",
|
|
63
63
|
"eslint": "^9.39.2",
|
|
64
64
|
"execa": "^9.6.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"prettier": "^3.7.4",
|
|
67
67
|
"prettier-plugin-ember-template-tag": "^2.1.2",
|
|
68
68
|
"publint": "^0.3.16",
|
|
69
|
-
"rollup": "^4.
|
|
69
|
+
"rollup": "^4.55.1",
|
|
70
70
|
"rollup-plugin-copy": "^3.5.0",
|
|
71
71
|
"typescript": "^5.9.3"
|
|
72
72
|
},
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* otherwise fallback to the uncontrolled toggle
|
|
4
4
|
*/
|
|
5
5
|
export function toggleWithFallback(
|
|
6
|
-
uncontrolledToggle: (...args:
|
|
7
|
-
|
|
6
|
+
uncontrolledToggle: undefined | ((...args: any[]) => void) | (() => void),
|
|
8
7
|
controlledToggle?: (...args: any[]) => void,
|
|
9
8
|
...args: unknown[]
|
|
10
9
|
) {
|
|
@@ -12,5 +11,5 @@ export function toggleWithFallback(
|
|
|
12
11
|
return controlledToggle(...args);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
uncontrolledToggle(...args);
|
|
14
|
+
uncontrolledToggle?.(...args);
|
|
16
15
|
}
|
|
@@ -20,7 +20,7 @@ export interface Signature {
|
|
|
20
20
|
/**
|
|
21
21
|
* A separator component to place between breadcrumb items.
|
|
22
22
|
* Typically renders as "/" or ">" and is decorative (aria-hidden="true").
|
|
23
|
-
* Pre-configured to render as an
|
|
23
|
+
* Pre-configured to render as an `<li>` element for proper HTML structure.
|
|
24
24
|
*/
|
|
25
25
|
Separator: WithBoundArgs<typeof Separator, "as" | "decorative">;
|
|
26
26
|
},
|
|
@@ -27,13 +27,27 @@ export interface Signature {
|
|
|
27
27
|
Blocks: {
|
|
28
28
|
default?: [
|
|
29
29
|
{
|
|
30
|
+
/**
|
|
31
|
+
* The current state of the Switch.
|
|
32
|
+
*
|
|
33
|
+
* ```gjs
|
|
34
|
+
* import { Switch } from 'ember-primitives/components/switch';
|
|
35
|
+
*
|
|
36
|
+
* <template>
|
|
37
|
+
* <Switch as |s|>
|
|
38
|
+
* {{s.isChecked}}
|
|
39
|
+
* </Switch>
|
|
40
|
+
* </template>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
isChecked: boolean;
|
|
30
44
|
/**
|
|
31
45
|
* The Switch Element.
|
|
32
46
|
* It has a pre-wired `id` so that the relevant Label is
|
|
33
47
|
* appropriately associated via the `for` property of the Label.
|
|
34
48
|
*
|
|
35
49
|
* ```gjs
|
|
36
|
-
* import { Switch } from 'ember-primitives';
|
|
50
|
+
* import { Switch } from 'ember-primitives/components/switch';
|
|
37
51
|
*
|
|
38
52
|
* <template>
|
|
39
53
|
* <Switch as |s|>
|
|
@@ -48,7 +62,7 @@ export interface Signature {
|
|
|
48
62
|
* the association to the Control by setting the `for` attribute to the `id` of the Control
|
|
49
63
|
*
|
|
50
64
|
* ```gjs
|
|
51
|
-
* import { Switch } from 'ember-
|
|
65
|
+
* import { Switch } from 'ember-primitive/components/switchs';
|
|
52
66
|
*
|
|
53
67
|
* <template>
|
|
54
68
|
* <Switch as |s|>
|
|
@@ -65,37 +79,42 @@ export interface Signature {
|
|
|
65
79
|
|
|
66
80
|
interface ControlSignature {
|
|
67
81
|
Element: HTMLInputElement;
|
|
68
|
-
Args: { id: string; checked?: boolean
|
|
82
|
+
Args: { id: string; checked?: ReturnType<typeof cell<boolean>>; onChange: () => void };
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
const Checkbox: TOC<ControlSignature> = <template>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/>
|
|
83
|
-
{{/let}}
|
|
86
|
+
<input
|
|
87
|
+
id={{@id}}
|
|
88
|
+
type="checkbox"
|
|
89
|
+
role="switch"
|
|
90
|
+
checked={{@checked.current}}
|
|
91
|
+
aria-checked={{@checked.current}}
|
|
92
|
+
data-state={{if @checked.current "on" "off"}}
|
|
93
|
+
{{on "click" (fn toggleWithFallback @checked.toggle @onChange)}}
|
|
94
|
+
...attributes
|
|
95
|
+
/>
|
|
84
96
|
</template>;
|
|
85
97
|
|
|
98
|
+
function defaultFalse(value: unknown) {
|
|
99
|
+
return value ?? false;
|
|
100
|
+
}
|
|
101
|
+
|
|
86
102
|
/**
|
|
87
103
|
* @public
|
|
88
104
|
*/
|
|
89
105
|
export const Switch: TOC<Signature> = <template>
|
|
90
106
|
<div ...attributes data-prim-switch>
|
|
91
|
-
{{! @glint-nocheck }}
|
|
92
107
|
{{#let (uniqueId) as |id|}}
|
|
93
|
-
{{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
{{#let (cell (defaultFalse @checked)) as |checked|}}
|
|
109
|
+
{{! @glint-nocheck }}
|
|
110
|
+
{{yield
|
|
111
|
+
(hash
|
|
112
|
+
isChecked=checked.current
|
|
113
|
+
Control=(component Checkbox checked=checked id=id onChange=@onChange)
|
|
114
|
+
Label=(component Label for=id)
|
|
115
|
+
)
|
|
116
|
+
}}
|
|
117
|
+
{{/let}}
|
|
99
118
|
{{/let}}
|
|
100
119
|
</div>
|
|
101
120
|
</template>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-D0v9WKmV.js","sources":["../src/components/-private/utils.ts"],"sourcesContent":["/**\n * If the user provides an onChange or similar function, use that,\n * otherwise fallback to the uncontrolled toggle\n */\nexport function toggleWithFallback(\n uncontrolledToggle: (...args: unknown[]) => void,\n\n controlledToggle?: (...args: any[]) => void,\n ...args: unknown[]\n) {\n if (controlledToggle) {\n return controlledToggle(...args);\n }\n\n uncontrolledToggle(...args);\n}\n"],"names":["toggleWithFallback","uncontrolledToggle","controlledToggle","args"],"mappings":"AAAA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,kBAAgD,EAEhDC,gBAA2C,EAC3C,GAAGC,IAAe,EAClB;AACA,EAAA,IAAID,gBAAgB,EAAE;AACpB,IAAA,OAAOA,gBAAgB,CAAC,GAAGC,IAAI,CAAC;AAClC,EAAA;EAEAF,kBAAkB,CAAC,GAAGE,IAAI,CAAC;AAC7B;;;;"}
|