ember-primitives 0.48.1 → 0.49.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/README.md +9 -2
- package/declarations/components/menu.d.ts +26 -10
- package/declarations/components/menu.d.ts.map +1 -1
- package/declarations/components/portal.d.ts.map +1 -1
- package/declarations/tabster.d.ts.map +1 -1
- package/declarations/utils.d.ts.map +1 -1
- package/declarations/viewport/in-viewport.d.ts +70 -0
- package/declarations/viewport/in-viewport.d.ts.map +1 -0
- package/declarations/viewport/viewport.d.ts +59 -0
- package/declarations/viewport/viewport.d.ts.map +1 -0
- package/declarations/viewport.d.ts +3 -0
- package/declarations/viewport.d.ts.map +1 -0
- package/dist/-private.js +0 -1
- package/dist/-private.js.map +1 -1
- package/dist/color-scheme.js +0 -1
- package/dist/color-scheme.js.map +1 -1
- package/dist/{component-Bs3N-G9z.js → component-BXy_iafw.js} +2 -3
- package/dist/component-BXy_iafw.js.map +1 -0
- package/dist/components/accordion.js +5 -6
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/avatar.js +3 -4
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/dialog.js +2 -3
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/external-link.js +1 -2
- package/dist/components/external-link.js.map +1 -1
- package/dist/components/form.js +1 -2
- package/dist/components/form.js.map +1 -1
- package/dist/components/heading.js +1 -2
- package/dist/components/heading.js.map +1 -1
- package/dist/components/keys.js +2 -3
- package/dist/components/keys.js.map +1 -1
- package/dist/components/layout/hero.js +1 -1
- package/dist/components/layout/sticky-footer.js +1 -1
- package/dist/components/link.js +1 -2
- package/dist/components/link.js.map +1 -1
- package/dist/components/menu.js +6 -9
- package/dist/components/menu.js.map +1 -1
- package/dist/components/one-time-password.js +1 -2
- package/dist/components/popover.js +3 -4
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal-targets.js +2 -3
- package/dist/components/portal-targets.js.map +1 -1
- package/dist/components/portal.js +3 -7
- package/dist/components/portal.js.map +1 -1
- package/dist/components/progress.js +2 -3
- package/dist/components/progress.js.map +1 -1
- package/dist/components/rating.js +1 -2
- package/dist/components/scroller.js +1 -2
- package/dist/components/scroller.js.map +1 -1
- package/dist/components/shadowed.js +2 -3
- package/dist/components/shadowed.js.map +1 -1
- package/dist/components/switch.js +5 -6
- package/dist/components/switch.js.map +1 -1
- package/dist/components/tabs.js +6 -7
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/toggle-group.js +3 -4
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.js +2 -3
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/visually-hidden.js +1 -2
- package/dist/components/visually-hidden.js.map +1 -1
- package/dist/components/zoetrope.js +1 -2
- package/dist/dom-context.js +2 -3
- package/dist/dom-context.js.map +1 -1
- package/dist/floating-ui.js +1 -2
- package/dist/head.js +1 -2
- package/dist/head.js.map +1 -1
- package/dist/helpers/body-class.js +0 -1
- package/dist/helpers/body-class.js.map +1 -1
- package/dist/helpers/link.js +0 -1
- package/dist/helpers/link.js.map +1 -1
- package/dist/helpers/service.js +0 -1
- package/dist/helpers/service.js.map +1 -1
- package/dist/helpers.js +0 -1
- package/dist/helpers.js.map +1 -1
- package/dist/iframe.js +0 -1
- package/dist/iframe.js.map +1 -1
- package/dist/{index-DKE67I8L.js → index-gRO4Cvlf.js} +2 -2
- package/dist/index-gRO4Cvlf.js.map +1 -0
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/load.js +0 -1
- package/dist/load.js.map +1 -1
- package/dist/narrowing.js +0 -1
- package/dist/narrowing.js.map +1 -1
- package/dist/on-resize.js +0 -1
- package/dist/on-resize.js.map +1 -1
- package/dist/{otp-C6hCCXKx.js → otp-7rz1PWP0.js} +6 -7
- package/dist/otp-7rz1PWP0.js.map +1 -0
- package/dist/proper-links.js +0 -1
- package/dist/proper-links.js.map +1 -1
- package/dist/qp.js +0 -1
- package/dist/qp.js.map +1 -1
- package/dist/{rating-D052JWRa.js → rating-CjBVsX6q.js} +5 -6
- package/dist/rating-CjBVsX6q.js.map +1 -0
- package/dist/resize-observer.js +0 -1
- package/dist/resize-observer.js.map +1 -1
- package/dist/service.js +0 -1
- package/dist/service.js.map +1 -1
- package/dist/store.js +0 -1
- package/dist/store.js.map +1 -1
- package/dist/styles.css.js +0 -1
- package/dist/tabster.js +0 -1
- package/dist/tabster.js.map +1 -1
- package/dist/test-support.js +0 -1
- package/dist/test-support.js.map +1 -1
- package/dist/{utils-C5796IKA.js → utils-D0v9WKmV.js} +1 -2
- package/dist/utils-D0v9WKmV.js.map +1 -0
- package/dist/utils.js +4 -1
- package/dist/utils.js.map +1 -1
- package/dist/viewport/in-viewport.js +82 -0
- package/dist/viewport/in-viewport.js.map +1 -0
- package/dist/viewport/viewport.js +92 -0
- package/dist/viewport/viewport.js.map +1 -0
- package/dist/viewport.js +3 -0
- package/dist/viewport.js.map +1 -0
- package/package.json +20 -20
- package/dist/component-Bs3N-G9z.js.map +0 -1
- package/dist/index-DKE67I8L.js.map +0 -1
- package/dist/otp-C6hCCXKx.js.map +0 -1
- package/dist/rating-D052JWRa.js.map +0 -1
- package/dist/utils-C5796IKA.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { fn, hash } from '@ember/helper';
|
|
3
2
|
import { on } from '@ember/modifier';
|
|
4
3
|
import { cell } from 'ember-resources';
|
|
@@ -6,16 +5,16 @@ import { uniqueId } from '../utils.js';
|
|
|
6
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
6
|
import { setComponentTemplate } from '@ember/component';
|
|
8
7
|
import templateOnly from '@ember/component/template-only';
|
|
9
|
-
import { t as toggleWithFallback } from '../utils-
|
|
8
|
+
import { t as toggleWithFallback } from '../utils-D0v9WKmV.js';
|
|
10
9
|
|
|
11
|
-
setComponentTemplate(precompileTemplate("
|
|
10
|
+
setComponentTemplate(precompileTemplate("<div ...attributes>{{yield}}</div>", {
|
|
12
11
|
strictMode: true
|
|
13
12
|
}), templateOnly());
|
|
14
|
-
const Label = setComponentTemplate(precompileTemplate("
|
|
13
|
+
const Label = setComponentTemplate(precompileTemplate("<label for={{@for}} ...attributes>{{yield}}</label>", {
|
|
15
14
|
strictMode: true
|
|
16
15
|
}), templateOnly());
|
|
17
16
|
|
|
18
|
-
const Checkbox = setComponentTemplate(precompileTemplate("
|
|
17
|
+
const Checkbox = setComponentTemplate(precompileTemplate("{{#let (cell @checked) as |checked|}}\n <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 />\n{{/let}}", {
|
|
19
18
|
strictMode: true,
|
|
20
19
|
scope: () => ({
|
|
21
20
|
cell,
|
|
@@ -27,7 +26,7 @@ const Checkbox = setComponentTemplate(precompileTemplate("\n {{#let (cell @chec
|
|
|
27
26
|
/**
|
|
28
27
|
* @public
|
|
29
28
|
*/
|
|
30
|
-
const Switch = setComponentTemplate(precompileTemplate("
|
|
29
|
+
const Switch = setComponentTemplate(precompileTemplate("<div ...attributes data-prim-switch>\n {{!-- @glint-nocheck --}}\n {{#let (uniqueId) as |id|}}\n {{yield (hash Control=(component Checkbox checked=@checked id=id onChange=@onChange) Label=(component Label for=id))}}\n {{/let}}\n</div>", {
|
|
31
30
|
strictMode: true,
|
|
32
31
|
scope: () => ({
|
|
33
32
|
uniqueId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
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-primitives';\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?: boolean; onChange: () => void };\n}\n\nconst Checkbox: TOC<ControlSignature> = <template>\n {{#let (cell @checked) as |checked|}}\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 {{/let}}\n</template>;\n\n/**\n * @public\n */\nexport const Switch: TOC<Signature> = <template>\n <div ...attributes data-prim-switch>\n {{! @glint-nocheck }}\n {{#let (uniqueId) as |id|}}\n {{yield\n (hash\n Control=(component Checkbox checked=@checked id=id onChange=@onChange)\n Label=(component Label for=id)\n )\n }}\n {{/let}}\n </div>\n</template>;\n\nexport default Switch;\n"],"names":["precompileTemplate","strictMode","templateOnly","Label","Checkbox","setComponentTemplate","scope","cell","on","fn","toggleWithFallback","Switch","uniqueId","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;;AC0DV,MAAME,QAAc,GAAAC,oBAAA,CAAoBL,kBAAA,CAAA,ySAAA,EAaxC;EAAAC,UAAA,EAAA,IAAA;AAAAK,EAAAA,KAAA,EAAAA,OAAA;IAAAC,IAAA;IAAAC,EAAA;IAAAC,EAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAR,YAAA,EAAA,CAAA;AAEV;;AAEC;MACYS,MAAY,GAAAN,oBAAA,CAAaL,kBAAA,CAAA,kPAAA,EAYtC;EAAAC,UAAA,EAAA,IAAA;AAAAK,EAAAA,KAAA,EAAAA,OAAA;IAAAM,QAAA;IAAAC,IAAA;IAAAT,QAAA;AAAAD,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAD,YAAA,EAAA;;;;"}
|
package/dist/components/tabs.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { tracked } from '@glimmer/tracking';
|
|
4
3
|
import { isDestroyed, isDestroying } from '@ember/destroyable';
|
|
@@ -31,17 +30,17 @@ const TABSTER_CONFIG = getTabsterAttribute({
|
|
|
31
30
|
},
|
|
32
31
|
deloser: {}
|
|
33
32
|
}, true);
|
|
34
|
-
const TabLink = setComponentTemplate(precompileTemplate("
|
|
33
|
+
const TabLink = setComponentTemplate(precompileTemplate("<a href=\"##missing##\" ...attributes role=\"tab\" aria-controls={{@panelId}} id={{@id}}>\n {{yield}}\n</a>", {
|
|
35
34
|
strictMode: true
|
|
36
35
|
}), templateOnly());
|
|
37
|
-
const TabButton = setComponentTemplate(precompileTemplate("
|
|
36
|
+
const TabButton = setComponentTemplate(precompileTemplate("<button ...attributes role=\"tab\" type=\"button\" aria-controls={{@panelId}} aria-selected={{String (@state.isActive @id @value)}} id={{@id}} {{on \"click\" @handleClick}} {{!-- The Types for modifier are wrong --}} {{!-- @glint-expect-error--}} {{(if @state.isAutomatic (modifier on \"focus\" @handleClick))}}>\n {{yield}}\n</button>", {
|
|
38
37
|
strictMode: true,
|
|
39
38
|
scope: () => ({
|
|
40
39
|
String,
|
|
41
40
|
on
|
|
42
41
|
})
|
|
43
42
|
}), templateOnly());
|
|
44
|
-
const TabContent = setComponentTemplate(precompileTemplate("
|
|
43
|
+
const TabContent = setComponentTemplate(precompileTemplate("<Portal @to=\"#{{@state.tabpanelId}}\" @append={{true}}>\n {{#if (@state.isActive @tabId)}}\n <div ...attributes role=\"tabpanel\" aria-labelledby={{@tabId}} id={{@id}}>\n {{yield}}\n </div>\n {{/if}}\n</Portal>", {
|
|
45
44
|
strictMode: true,
|
|
46
45
|
scope: () => ({
|
|
47
46
|
Portal
|
|
@@ -67,7 +66,7 @@ class TabContainer extends Component {
|
|
|
67
66
|
return this.args.label ?? this.tabId;
|
|
68
67
|
}
|
|
69
68
|
static {
|
|
70
|
-
setComponentTemplate(precompileTemplate("
|
|
69
|
+
setComponentTemplate(precompileTemplate("{{#if @label}}\n <TabButton @state={{@state}} @id={{this.tabId}} @value={{@value}} @panelId={{this.panelId}} @handleClick={{fn @state.handleChange this.tabId @value}}>\n {{#if (isString @label)}}\n {{@label}}\n {{else}}\n <@label />\n {{/if}}\n </TabButton>\n\n <TabContent @state={{@state}} @id={{this.panelId}} @tabId={{this.tabId}}>\n {{#if @content}}\n {{#if (isString @content)}}\n {{@content}}\n {{else}}\n <@content />\n {{/if}}\n {{else}}\n {{yield}}\n {{/if}}\n </TabContent>\n{{else}}\n {{yield (makeTab (component TabButton state=@state value=@value id=this.tabId panelId=this.panelId handleClick=(fn @state.handleChange this.tabId @value)) (component TabLink state=@state id=this.tabId panelId=this.panelId)) (component TabContent state=@state id=this.panelId tabId=this.tabId)}}\n{{/if}}", {
|
|
71
70
|
strictMode: true,
|
|
72
71
|
scope: () => ({
|
|
73
72
|
TabButton,
|
|
@@ -80,7 +79,7 @@ class TabContainer extends Component {
|
|
|
80
79
|
}), this);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
const Label = setComponentTemplate(precompileTemplate("
|
|
82
|
+
const Label = setComponentTemplate(precompileTemplate("<Portal @to=\"#{{@state.labelId}}\">\n {{yield}}\n</Portal>", {
|
|
84
83
|
strictMode: true,
|
|
85
84
|
scope: () => ({
|
|
86
85
|
Portal
|
|
@@ -201,7 +200,7 @@ class Tabs extends Component {
|
|
|
201
200
|
this.state = new TabState(args);
|
|
202
201
|
}
|
|
203
202
|
static {
|
|
204
|
-
setComponentTemplate(precompileTemplate("
|
|
203
|
+
setComponentTemplate(precompileTemplate("<div class=\"ember-primitives__tabs\" ...attributes data-active={{this.state.activeLabel}}>\n {{!-- This element will be portaled in to and replaced if tabs.Label is invoked --}}\n <div class=\"ember-primitives__tabs__label\" id={{this.state.labelId}}>\n {{#if (isString @label)}}\n {{@label}}\n {{else}}\n <@label />\n {{/if}}\n </div>\n <div class=\"ember-primitives__tabs__tablist\" role=\"tablist\" aria-labelledby={{this.state.labelId}} data-tabster={{TABSTER_CONFIG}}>\n {{yield (makeAPI (component TabContainer state=this.state) (component Label state=this.state))}}\n </div>\n {{!--\n Tab's contents are portaled in to this element\n --}}\n <div class=\"ember-primitives__tabs__tabpanel\" id={{this.state.tabpanelId}}></div>\n</div>", {
|
|
205
204
|
strictMode: true,
|
|
206
205
|
scope: () => ({
|
|
207
206
|
isString,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"tabs.js","sources":["../../src/components/tabs.gts"],"sourcesContent":["/**\n * References:\n * - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role\n * - https://www.w3.org/WAI/ARIA/apg/patterns/tabs/\n *\n *\n * Keyboard behaviors (optionally) provided by tabster\n */\n\nimport Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { isDestroyed, isDestroying } from \"@ember/destroyable\";\nimport { fn } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\nimport { next } from \"@ember/runloop\";\n\nimport { getTabsterAttribute, MoverDirections } from \"tabster\";\n\nimport { uniqueId } from \"../utils.ts\";\nimport Portal from \"./portal.gts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type Owner from \"@ember/owner\";\nimport type { ComponentLike, WithBoundArgs } from \"@glint/template\";\n\nconst UNSET = Symbol.for(\"ember-primitives:tabs:unset\");\n\nconst TABSTER_CONFIG = getTabsterAttribute(\n {\n mover: {\n direction: MoverDirections.Both,\n cyclic: true,\n memorizeCurrent: true,\n },\n deloser: {},\n },\n true,\n);\n\nconst TabLink: TOC<{\n Element: HTMLAnchorElement;\n Args: {\n /**\n * @internal\n * for linking of aria\n */\n id: string;\n /**\n * @internal\n * for linking of aria\n */\n panelId: string;\n };\n Blocks: { default: [] };\n}> = <template>\n <a href=\"##missing##\" ...attributes role=\"tab\" aria-controls={{@panelId}} id={{@id}}>\n {{yield}}\n </a>\n</template>;\n\nexport type ButtonType = ComponentLike<ButtonSignature>;\nexport interface ButtonSignature {\n Element: HTMLButtonElement;\n Blocks: {\n default: [];\n };\n}\n\nconst TabButton: TOC<{\n Args: {\n /**\n * @internal\n * for linking of aria\n */\n id: string;\n /**\n * @internal\n * for linking of aria\n */\n panelId: string;\n\n /**\n * @internal\n * for managing state\n */\n handleClick: () => void;\n\n /**\n * @internal\n * for managing state\n */\n value: string | undefined;\n\n /**\n * @internal\n */\n state: TabState;\n };\n Blocks: {\n default: [];\n };\n}> = <template>\n <button\n ...attributes\n role=\"tab\"\n type=\"button\"\n aria-controls={{@panelId}}\n aria-selected={{String (@state.isActive @id @value)}}\n id={{@id}}\n {{on \"click\" @handleClick}}\n {{! The Types for modifier are wrong }}\n {{! @glint-expect-error}}\n {{(if @state.isAutomatic (modifier on \"focus\" @handleClick))}}\n >\n {{yield}}\n </button>\n</template>;\n\nexport type ContentType = ComponentLike<ContentSignature>;\nexport interface ContentSignature {\n /**\n * the [role=tabpanel] element\n */\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nconst TabContent: TOC<{\n Element: HTMLDivElement;\n Args: {\n /**\n * @internal\n * for linking of aria\n */\n id: string;\n /**\n * @internal\n * for linking of aria\n */\n tabId: string;\n /**\n * @internal\n */\n state: TabState;\n };\n Blocks: {\n default: [];\n };\n}> = <template>\n <Portal @to=\"#{{@state.tabpanelId}}\" @append={{true}}>\n {{#if (@state.isActive @tabId)}}\n <div ...attributes role=\"tabpanel\" aria-labelledby={{@tabId}} id={{@id}}>\n {{yield}}\n </div>\n {{/if}}\n </Portal>\n</template>;\n\nfunction isString(x: unknown): x is string {\n return typeof x === \"string\";\n}\n\nfunction makeTab(tabButton: any, tabLink: any): any {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n tabButton.Link = tabLink;\n\n return tabButton;\n}\n\nexport type ContainerType = ComponentLike<ContainerSignature>;\nexport type ContainerSignature =\n | {\n Blocks: {\n default: [];\n };\n }\n | {\n Args: {\n label: string | ComponentLike;\n content: string | ComponentLike;\n };\n }\n | {\n Args: {\n label: string | ComponentLike;\n };\n Blocks: {\n /**\n * The content for the tab\n */\n default: [];\n };\n };\n\nclass TabContainer extends Component<{\n Args: {\n /**\n * @internal\n */\n state: TabState;\n\n /**\n * When opting for a \"controlled component\",\n * the value will be needed to make sense of the selected tab.\n *\n * The default value used for communication within the Tabs component (and eventually emitted via the @onChange argument) is a unique random id.\n * So while that could still be used for controlling the tabs component, it may be more easy to grok with user-managed values.\n */\n value?: string;\n\n /**\n * optional user-passable label\n */\n label?: string | ComponentLike;\n\n /**\n * optional user-passable content.\n */\n content?: string | ComponentLike;\n };\n Blocks: {\n default: [\n Label: WithBoundArgs<typeof TabButton, \"state\" | \"id\" | \"panelId\" | \"handleClick\" | \"value\">,\n Content: WithBoundArgs<typeof TabContent, \"state\" | \"id\" | \"tabId\">,\n ];\n };\n}> {\n id = `ember-primitives__tab-${uniqueId()}`;\n\n get tabId() {\n return `${this.id}__tab`;\n }\n\n get panelId() {\n return `${this.id}__panel`;\n }\n\n get label() {\n return this.args.label ?? this.tabId;\n }\n\n <template>\n {{#if @label}}\n <TabButton\n @state={{@state}}\n @id={{this.tabId}}\n @value={{@value}}\n @panelId={{this.panelId}}\n @handleClick={{fn @state.handleChange this.tabId @value}}\n >\n {{#if (isString @label)}}\n {{@label}}\n {{else}}\n <@label />\n {{/if}}\n </TabButton>\n\n <TabContent @state={{@state}} @id={{this.panelId}} @tabId={{this.tabId}}>\n {{#if @content}}\n {{#if (isString @content)}}\n {{@content}}\n {{else}}\n <@content />\n {{/if}}\n {{else}}\n {{yield}}\n {{/if}}\n </TabContent>\n {{else}}\n {{yield\n (makeTab\n (component\n TabButton\n state=@state\n value=@value\n id=this.tabId\n panelId=this.panelId\n handleClick=(fn @state.handleChange this.tabId @value)\n )\n (component TabLink state=@state id=this.tabId panelId=this.panelId)\n )\n (component TabContent state=@state id=this.panelId tabId=this.tabId)\n }}\n {{/if}}\n </template>\n}\n\nconst Label: TOC<{\n /**\n * The label wiring (id, aria, etc) are handled for you.\n * If you'd like to use a heading element (h3, etc), place that in the block content\n * when invoking this Label component.\n */\n Element: null;\n Args: {\n /**\n * @internal\n */\n state: TabState;\n };\n Blocks: { default: [] };\n}> = <template>\n <Portal @to=\"#{{@state.labelId}}\">\n {{yield}}\n </Portal>\n</template>;\n\nexport interface Signature {\n /**\n * The wrapping element for the overall Tabs component.\n * This should be used for styling the layout of the tabs.\n */\n Element: HTMLDivElement;\n Args: {\n /**\n * Sets the active tab.\n * If not passed, the first tab will be selected\n */\n activeTab?: string;\n\n /**\n * Optional label for the overall TabList\n */\n label?: string | ComponentLike;\n\n /**\n * When the tab changes, this function will be called.\n * The function receives both the newly selected tab as well as the previous tab.\n *\n * However, if the tabs are not configured with names, these values will be null.\n */\n onChange?: (selectedTab: string, previousTab: string | null) => void;\n\n /**\n * When activationMode is set to \"automatic\", tabs are activated when receiving focus. When set to \"manual\", tabs are activated when clicked (or when \"enter\" is pressed via the keyboard).\n */\n activationMode?: \"automatic\" | \"manual\";\n };\n Blocks: {\n default: [\n Tab: WithBoundArgs<typeof TabContainer, \"state\"> & {\n Label: WithBoundArgs<typeof Label, \"state\">;\n },\n ];\n };\n}\n\n/**\n * We're doing old skool hax with this, so we don't need to care about what the types think, really\n */\nfunction makeAPI(tabContainer: any, labelComponent: any): any {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n tabContainer.Label = labelComponent;\n\n return tabContainer;\n}\n\nimport { buildWaiter } from \"@ember/test-waiters\";\n\nconst stateWaiter = buildWaiter(\"ember-primitives:tabs\");\n\n/**\n * State bucket passed around to all the sub-components.\n *\n * Sort of a \"Context\", but with a bit of prop-drilling (which is more efficient than dom-context)\n */\nclass TabState {\n declare args: {\n activeTab?: string;\n activationMode?: \"automatic\" | \"manual\";\n onChange?: (selected: string, previous: string | null) => void;\n };\n\n @tracked _active: string | null = null;\n\n @tracked _label: string | undefined;\n\n #first: string | null = null;\n id: string;\n labelId: string;\n tabpanelId: string;\n #token: unknown;\n\n constructor(args: { activeTab?: string; onChange?: () => void }) {\n this.args = args;\n\n this.id = `ember-primitives-${uniqueId()}`;\n this.labelId = `${this.id}__label`;\n this.tabpanelId = `${this.id}__tabpanel`;\n }\n\n get activationMode() {\n return this.args.activationMode ?? \"automatic\";\n }\n\n get isAutomatic() {\n return this.activationMode === \"automatic\";\n }\n\n /**\n * This function relies on the fact that during rendering,\n * the first component to be rendered will be first,\n * and it will be the one to set the secret first value,\n * which means all other tabs will not be first.\n *\n */\n isActive = (tabId: string, tabValue: undefined | string) => {\n /**\n * When users pass the @value to a tab, we use that for managing\n * the \"active state\" instead of the DOM ID.\n *\n * NOTE: DOM IDs must be unique across the whole document, but @value\n * does not need to be unqiue.\n * `@value` *should* be unique for the Tabs component though\n */\n const isSelected = (x: string) => {\n if (tabValue) return x === tabValue;\n\n return x === tabId;\n };\n\n if (this.active === UNSET) {\n if (this.#first) return isSelected(this.#first);\n\n this.#first = tabValue ?? tabId;\n this.#token = stateWaiter.beginAsync();\n\n // eslint-disable-next-line ember/no-runloop\n next(() => {\n if (!this.#token) return;\n stateWaiter.endAsync(this.#token);\n if (this._active) return;\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this._label = tabValue ?? tabId;\n });\n\n return true;\n }\n\n return isSelected(this.active);\n };\n\n get active() {\n return this._active ?? this.args.activeTab ?? UNSET;\n }\n\n get activeLabel() {\n /**\n * This is only needed during the first set\n * because we prioritize rendering first, and then updating metadata later\n * (next render)\n *\n * NOTE: this does not mean that the a11y tree is updated later.\n * it is correct on initial render\n */\n if (this._label) {\n return this._label;\n }\n\n if (this.active === UNSET) {\n return \"Pending\";\n }\n\n return this.active;\n }\n\n handleChange = (tabId: string, tabValue: string | undefined) => {\n const previous = this.active;\n const next = tabValue ?? tabId;\n\n // No change, no need to be noisy\n if (next === previous) return;\n\n this._active = this._label = next;\n\n this.args.onChange?.(next, previous === UNSET ? null : previous);\n };\n}\n\nexport class Tabs extends Component<Signature> {\n state: TabState;\n\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n constructor(owner: Owner, args: {}) {\n super(owner, args);\n\n this.state = new TabState(args);\n }\n\n <template>\n <div class=\"ember-primitives__tabs\" ...attributes data-active={{this.state.activeLabel}}>\n {{! This element will be portaled in to and replaced if tabs.Label is invoked }}\n <div class=\"ember-primitives__tabs__label\" id={{this.state.labelId}}>\n {{#if (isString @label)}}\n {{@label}}\n {{else}}\n <@label />\n {{/if}}\n </div>\n <div\n class=\"ember-primitives__tabs__tablist\"\n role=\"tablist\"\n aria-labelledby={{this.state.labelId}}\n data-tabster={{TABSTER_CONFIG}}\n >\n {{yield\n (makeAPI (component TabContainer state=this.state) (component Label state=this.state))\n }}\n </div>\n {{!\n Tab's contents are portaled in to this element\n }}\n <div class=\"ember-primitives__tabs__tabpanel\" id={{this.state.tabpanelId}}></div>\n </div>\n </template>\n}\n"],"names":["UNSET","Symbol","for","TABSTER_CONFIG","getTabsterAttribute","mover","direction","MoverDirections","Both","cyclic","memorizeCurrent","deloser","TabLink","setComponentTemplate","precompileTemplate","strictMode","templateOnly","TabButton","scope","String","on","TabContent","Portal","isString","x","makeTab","tabButton","tabLink","Link","TabContainer","Component","id","uniqueId","tabId","panelId","label","args","fn","Label","makeAPI","tabContainer","labelComponent","stateWaiter","buildWaiter","TabState","g","prototype","tracked","i","labelId","tabpanelId","constructor","activationMode","isAutomatic","isActive","tabValue","isSelected","active","beginAsync","next","endAsync","_active","isDestroyed","isDestroying","_label","activeTab","activeLabel","handleChange","previous","onChange","Tabs","state","owner"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;AAOC;AAkBD,MAAMA,KAAA,GAAQC,MAAA,CAAOC,GAAG,CAAC,6BAAA,CAAA;AAEzB,MAAMC,iBAAiBC,mBAAA,CACrB;AACEC,EAAAA,KAAA,EAAO;IACLC,SAAA,EAAWC,gBAAgBC,IAAI;AAC/BC,IAAAA,MAAA,EAAQ,IAAA;AACRC,IAAAA,eAAA,EAAiB;GACnB;AACAC,EAAAA,OAAA,EAAS;AACX,CAAA,EACA,IAAA,CAAA;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AoC,OAAA;QAAAV,YAAA;AAAAS,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { cached } from '@glimmer/tracking';
|
|
4
3
|
import { hash } from '@ember/helper';
|
|
@@ -22,7 +21,7 @@ function isMulti(x) {
|
|
|
22
21
|
class ToggleGroup extends Component {
|
|
23
22
|
// See: https://github.com/typed-ember/glint/issues/715
|
|
24
23
|
static {
|
|
25
|
-
setComponentTemplate(precompileTemplate("
|
|
24
|
+
setComponentTemplate(precompileTemplate("{{#if (isMulti this.args.type)}}\n <MultiToggleGroup @value={{this.args.value}} @onChange={{this.args.onChange}} ...attributes as |x|>\n {{yield x}}\n </MultiToggleGroup>\n{{else}}\n <SingleToggleGroup @value={{this.args.value}} @onChange={{this.args.onChange}} ...attributes as |x|>\n {{yield x}}\n </SingleToggleGroup>\n{{/if}}", {
|
|
26
25
|
strictMode: true,
|
|
27
26
|
scope: () => ({
|
|
28
27
|
isMulti,
|
|
@@ -47,7 +46,7 @@ class SingleToggleGroup extends Component {
|
|
|
47
46
|
};
|
|
48
47
|
isPressed = value => value === this.activePressed;
|
|
49
48
|
static {
|
|
50
|
-
setComponentTemplate(precompileTemplate("
|
|
49
|
+
setComponentTemplate(precompileTemplate("<div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n</div>", {
|
|
51
50
|
strictMode: true,
|
|
52
51
|
scope: () => ({
|
|
53
52
|
TABSTER_CONFIG,
|
|
@@ -89,7 +88,7 @@ class MultiToggleGroup extends Component {
|
|
|
89
88
|
};
|
|
90
89
|
isPressed = value => this.activePressed.has(value);
|
|
91
90
|
static {
|
|
92
|
-
setComponentTemplate(precompileTemplate("
|
|
91
|
+
setComponentTemplate(precompileTemplate("<div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n</div>", {
|
|
93
92
|
strictMode: true,
|
|
94
93
|
scope: () => ({
|
|
95
94
|
TABSTER_CONFIG,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"toggle-group.js","sources":["../../src/components/toggle-group.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\nimport { cached } from \"@glimmer/tracking\";\nimport { hash } from \"@ember/helper\";\n\nimport { getTabsterAttribute, MoverDirections } from \"tabster\";\nimport { TrackedSet } from \"tracked-built-ins\";\n// The consumer will need to provide types for tracked-toolbox.\n// Or.. better yet, we PR to trakcked-toolbox to provide them\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { localCopy } from \"tracked-toolbox\";\n\nimport { Toggle } from \"./toggle.gts\";\n\nimport type { ComponentLike } from \"@glint/template\";\n\nconst TABSTER_CONFIG = getTabsterAttribute(\n {\n mover: {\n direction: MoverDirections.Both,\n cyclic: true,\n },\n },\n true,\n);\n\nexport interface ItemSignature<Value = any> {\n /**\n * The button element will have aria-pressed=\"true\" on it when the button is in the pressed state.\n */\n Element: HTMLButtonElement;\n Args: {\n /**\n * When used in a group of Toggles, this option will be helpful to\n * know which toggle was pressed if you're using the same @onChange\n * handler for multiple toggles.\n */\n value?: Value;\n };\n Blocks: {\n default: [\n /**\n * the current pressed state of the toggle button\n *\n * Useful when using the toggle button as an uncontrolled component\n */\n pressed: boolean,\n ];\n };\n}\n\nexport type Item<Value = any> = ComponentLike<ItemSignature<Value>>;\n\nexport interface SingleSignature<Value> {\n Element: HTMLDivElement;\n Args: {\n /**\n * Optionally set the initial toggle state\n */\n value?: Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */\n onChange?: (value: Value | undefined) => void;\n };\n Blocks: {\n default: [\n {\n /**\n * The Toggle Switch\n */\n Item: Item;\n },\n ];\n };\n}\n\nexport interface MultiSignature<Value = any> {\n Element: HTMLDivElement;\n Args: {\n /**\n * Optionally set the initial toggle state\n */\n value?: Value[] | Set<Value> | Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */\n onChange?: (value: Set<Value>) => void;\n };\n Blocks: {\n default: [\n {\n /**\n * The Toggle Switch\n */\n Item: Item;\n },\n ];\n };\n}\n\ninterface PrivateSingleSignature<Value = any> {\n Element: HTMLDivElement;\n Args: {\n type?: \"single\";\n\n /**\n * Optionally set the initial toggle state\n */\n value?: Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */\n onChange?: (value: Value | undefined) => void;\n };\n Blocks: {\n default: [\n {\n Item: Item;\n },\n ];\n };\n}\n\ninterface PrivateMultiSignature<Value = any> {\n Element: HTMLDivElement;\n Args: {\n type: \"multi\";\n /**\n * Optionally set the initial toggle state\n */\n value?: Value[] | Set<Value> | Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */\n onChange?: (value: Set<Value>) => void;\n };\n Blocks: {\n default: [\n {\n Item: Item;\n },\n ];\n };\n}\n\nfunction isMulti(x: \"single\" | \"multi\" | undefined): x is \"multi\" {\n return x === \"multi\";\n}\n\nexport class ToggleGroup<Value = any> extends Component<\n PrivateSingleSignature<Value> | PrivateMultiSignature<Value>\n> {\n // See: https://github.com/typed-ember/glint/issues/715\n <template>\n {{#if (isMulti this.args.type)}}\n <MultiToggleGroup\n @value={{this.args.value}}\n @onChange={{this.args.onChange}}\n ...attributes\n as |x|\n >\n {{yield x}}\n </MultiToggleGroup>\n {{else}}\n <SingleToggleGroup\n @value={{this.args.value}}\n @onChange={{this.args.onChange}}\n ...attributes\n as |x|\n >\n {{yield x}}\n </SingleToggleGroup>\n {{/if}}\n </template>\n}\n\nclass SingleToggleGroup<Value = any> extends Component<SingleSignature<Value>> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n @localCopy(\"args.value\") activePressed?: Value;\n\n handleToggle = (value: Value) => {\n if (this.activePressed === value) {\n this.activePressed = undefined;\n\n return;\n }\n\n this.activePressed = value;\n\n this.args.onChange?.(this.activePressed);\n };\n\n isPressed = (value: Value | undefined) => value === this.activePressed;\n\n <template>\n <div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n </div>\n </template>\n}\n\nclass MultiToggleGroup<Value = any> extends Component<MultiSignature<Value>> {\n /**\n * Normalizes @value to a Set\n * and makes sure that even if the input Set is reactive,\n * we don't mistakenly dirty it.\n */\n @cached\n get activePressed(): TrackedSet<Value> {\n const value = this.args.value;\n\n if (!value) {\n return new TrackedSet();\n }\n\n if (Array.isArray(value)) {\n return new TrackedSet(value);\n }\n\n if (value instanceof Set) {\n return new TrackedSet(value);\n }\n\n return new TrackedSet([value]);\n }\n\n handleToggle = (value: Value) => {\n if (this.activePressed.has(value)) {\n this.activePressed.delete(value);\n } else {\n this.activePressed.add(value);\n }\n\n this.args.onChange?.(new Set<Value>(this.activePressed.values()));\n };\n\n isPressed = (value: Value) => this.activePressed.has(value);\n\n <template>\n <div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n </div>\n </template>\n}\n"],"names":["TABSTER_CONFIG","getTabsterAttribute","mover","direction","MoverDirections","Both","cyclic","isMulti","x","ToggleGroup","Component","setComponentTemplate","precompileTemplate","strictMode","scope","MultiToggleGroup","SingleToggleGroup","g","prototype","localCopy","i","handleToggle","value","activePressed","undefined","args","onChange","isPressed","hash","Toggle","TrackedSet","Array","isArray","Set","n","cached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AAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAd,cAAA;QAAA4B,IAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
import { fn } from '@ember/helper';
|
|
3
2
|
import { on } from '@ember/modifier';
|
|
4
3
|
import { cell } from 'ember-resources';
|
|
5
|
-
import { t as toggleWithFallback } from '../utils-
|
|
4
|
+
import { t as toggleWithFallback } from '../utils-D0v9WKmV.js';
|
|
6
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
6
|
import { setComponentTemplate } from '@ember/component';
|
|
8
7
|
import templateOnly from '@ember/component/template-only';
|
|
@@ -14,7 +13,7 @@ function isPressed(pressed, value, isPressed) {
|
|
|
14
13
|
if (!isPressed) return Boolean(pressed);
|
|
15
14
|
return isPressed(value);
|
|
16
15
|
}
|
|
17
|
-
const Toggle = setComponentTemplate(precompileTemplate("
|
|
16
|
+
const Toggle = setComponentTemplate(precompileTemplate("{{#let (cell (isPressed @pressed @value @isPressed)) as |pressed|}}\n <button type=\"button\" aria-pressed=\"{{pressed.current}}\" {{on \"click\" (fn toggleWithFallback pressed.toggle @onChange @value)}} ...attributes>\n {{yield pressed.current}}\n </button>\n{{/let}}", {
|
|
18
17
|
strictMode: true,
|
|
19
18
|
scope: () => ({
|
|
20
19
|
cell,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"toggle.js","sources":["../../src/components/toggle.gts"],"sourcesContent":["// import Component from '@glimmer/component';\nimport { fn } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\n\nimport { cell } from \"ember-resources\";\n\nimport { toggleWithFallback } from \"./-private/utils.ts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\n\nexport interface Signature<Value = any> {\n Element: HTMLButtonElement;\n Args: {\n /**\n * The pressed-state of the toggle.\n *\n * Can be used to control the state of the component.\n */\n pressed?: boolean;\n /**\n * Callback for when the toggle's state is changed.\n *\n * Can be used to control the state of the component.\n *\n * if a `@value` is passed to this `<Toggle>`, that @value will\n * be passed to the `@onChange` handler.\n *\n * This can be useful when using the same function for the `@onChange`\n * handler with multiple `<Toggle>` components.\n */\n onChange?: (value: Value | undefined, pressed: boolean) => void;\n\n /**\n * When used in a group of Toggles, this option will be helpful to\n * know which toggle was pressed if you're using the same @onChange\n * handler for multiple toggles.\n */\n value?: Value;\n\n /**\n * When controlling state in a wrapping component, this function can be used in conjunction with `@value` to determine if this `<Toggle>` should appear pressed.\n */\n isPressed?: (value?: Value) => boolean;\n };\n Blocks: {\n default: [\n /**\n * the current pressed state of the toggle button\n *\n * Useful when using the toggle button as an uncontrolled component\n */\n pressed: boolean,\n ];\n };\n}\n\nfunction isPressed(\n pressed?: boolean,\n value?: unknown,\n isPressed?: (value?: unknown) => boolean,\n): boolean {\n if (!value) return Boolean(pressed);\n if (!isPressed) return Boolean(pressed);\n\n return isPressed(value);\n}\n\nexport const Toggle: TOC<Signature> = <template>\n {{#let (cell (isPressed @pressed @value @isPressed)) as |pressed|}}\n <button\n type=\"button\"\n aria-pressed=\"{{pressed.current}}\"\n {{on \"click\" (fn toggleWithFallback pressed.toggle @onChange @value)}}\n ...attributes\n >\n {{yield pressed.current}}\n </button>\n {{/let}}\n</template>;\n\nexport default Toggle;\n"],"names":["isPressed","pressed","value","Boolean","Toggle","setComponentTemplate","precompileTemplate","strictMode","scope","cell","on","fn","toggleWithFallback","templateOnly"],"mappings":";;;;;;;;AAAA;;AAwDA,SAASA,SAAAA,CACPC,OAAiB,EACjBC,KAAe,EACfF,SAAwC,EAChC;AACR,EAAA,IAAI,CAACE,KAAA,EAAO,OAAOC,OAAA,CAAQF,OAAA,CAAA;AAC3B,EAAA,IAAI,CAACD,SAAA,EAAW,OAAOG,OAAA,CAAQF,OAAA,CAAA;EAE/B,OAAOD,SAAA,CAAUE,KAAA,CAAA;AACnB;MAEaE,MAAY,GAAAC,oBAAA,CAAaC,kBAAA,CAAA,mRAAA,EAWtC;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,IAAA;IAAAT,SAAA;IAAAU,EAAA;IAAAC,EAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;;;"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
import '../visually-hidden-CGP1FSjt.js';
|
|
3
2
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
3
|
import { setComponentTemplate } from '@ember/component';
|
|
5
4
|
import templateOnly from '@ember/component/template-only';
|
|
6
5
|
|
|
7
|
-
const VisuallyHidden = setComponentTemplate(precompileTemplate("
|
|
6
|
+
const VisuallyHidden = setComponentTemplate(precompileTemplate("<span class=\"ember-primitives__visually-hidden\" ...attributes>{{yield}}</span>", {
|
|
8
7
|
strictMode: true
|
|
9
8
|
}), templateOnly());
|
|
10
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visually-hidden.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"visually-hidden.js","sources":["../../src/components/visually-hidden.gts"],"sourcesContent":["import \"./visually-hidden.css\";\n\nimport type { TOC } from \"@ember/component/template-only\";\n\nexport const VisuallyHidden: TOC<{\n Element: HTMLSpanElement;\n Blocks: {\n /**\n * Content to hide visually\n */\n default: [];\n };\n}> = <template>\n <span class=\"ember-primitives__visually-hidden\" ...attributes>{{yield}}</span>\n</template>;\n"],"names":["VisuallyHidden","precompileTemplate","strictMode","templateOnly"],"mappings":";;;;;MAIaA,sCAQRC,kBAAA,CAAA,kFAAA,EAEL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;;;"}
|
package/dist/dom-context.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { tracked, cached } from '@glimmer/tracking';
|
|
4
3
|
import { assert } from '@ember/debug';
|
|
@@ -41,7 +40,7 @@ class Provide extends Component {
|
|
|
41
40
|
return this.args.element !== false;
|
|
42
41
|
}
|
|
43
42
|
static {
|
|
44
|
-
setComponentTemplate(precompileTemplate("
|
|
43
|
+
setComponentTemplate(precompileTemplate("{{#if (isElement this.element)}}\n {{this.element}}\n\n {{#in-element this.element}}\n {{yield}}\n {{/in-element}}\n\n{{else}}\n {{!-- NOTE! This type of provider will _allow_ non-descendents using the same key to find the provider and use it.\n\n For example:\n Provider\n Consumer\n\n Consumer (finds Provider)\n --}}\n\n {{this.element}}\n {{yield}}\n\n{{/if}}", {
|
|
45
44
|
strictMode: true,
|
|
46
45
|
scope: () => ({
|
|
47
46
|
isElement
|
|
@@ -105,7 +104,7 @@ class Consume extends Component {
|
|
|
105
104
|
n(this.prototype, "context", [cached]);
|
|
106
105
|
}
|
|
107
106
|
static {
|
|
108
|
-
setComponentTemplate(precompileTemplate("
|
|
107
|
+
setComponentTemplate(precompileTemplate("{{this.element}}\n\n{{yield this.context}}", {
|
|
109
108
|
strictMode: true
|
|
110
109
|
}), this);
|
|
111
110
|
}
|
package/dist/dom-context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-context.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"dom-context.js","sources":["../src/dom-context.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\nimport { cached, tracked } from \"@glimmer/tracking\";\nimport { assert } from \"@ember/debug\";\n\nimport { isElement } from \"./narrowing.ts\";\nimport { createStore } from \"./store.ts\";\n\nimport type { Newable } from \"./type-utils\";\nimport type Owner from \"@ember/owner\";\n\n/**\n * IMPLEMENTATION NOTE:\n * we don't use https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md\n * because it is not inherently reactive.\n *\n * Its *event* based, which opts you out of fine-grained reactivity.\n * We want minimal effort fine-grained reactivity.\n *\n * This Technique follows the DOM tree, and is synchronous,\n * allowing correct fine-grained signals-based reactivity.\n *\n * We *could* do less work to find Providers,\n * but only if we forgoe DOM-tree scoping.\n * We must traverse the DOM hierarchy to validate that we aren't accessing providers from different subtrees.\n */\nconst LOOKUP = new WeakMap<Text | Element, [unknown, () => unknown]>();\n\nexport class Provide<Data extends object> extends Component<{\n /**\n * The Element is not customizable\n * (and also sometimes doesn't exist (depending on the `@element` value))\n */\n Element: null;\n Args: {\n /**\n * What data do you want to provide to the DOM subtree?\n *\n * If this is a function or class, it will be instantiated and given an\n * owner + destroyable linkage via `createStore`\n */\n data: Data | (() => Data) | Newable<Data>;\n\n /**\n * Optionally, you may use string-based keys to reference the data in the Provide.\n *\n * This is not recommended though, because when using a class or other object-like structure,\n * the type in the `<Consume>` component can be derived from that class or object-like structure.\n * With string keys, the `<Consume>` type will be unknown.\n */\n key?: string;\n\n /**\n * Can be used to either customize the element tag ( defaults to div )\n * If set to `false`, we won't use an element for the Provider boundary.\n *\n * Setting this to `false` changes the DOM Node containing the Provider's data to be a text node -- which can be useful when certain CSS situations are needed.\n *\n * But setting to `false` has a hazard: it allows subsequent sibling subtrees to access adjacent providers.\n *\n * There is no way around caveat in library land, and in a framework implementation of context,\n * it can only be solved by having render-tree context implemented, and ignoring DOM\n * (which then makes the only difference between DOM-Context and Context be whether or not\n * the context punches through Portals)\n */\n element?: keyof HTMLElementTagNameMap | false | undefined;\n };\n Blocks: {\n /**\n * The content that this component will _provide_ data to the entire hierarchy.\n */\n default: [];\n };\n}> {\n get data() {\n assert(`@data is missing in <Provide>. Please pass @data.`, \"data\" in this.args);\n\n /**\n * This covers both classes and functions\n */\n if (typeof this.args.data === \"function\") {\n return createStore<Data>(this, this.args.data);\n }\n\n /**\n * Non-instantiable value\n */\n return this.args.data;\n }\n\n element: Text | HTMLElement;\n\n constructor(\n owner: Owner,\n args: {\n data: Data | (() => Data) | Newable<Data>;\n key?: string;\n },\n ) {\n super(owner, args);\n\n assert(\n `@element may only be \\`false\\` or a string (or undefined (default when not set))`,\n this.args.element === undefined ||\n this.args.element === false ||\n typeof this.args.element === \"string\",\n );\n\n if (this.useElementProvider) {\n this.element = document.createElement(this.args.element || \"div\");\n\n // This tells the browser to ignore everything about this element when it comes to styling\n this.element.style.display = \"contents\";\n } else {\n this.element = document.createTextNode(\"\");\n }\n\n const key = this.args.key ?? this.args.data;\n\n LOOKUP.set(this.element, [key, () => this.data]);\n }\n\n get useElementProvider() {\n return this.args.element !== false;\n }\n\n <template>\n {{#if (isElement this.element)}}\n {{this.element}}\n\n {{#in-element this.element}}\n {{yield}}\n {{/in-element}}\n\n {{else}}\n {{! NOTE! This type of provider will _allow_ non-descendents using the same key to find the provider and use it.\n\n For example:\n Provider\n Consumer\n\n Consumer (finds Provider)\n }}\n\n {{this.element}}\n {{yield}}\n\n {{/if}}\n </template>\n}\n\n/**\n * How this works:\n * - starting at some deep node (Text, Element, whatever),\n * start crawling up the ancenstry graph (of DOM Nodes).\n *\n * - This algo \"tops out\" (since we traverse upwards (otherwise this would be \"bottoming out\")) at the HTMLDocument (parent of the HTML Tag)\n *\n */\nfunction findForKey<Data>(startElement: Text, key: string | object): undefined | (() => Data) {\n let parent: ParentNode | Text | null | undefined = startElement;\n\n while (parent) {\n let target: ParentNode | ChildNode | Text | null | undefined = parent;\n\n while (target) {\n if (!(target instanceof Element) && !(target instanceof Text)) {\n target = target?.previousSibling;\n continue;\n }\n\n const maybe = LOOKUP.get(target);\n\n target = target?.previousSibling;\n\n if (!maybe) {\n continue;\n }\n\n if (maybe[0] === key) {\n return maybe[1] as () => Data;\n }\n }\n\n parent = parent.parentElement;\n }\n}\n\ntype DataForKey<Key> = Key extends string\n ? unknown\n : Key extends Newable<infer T>\n ? T\n : Key extends () => infer T\n ? T\n : Key;\n\nexport class Consume<Key extends object | string> extends Component<{\n Args: {\n key: Key;\n };\n Blocks: {\n default: [\n context: {\n data: DataForKey<Key>;\n },\n ];\n };\n}> {\n // SAFETY: We do a runtime assert in the getter below.\n @tracked getData!: () => DataForKey<Key>;\n\n element: Text;\n\n constructor(owner: Owner, args: { key: Key }) {\n super(owner, args);\n\n this.element = document.createTextNode(\"\");\n }\n\n @cached\n get context() {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n return {\n get data(): DataForKey<Key> {\n const getData = findForKey<Key>(self.element, self.args.key);\n\n assert(\n `Could not find provided context in <Consume>. Please assure that there is a corresponding <Provide> component before using this <Consume> component`,\n getData,\n );\n\n // SAFETY: return type handled by getter's signature\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return getData() as any;\n },\n };\n }\n\n <template>\n {{this.element}}\n\n {{yield this.context}}\n </template>\n}\n"],"names":["LOOKUP","WeakMap","Provide","Component","data","assert","args","createStore","element","constructor","owner","undefined","useElementProvider","document","createElement","style","display","createTextNode","key","set","setComponentTemplate","precompileTemplate","strictMode","scope","isElement","findForKey","startElement","parent","target","Element","Text","previousSibling","maybe","get","parentElement","Consume","tracked","i","context","self","getData","n","prototype","cached"],"mappings":";;;;;;;;;AAyBA,MAAMA,SAAS,IAAIC,OAAA,EAA+C;AAE3D,MAAMC,OAAA,SAAqCC,SAAA;EA8ChD,IAAIC,IAAAA,GAAO;IACTC,MAAA,CAAO,mDAAmD,EAAE,MAAA,IAAU,IAAI,CAACC,IAAI,CAAA;AAE/E;;;IAGA,IAAI,OAAO,IAAI,CAACA,IAAI,CAACF,IAAI,KAAK,UAAA,EAAY;MACxC,OAAOG,WAAA,CAAkB,IAAI,EAAE,IAAI,CAACD,IAAI,CAACF,IAAI,CAAA;AAC/C,IAAA;AAEA;;AAEC;AACD,IAAA,OAAO,IAAI,CAACE,IAAI,CAACF,IAAI;AACvB,EAAA;EAEAI,OAAA;AAEAC,EAAAA,WAAAA,CACEC,KAAY,EACZJ,IAGC,EACD;AACA,IAAA,KAAK,CAACI,KAAA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AA,CAAAC,SAAA,EAAA,SAAA,EAAA,CAnBCC,MAAA,CAAA,CAAA;AAAA;AAqBD,EAAA;IAAAvB,oBAAA,CAAAC,kBAAA,CAAA,4CAAA,EAIA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
package/dist/floating-ui.js
CHANGED
package/dist/head.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
3
2
|
import { setComponentTemplate } from '@ember/component';
|
|
4
3
|
import templateOnly from '@ember/component/template-only';
|
|
@@ -23,7 +22,7 @@ function getHead() {
|
|
|
23
22
|
* </template>
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
|
-
const InHead = setComponentTemplate(precompileTemplate("
|
|
25
|
+
const InHead = setComponentTemplate(precompileTemplate("{{#in-element (getHead) insertBefore=null}}\n {{yield}}\n{{/in-element}}", {
|
|
27
26
|
strictMode: true,
|
|
28
27
|
scope: () => ({
|
|
29
28
|
getHead
|
package/dist/head.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"head.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"head.js","sources":["../src/head.gts"],"sourcesContent":["import type { TOC } from \"@ember/component/template-only\";\n\nexport interface Signature {\n Blocks: {\n /**\n * Content to render in to the `<head>` element\n */\n default: [];\n };\n}\n\nfunction getHead() {\n return document.head;\n}\n\n/**\n * Utility component to place elements in the document `<head>`\n *\n * When this component is unrendered, its contents will be removed as well.\n *\n * @example\n * ```js\n * import { InHead } from 'ember-primitives/head';\n *\n * <template>\n * {{#if @useBootstrap}}\n * <script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js\"></script>\n * <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css\">\n * {{/if}}\n * </template>\n * ```\n */\nexport const InHead: TOC<Signature> = <template>\n {{#in-element (getHead) insertBefore=null}}\n {{yield}}\n {{/in-element}}\n</template>;\n"],"names":["getHead","document","head","InHead","setComponentTemplate","precompileTemplate","strictMode","scope","templateOnly"],"mappings":";;;;AAWA,SAASA,OAAAA,GAAA;EACP,OAAOC,SAASC,IAAI;AACtB;AAEA;;;;;;;;;;;;;;;;AAgBC;MACYC,MAAY,GAAAC,oBAAA,CAAaC,kBAAA,CAAA,2EAAA,EAItC;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAP,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAQ,YAAA,EAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-class.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"body-class.js","sources":["../../src/helpers/body-class.ts"],"sourcesContent":["/**\n * Initial inspo:\n * - https://github.com/ef4/ember-set-body-class/blob/master/addon/services/body-class.js\n * - https://github.com/ef4/ember-set-body-class/blob/master/addon/helpers/set-body-class.js\n */\nimport Helper from '@ember/component/helper';\nimport { buildWaiter } from '@ember/test-waiters';\n\nconst waiter = buildWaiter('ember-primitives:body-class:raf');\n\nlet id = 0;\nconst registrations = new Map<number, string[]>();\nlet previousRegistrations: string[] = [];\n\nfunction classNames(): string[] {\n const allNames = new Set<string>();\n\n for (const classNames of registrations.values()) {\n for (const className of classNames) {\n allNames.add(className);\n }\n }\n\n return [...allNames];\n}\n\nlet frame: number;\nlet waiterToken: unknown;\n\nfunction queueUpdate() {\n waiterToken ||= waiter.beginAsync();\n\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n updateBodyClass();\n waiter.endAsync(waiterToken);\n waiterToken = undefined;\n });\n}\n\n/**\n * This should only add/remove classes that we tried to maintain via the body-class helper.\n *\n * Folks can set classes in their html and we don't want to mess with those\n */\nfunction updateBodyClass() {\n const toAdd = classNames();\n\n for (const name of previousRegistrations) {\n document.body.classList.remove(name);\n }\n\n for (const name of toAdd) {\n document.body.classList.add(name);\n }\n\n previousRegistrations = toAdd;\n}\n\nexport interface Signature {\n Args: {\n Positional: [\n /**\n * a space-delimited list of classes to apply when this helper is called.\n *\n * When the helper is removed from rendering, the clasess will be removed as well.\n */\n classes: string,\n ];\n };\n /**\n * This helper returns nothing, as it is a side-effect that mutates and manages external state.\n */\n Return: undefined;\n}\n\nexport default class BodyClass extends Helper<Signature> {\n localId = id++;\n\n compute([classes]: [string]): undefined {\n const classNames = classes ? classes.split(/\\s+/) : [];\n\n registrations.set(this.localId, classNames);\n\n queueUpdate();\n }\n\n willDestroy() {\n registrations.delete(this.localId);\n queueUpdate();\n }\n}\n\nexport const bodyClass = BodyClass;\n"],"names":["waiter","buildWaiter","id","registrations","Map","previousRegistrations","classNames","allNames","Set","values","className","add","frame","waiterToken","queueUpdate","beginAsync","cancelAnimationFrame","requestAnimationFrame","updateBodyClass","endAsync","undefined","toAdd","name","document","body","classList","remove","BodyClass","Helper","localId","compute","classes","split","set","willDestroy","delete","bodyClass"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AAIA,MAAMA,MAAM,GAAGC,WAAW,CAAC,iCAAiC,CAAC;AAE7D,IAAIC,EAAE,GAAG,CAAC;AACV,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAAoB;AACjD,IAAIC,qBAA+B,GAAG,EAAE;AAExC,SAASC,UAAUA,GAAa;AAC9B,EAAA,MAAMC,QAAQ,GAAG,IAAIC,GAAG,EAAU;EAElC,KAAK,MAAMF,UAAU,IAAIH,aAAa,CAACM,MAAM,EAAE,EAAE;AAC/C,IAAA,KAAK,MAAMC,SAAS,IAAIJ,UAAU,EAAE;AAClCC,MAAAA,QAAQ,CAACI,GAAG,CAACD,SAAS,CAAC;AACzB,IAAA;AACF,EAAA;EAEA,OAAO,CAAC,GAAGH,QAAQ,CAAC;AACtB;AAEA,IAAIK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;;;;"}
|
package/dist/helpers/link.js
CHANGED
package/dist/helpers/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../src/helpers/link.ts"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { assert } from '@ember/debug';\nimport { service } from '@ember/service';\n\nimport { handle } from '../proper-links.ts';\n\nimport type RouterService from '@ember/routing/router-service';\n\nexport interface Signature {\n Args: {\n Positional: [href: string];\n Named: {\n includeActiveQueryParams?: boolean | string[];\n activeOnSubPaths?: boolean;\n };\n };\n Return: {\n isExternal: boolean;\n isActive: boolean;\n handleClick: (event: MouseEvent) => void;\n };\n}\n\nexport default class Link extends Helper<Signature> {\n @service declare router: RouterService;\n\n compute(\n [href]: [href: string],\n {\n includeActiveQueryParams = false,\n activeOnSubPaths = false,\n }: { includeActiveQueryParams?: boolean | string[]; activeOnSubPaths?: boolean }\n ) {\n assert('href was not passed in', href);\n\n const router = this.router;\n const handleClick = (event: MouseEvent) => {\n assert('[BUG]', event.currentTarget instanceof HTMLAnchorElement);\n\n handle(router, event.currentTarget, [], event);\n };\n\n return {\n isExternal: isExternal(href),\n get isActive() {\n return isActive(router, href, includeActiveQueryParams, activeOnSubPaths);\n },\n handleClick,\n };\n }\n}\n\nexport const link = Link;\n\nexport function isExternal(href: string) {\n if (!href) return false;\n if (href.startsWith('#')) return false;\n if (href.startsWith('/')) return false;\n\n return location.origin !== new URL(href).origin;\n}\n\nexport function isActive(\n router: RouterService,\n href: string,\n includeQueryParams?: boolean | string[],\n activeOnSubPaths?: boolean\n) {\n if (!includeQueryParams) {\n /**\n * is Active doesn't understand `href`, so we have to convert to RouteInfo-esque\n */\n const info = router.recognize(href);\n\n if (info) {\n const dynamicSegments = getParams(info);\n const routeName = activeOnSubPaths ? info.name.replace(/\\.index$/, '') : info.name;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return router.isActive(routeName, ...dynamicSegments);\n }\n\n return false;\n }\n\n const url = new URL(href, location.origin);\n const hrefQueryParams = new URLSearchParams(url.searchParams);\n const hrefPath = url.pathname;\n\n const currentPath = router.currentURL?.split('?')[0];\n\n if (!currentPath) return false;\n\n if (activeOnSubPaths ? !currentPath.startsWith(hrefPath) : hrefPath !== currentPath) return false;\n\n const currentQueryParams = router.currentRoute?.queryParams;\n\n if (!currentQueryParams) return false;\n\n if (includeQueryParams === true) {\n return Object.entries(currentQueryParams).every(([key, value]) => {\n return hrefQueryParams.get(key) === value;\n });\n }\n\n return includeQueryParams.every((key) => {\n return hrefQueryParams.get(key) === currentQueryParams[key];\n });\n}\n\ntype RouteInfo = ReturnType<RouterService['recognize']>;\n\nexport function getParams(currentRouteInfo: RouteInfo) {\n let params: Record<string, unknown>[] = [];\n\n while (currentRouteInfo?.parent) {\n const currentParams = currentRouteInfo.params;\n\n params = currentParams ? [currentParams, ...params] : params;\n currentRouteInfo = currentRouteInfo.parent;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return params.map(Object.values).flat();\n}\n"],"names":["Link","Helper","g","prototype","service","i","compute","href","includeActiveQueryParams","activeOnSubPaths","assert","router","handleClick","event","currentTarget","HTMLAnchorElement","handle","isExternal","isActive","link","startsWith","location","origin","URL","includeQueryParams","info","recognize","dynamicSegments","getParams","routeName","name","replace","url","hrefQueryParams","URLSearchParams","searchParams","hrefPath","pathname","currentPath","currentURL","split","currentQueryParams","currentRoute","queryParams","Object","entries","every","key","value","get","currentRouteInfo","params","parent","currentParams","map","values","flat"],"mappings":";;;;;;AAuBe,MAAMA,IAAI,SAASC,MAAM,CAAY;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CACjDC,OAAO,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;AAERC,EAAAA,OAAOA,CACL,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GAAG,IAAK;IACvC,OAAOd,eAAe,CAACgB,GAAG,CAACF,GAAG,CAAC,KAAKN,kBAAkB,CAACM,GAAG,CAAC;AAC7D,EAAA,CAAC,CAAC;AACJ;AAIO,SAASnB,SAASA,CAACsB,gBAA2B,EAAE;EACrD,IAAIC,MAAiC,GAAG,EAAE;EAE1C,OAAOD,gBAAgB,EAAEE,MAAM,EAAE;AAC/B,IAAA,MAAMC,aAAa,GAAGH,gBAAgB,CAACC,MAAM;IAE7CA,MAAM,GAAGE,aAAa,GAAG,CAACA,aAAa,EAAE,GAAGF,MAAM,CAAC,GAAGA,MAAM;IAC5DD,gBAAgB,GAAGA,gBAAgB,CAACE,MAAM;AAC5C,EAAA;;AAEA;EACA,OAAOD,MAAM,CAACG,GAAG,CAACV,MAAM,CAACW,MAAM,CAAC,CAACC,IAAI,EAAE;AACzC;;;;"}
|
package/dist/helpers/service.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"service.js","sources":["../../src/helpers/service.ts"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { assert } from '@ember/debug';\nimport { getOwner } from '@ember/owner';\n\nimport type { Registry } from '@ember/service';\nimport type Service from '@ember/service';\n\nexport interface Signature<Key extends keyof Registry> {\n Args: {\n Positional: [Key];\n };\n Return: Registry[Key] & Service;\n}\n\nexport default class GetService<Key extends keyof Registry> extends Helper<Signature<Key>> {\n compute(positional: [Key]): Registry[Key] & Service {\n const owner = getOwner(this);\n\n assert(`Could not get owner.`, owner);\n\n return owner.lookup(`service:${positional[0]}`) as Registry[Key] & Service;\n }\n}\n\nexport const service = GetService;\n"],"names":["GetService","Helper","compute","positional","owner","getOwner","assert","lookup","service"],"mappings":";;;;AAce,MAAMA,UAAU,SAAqCC,MAAM,CAAiB;EACzFC,OAAOA,CAACC,UAAiB,EAA2B;AAClD,IAAA,MAAMC,KAAK,GAAGC,QAAQ,CAAC,IAAI,CAAC;AAE5BC,IAAAA,MAAM,CAAC,CAAA,oBAAA,CAAsB,EAAEF,KAAK,CAAC;IAErC,OAAOA,KAAK,CAACG,MAAM,CAAC,CAAA,QAAA,EAAWJ,UAAU,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACjD,EAAA;AACF;AAEO,MAAMK,OAAO,GAAGR;;;;"}
|
package/dist/helpers.js
CHANGED
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/iframe.js
CHANGED
package/dist/iframe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"iframe.js","sources":["../src/iframe.ts"],"sourcesContent":["/**\n * Returns true if the current frame is within an iframe.\n *\n * ```gjs\n * import { inIframe } from 'ember-primitives/iframe';\n *\n * <template>\n * {{#if (inFrame)}}\n * only show content in an iframe\n * {{/if}}\n * </template>\n * ```\n */\nexport const inIframe = () => window.self !== window.top;\n\n/**\n * Returns true if the current frame is not within an iframe.\n *\n * ```gjs\n * import { notInIframe } from 'ember-primitives/iframe';\n *\n * <template>\n * {{#if (notInIframe)}}\n * only show content when not in an iframe\n * This is also the default if your site/app\n * does not use iframes\n * {{/if}}\n * </template>\n * ```\n */\nexport const notInIframe = () => !inIframe();\n"],"names":["inIframe","window","self","top","notInIframe"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAGA,MAAMC,MAAM,CAACC,IAAI,KAAKD,MAAM,CAACE;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAGA,MAAM,CAACJ,QAAQ;;;;"}
|
|
@@ -231,7 +231,7 @@ class Zoetrope extends Component {
|
|
|
231
231
|
return returnObj;
|
|
232
232
|
}
|
|
233
233
|
static {
|
|
234
|
-
setComponentTemplate(precompileTemplate("
|
|
234
|
+
setComponentTemplate(precompileTemplate("<section class=\"ember-primitives__zoetrope\" {{this.setCSSVariables gap=this.gap offset=this.offset}} ...attributes>\n {{#if (has-block \"header\")}}\n <div class=\"ember-primitives__zoetrope__header\">\n {{yield to=\"header\"}}\n </div>\n {{/if}}\n\n {{#if (has-block \"controls\")}}\n {{yield (hash cannotScrollLeft=this.cannotScrollLeft cannotScrollRight=this.cannotScrollRight canScroll=this.canScroll scrollLeft=this.scrollLeft scrollRight=this.scrollRight) to=\"controls\"}}\n {{else}}\n {{#if this.canScroll}}\n <div class=\"ember-primitives__zoetrope__controls\">\n <button type=\"button\" {{on \"click\" this.scrollLeft}} disabled={{this.cannotScrollLeft}}>Left</button>\n\n <button type=\"button\" {{on \"click\" this.scrollRight}} disabled={{this.cannotScrollRight}}>Right</button>\n </div>\n {{/if}}\n {{/if}}\n {{#if (has-block \"content\")}}\n <div class=\"ember-primitives__zoetrope__scroller\" {{this.configureScroller}}>\n {{yield to=\"content\"}}\n </div>\n {{else}}\n {{(this.noScrollWaiter)}}\n {{/if}}\n</section>", {
|
|
235
235
|
strictMode: true,
|
|
236
236
|
scope: () => ({
|
|
237
237
|
hash,
|
|
@@ -266,4 +266,4 @@ function getRelativeBoundingClientRect(childElement, parentElement) {
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
export { Zoetrope as Z };
|
|
269
|
-
//# sourceMappingURL=index-
|
|
269
|
+
//# sourceMappingURL=index-gRO4Cvlf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-gRO4Cvlf.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { macroCondition, isDevelopingApp, importSync } from '@embroider/macros';
|
|
3
2
|
export { Accordion } from './components/accordion.js';
|
|
4
3
|
export { Avatar } from './components/avatar.js';
|
|
@@ -9,19 +8,19 @@ export { Key, KeyCombo } from './components/keys.js';
|
|
|
9
8
|
export { StickyFooter } from './components/layout/sticky-footer.js';
|
|
10
9
|
export { Link } from './components/link.js';
|
|
11
10
|
export { Menu } from './components/menu.js';
|
|
12
|
-
export { a as OTP, O as OTPInput } from './otp-
|
|
11
|
+
export { a as OTP, O as OTPInput } from './otp-7rz1PWP0.js';
|
|
13
12
|
export { Popover } from './components/popover.js';
|
|
14
13
|
export { Portal } from './components/portal.js';
|
|
15
14
|
export { TARGETS as PORTALS, PortalTargets } from './components/portal-targets.js';
|
|
16
15
|
export { Progress } from './components/progress.js';
|
|
17
|
-
export { R as Rating } from './rating-
|
|
16
|
+
export { R as Rating } from './rating-CjBVsX6q.js';
|
|
18
17
|
export { Scroller } from './components/scroller.js';
|
|
19
18
|
export { Shadowed } from './components/shadowed.js';
|
|
20
19
|
export { Switch } from './components/switch.js';
|
|
21
20
|
export { Toggle } from './components/toggle.js';
|
|
22
21
|
export { ToggleGroup } from './components/toggle-group.js';
|
|
23
22
|
export { VisuallyHidden } from './components/visually-hidden.js';
|
|
24
|
-
export { Z as Zoetrope } from './index-
|
|
23
|
+
export { Z as Zoetrope } from './index-gRO4Cvlf.js';
|
|
25
24
|
export { link } from './helpers/link.js';
|
|
26
25
|
export { service } from './helpers/service.js';
|
|
27
26
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * DANGER: this is a *barrel file*\n *\n * It forces the whole library to be loaded and all dependencies.\n *\n * If you have a small app, you probably don't want to import from here -- instead import from each sub-path.\n */\nimport { importSync, isDevelopingApp, macroCondition } from '@embroider/macros';\n\nif (macroCondition(isDevelopingApp())) {\n importSync('./components/violations.css');\n}\n\nexport { Accordion } from './components/accordion.gts';\nexport type {\n AccordionContentExternalSignature,\n AccordionHeaderExternalSignature,\n AccordionItemExternalSignature,\n AccordionTriggerExternalSignature,\n} from './components/accordion/public.ts';\nexport { Avatar } from './components/avatar.gts';\nexport { Dialog, Dialog as Modal } from './components/dialog.gts';\nexport { ExternalLink } from './components/external-link.gts';\nexport { Form } from './components/form.gts';\nexport { Key, KeyCombo } from './components/keys.gts';\nexport { StickyFooter } from './components/layout/sticky-footer.gts';\nexport { Link } from './components/link.gts';\nexport { Menu } from './components/menu.gts';\nexport { OTP, OTPInput } from './components/one-time-password.gts';\nexport { Popover } from './components/popover.gts';\nexport { Portal } from './components/portal.gts';\nexport { PortalTargets } from './components/portal-targets.gts';\nexport { TARGETS as PORTALS } from './components/portal-targets.gts';\nexport { Progress } from './components/progress.gts';\nexport { Rating } from './components/rating.gts';\nexport { Scroller } from './components/scroller.gts';\nexport { Shadowed } from './components/shadowed.gts';\nexport { Switch } from './components/switch.gts';\nexport { Toggle } from './components/toggle.gts';\nexport { ToggleGroup } from './components/toggle-group.gts';\nexport { VisuallyHidden } from './components/visually-hidden.gts';\nexport { Zoetrope } from './components/zoetrope.ts';\nexport * from './helpers.ts';\n"],"names":["macroCondition","isDevelopingApp","importSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,IAAIA,cAAc,CAACC,eAAe,EAAE,CAAC,EAAE;EACrCC,UAAU,CAAC,6BAA6B,CAAC;AAC3C"}
|
package/dist/load.js
CHANGED
package/dist/load.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"load.js","sources":["../src/load.gts"],"sourcesContent":["import { setComponentTemplate } from \"@ember/component\";\nimport templateOnly from \"@ember/component/template-only\";\n// Have to use these until min ember version is like 6.3 or something\nimport { precompileTemplate } from \"@ember/template-compilation\";\n\nimport { getPromiseState } from \"reactiveweb/get-promise-state\";\n\nimport type { ComponentLike } from \"@glint/template\";\n\ninterface LoadSignature<\n Expected = {\n Args: any;\n },\n> {\n Blocks: {\n loading: [];\n error: [\n {\n original: unknown;\n reason: string;\n },\n ];\n success?: [component: ComponentLike<Expected>];\n };\n}\n\n/**\n * Loads a value / promise / function providing state for the lifetime of that value / promise / function.\n *\n * Can be used for manual bundle splitting via await importing components.\n *\n * @example\n * ```gjs\n * import { load } from 'ember-primitives/load';\n *\n * const Loader = load(() => import('./routes/sub-route.gts'));\n *\n * <template>\n * <Loader>\n * <:loading> ... loading ... </:loading>\n * <:error as |error|> ... error! {{error.reason}} </:error>\n * <:success as |component|> <component /> </:success>\n * </Loader>\n * </template>\n * ```\n */\nexport function load<ExpectedSignature, Value>(\n fn: Value | Promise<Value> | (() => Promise<Value>) | (() => Value),\n): ComponentLike<LoadSignature<ExpectedSignature>> {\n return setComponentTemplate(\n precompileTemplate(\n `{{#let (getPromiseState fn) as |state|}}\n {{#if state.isLoading}}\n {{yield to=\"loading\"}}\n {{else if state.error}}\n {{yield state.error to=\"error\"}}\n {{else if state.resolved}}\n {{#if (has-block \"success\")}}\n {{yield state.resolved to=\"success\"}}\n {{else}}\n <state.component />\n {{/if}}\n {{/if}}\n{{/let}}`,\n {\n strictMode: true,\n /**\n * The old setComponentTemplate + precompileTemplate combo\n * does not allow defining things in this scope object,\n * we _have_ to use the shorthand.\n */\n scope: () => ({ fn, getPromiseState }),\n },\n ),\n templateOnly(),\n ) as ComponentLike<LoadSignature<ExpectedSignature>>;\n}\n"],"names":["load","fn","setComponentTemplate","precompileTemplate","strictMode","scope","getPromiseState","templateOnly"],"mappings":";;;;;AA0BA;;;;;;;;;;;;;;;;;;;AAmBC;AACM,SAASA,IAAAA,CACdC,EAAmE,EACtC;EAC7B,OAAOC,oBAAA,CACLC,wXAcE;AACEC,IAAAA,UAAA,EAAY,IAAA;AACZ;;;;;AAKAC,IAAAA,KAAA,EAAAA,OAAA;MAAAJ,EAAA;AAAAK,MAAAA;AAAA,KAAA;AACF,GAAA,CAAA,EAEFC,YAAA,EAAA,CAAA;AAEJ;;;;"}
|
package/dist/narrowing.js
CHANGED
package/dist/narrowing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"narrowing.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"narrowing.js","sources":["../src/narrowing.ts"],"sourcesContent":["export function isString(x: unknown): x is string {\n return typeof x === 'string';\n}\n\nexport function isElement(x: unknown): x is Element {\n return x instanceof Element;\n}\n"],"names":["isString","x","isElement","Element"],"mappings":"AAAO,SAASA,QAAQA,CAACC,CAAU,EAAe;EAChD,OAAO,OAAOA,CAAC,KAAK,QAAQ;AAC9B;AAEO,SAASC,SAASA,CAACD,CAAU,EAAgB;EAClD,OAAOA,CAAC,YAAYE,OAAO;AAC7B;;;;"}
|
package/dist/on-resize.js
CHANGED
package/dist/on-resize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-resize.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"on-resize.js","sources":["../src/on-resize.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\n\nimport Modifier, { type ArgsFor } from 'ember-modifier';\n\nimport { resizeObserver } from './resize-observer.ts';\n\nimport type Owner from '@ember/owner';\n\n// re-export provided for convenience\nexport { ignoreROError } from './resize-observer.ts';\n\nexport interface Signature {\n /**\n * Any element that is resizable can have onResize attached\n */\n Element: Element;\n Args: {\n Positional: [\n /**\n * The ResizeObserver callback will only receive\n * one entry per resize event.\n *\n * See: [ResizeObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)\n */\n callback: (entry: ResizeObserverEntry) => void,\n ];\n };\n}\n\nclass OnResize extends Modifier<Signature> {\n #callback: ((entry: ResizeObserverEntry) => void) | null = null;\n #element: Element | null = null;\n\n #resizeObserver = resizeObserver(this);\n\n constructor(owner: Owner, args: ArgsFor<Signature>) {\n super(owner, args);\n\n registerDestructor(this, () => {\n if (this.#element && this.#callback) {\n this.#resizeObserver.unobserve(this.#element, this.#callback);\n }\n });\n }\n\n modify(element: Element, [callback]: [callback: (entry: ResizeObserverEntry) => void]) {\n assert(\n `{{onResize}}: callback must be a function, but was ${callback as unknown as string}`,\n typeof callback === 'function'\n );\n\n if (this.#element && this.#callback) {\n this.#resizeObserver.unobserve(this.#element, this.#callback);\n }\n\n this.#resizeObserver.observe(element, callback);\n\n this.#callback = callback;\n this.#element = element;\n }\n}\n\nexport const onResize = OnResize;\n"],"names":["OnResize","Modifier","resizeObserver","constructor","owner","args","registerDestructor","unobserve","modify","element","callback","assert","observe","onResize"],"mappings":";;;;;;AA8BA,MAAMA,QAAQ,SAASC,QAAQ,CAAY;EACzC,SAAS,GAAkD,IAAI;EAC/D,QAAQ,GAAmB,IAAI;AAE/B,EAAA,eAAe,GAAGC,cAAc,CAAC,IAAI,CAAC;AAEtCC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,IAAwB,EAAE;AAClD,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC;IAElBC,kBAAkB,CAAC,IAAI,EAAE,MAAM;MAC7B,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;AACnC,QAAA,IAAI,CAAC,eAAe,CAACC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AAC/D,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA;AAEAC,EAAAA,MAAMA,CAACC,OAAgB,EAAE,CAACC,QAAQ,CAAmD,EAAE;IACrFC,MAAM,CACJ,sDAAsDD,QAAQ,CAAA,CAAuB,EACrF,OAAOA,QAAQ,KAAK,UACtB,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;AACnC,MAAA,IAAI,CAAC,eAAe,CAACH,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AAC/D,IAAA;IAEA,IAAI,CAAC,eAAe,CAACK,OAAO,CAACH,OAAO,EAAEC,QAAQ,CAAC;AAE/C,IAAA,IAAI,CAAC,SAAS,GAAGA,QAAQ;AACzB,IAAA,IAAI,CAAC,QAAQ,GAAGD,OAAO;AACzB,EAAA;AACF;AAEO,MAAMI,QAAQ,GAAGb;;;;"}
|