ember-primitives 0.48.2 → 0.50.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/bin/index.mjs +271 -0
- package/declarations/components/portal.d.ts.map +1 -1
- package/declarations/components/rating/public-types.d.ts +0 -4
- package/declarations/components/rating/public-types.d.ts.map +1 -1
- package/declarations/components/rating/rating.d.ts +9 -1
- package/declarations/components/rating/rating.d.ts.map +1 -1
- package/declarations/components/rating/stars.d.ts.map +1 -1
- package/declarations/components/rating/state.d.ts +4 -0
- package/declarations/components/rating/state.d.ts.map +1 -1
- package/declarations/components/rating/utils.d.ts +0 -1
- package/declarations/components/rating/utils.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 -8
- 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-BrIiwDLw.js +152 -0
- package/dist/rating-BrIiwDLw.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 +24 -20
- package/src/-private.ts +4 -0
- package/src/color-scheme.ts +165 -0
- package/src/components/-private/typed-elements.gts +13 -0
- package/src/components/-private/utils.ts +16 -0
- package/src/components/accordion/content.gts +34 -0
- package/src/components/accordion/header.gts +36 -0
- package/src/components/accordion/item.gts +55 -0
- package/src/components/accordion/public.ts +64 -0
- package/src/components/accordion/trigger.gts +32 -0
- package/src/components/accordion.gts +195 -0
- package/src/components/avatar.gts +108 -0
- package/src/components/dialog.gts +234 -0
- package/src/components/external-link.gts +14 -0
- package/src/components/form.gts +75 -0
- package/src/components/heading.gts +36 -0
- package/src/components/keys.gts +53 -0
- package/src/components/layout/hero.css +5 -0
- package/src/components/layout/hero.gts +17 -0
- package/src/components/layout/sticky-footer.css +9 -0
- package/src/components/layout/sticky-footer.gts +40 -0
- package/src/components/link.gts +172 -0
- package/src/components/menu.gts +373 -0
- package/src/components/one-time-password/buttons.gts +31 -0
- package/src/components/one-time-password/input.gts +198 -0
- package/src/components/one-time-password/otp.gts +130 -0
- package/src/components/one-time-password/utils.ts +201 -0
- package/src/components/one-time-password.gts +2 -0
- package/src/components/popover.gts +248 -0
- package/src/components/portal-targets.gts +136 -0
- package/src/components/portal.gts +194 -0
- package/src/components/progress.gts +154 -0
- package/src/components/rating/public-types.ts +44 -0
- package/src/components/rating/range.gts +22 -0
- package/src/components/rating/rating.gts +228 -0
- package/src/components/rating/stars.gts +60 -0
- package/src/components/rating/state.gts +144 -0
- package/src/components/rating/utils.ts +7 -0
- package/src/components/rating.gts +5 -0
- package/src/components/scroller.gts +179 -0
- package/src/components/shadowed.gts +110 -0
- package/src/components/switch.gts +103 -0
- package/src/components/tabs.gts +519 -0
- package/src/components/toggle-group.gts +265 -0
- package/src/components/toggle.gts +81 -0
- package/src/components/violations.css +105 -0
- package/src/components/violations.css.ts +1 -0
- package/src/components/visually-hidden.css +14 -0
- package/src/components/visually-hidden.gts +15 -0
- package/src/components/zoetrope/index.gts +358 -0
- package/src/components/zoetrope/styles.css +40 -0
- package/src/components/zoetrope/types.ts +65 -0
- package/src/components/zoetrope.ts +3 -0
- package/src/dom-context.gts +245 -0
- package/src/floating-ui/component.gts +186 -0
- package/src/floating-ui/middleware.ts +13 -0
- package/src/floating-ui/modifier.ts +183 -0
- package/src/floating-ui.ts +2 -0
- package/src/head.gts +37 -0
- package/src/helpers/body-class.ts +94 -0
- package/src/helpers/link.ts +125 -0
- package/src/helpers/service.ts +25 -0
- package/src/helpers.ts +2 -0
- package/src/iframe.ts +31 -0
- package/src/index.ts +43 -0
- package/src/load.gts +77 -0
- package/src/narrowing.ts +7 -0
- package/src/on-resize.ts +64 -0
- package/src/proper-links.ts +140 -0
- package/src/qp.ts +107 -0
- package/src/resize-observer.ts +132 -0
- package/src/service.ts +103 -0
- package/src/store.ts +72 -0
- package/src/styles.css.ts +5 -0
- package/src/tabster.ts +54 -0
- package/src/template-registry.ts +44 -0
- package/src/test-support/a11y.ts +50 -0
- package/src/test-support/dom.ts +112 -0
- package/src/test-support/otp.ts +64 -0
- package/src/test-support/rating.ts +144 -0
- package/src/test-support/routing.ts +62 -0
- package/src/test-support/zoetrope.ts +51 -0
- package/src/test-support.gts +6 -0
- package/src/type-utils.ts +1 -0
- package/src/utils.ts +75 -0
- package/src/viewport/in-viewport.gts +128 -0
- package/src/viewport/viewport.ts +122 -0
- package/src/viewport.ts +2 -0
- 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 +0 -149
- package/dist/rating-D052JWRa.js.map +0 -1
- package/dist/utils-C5796IKA.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { assert } from '@ember/debug';
|
|
3
2
|
import { schedule } from '@ember/runloop';
|
|
4
3
|
import { buildWaiter } from '@ember/test-waiters';
|
|
@@ -10,7 +9,6 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
10
9
|
import { setComponentTemplate } from '@ember/component';
|
|
11
10
|
import templateOnly from '@ember/component/template-only';
|
|
12
11
|
|
|
13
|
-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
14
12
|
/**
|
|
15
13
|
* Polyfill for ember-wormhole behavior
|
|
16
14
|
*
|
|
@@ -38,9 +36,7 @@ function wormhole(query) {
|
|
|
38
36
|
return found;
|
|
39
37
|
}
|
|
40
38
|
const anchor = modifier((element, [to, update]) => {
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
42
39
|
const found = findNearestTarget(element, to);
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
44
40
|
update(found);
|
|
45
41
|
});
|
|
46
42
|
const ElementValue = () => cell();
|
|
@@ -62,7 +58,7 @@ function wormholeCompat(selector) {
|
|
|
62
58
|
});
|
|
63
59
|
}
|
|
64
60
|
resourceFactory(wormholeCompat);
|
|
65
|
-
const Portal = setComponentTemplate(precompileTemplate("
|
|
61
|
+
const Portal = setComponentTemplate(precompileTemplate("{{#if (isElement @to)}}\n <ToElement @to={{@to}} @append={{@append}}>\n {{yield}}\n </ToElement>\n{{else if @wormhole}}\n {{#let (wormholeCompat @wormhole) as |target|}}\n {{#if target}}\n {{#in-element target insertBefore=null}}\n {{yield}}\n {{/in-element}}\n {{/if}}\n {{/let}}\n{{else if @to}}\n <Nestable @to={{@to}} @append={{@append}}>\n {{yield}}\n </Nestable>\n{{else}}\n {{assert \"either @to or @wormhole is required. Received neither\"}}\n{{/if}}", {
|
|
66
62
|
strictMode: true,
|
|
67
63
|
scope: () => ({
|
|
68
64
|
isElement,
|
|
@@ -72,10 +68,10 @@ const Portal = setComponentTemplate(precompileTemplate("\n {{#if (isElement @to
|
|
|
72
68
|
assert
|
|
73
69
|
})
|
|
74
70
|
}), templateOnly());
|
|
75
|
-
const ToElement = setComponentTemplate(precompileTemplate("
|
|
71
|
+
const ToElement = setComponentTemplate(precompileTemplate("{{#if @append}}\n {{#in-element @to insertBefore=null}}\n {{yield}}\n {{/in-element}}\n{{else}}\n {{#in-element @to}}\n {{yield}}\n {{/in-element}}\n{{/if}}", {
|
|
76
72
|
strictMode: true
|
|
77
73
|
}), templateOnly());
|
|
78
|
-
const Nestable = setComponentTemplate(precompileTemplate("
|
|
74
|
+
const Nestable = setComponentTemplate(precompileTemplate("{{#let (ElementValue) as |target|}}\n {{!-- This div is always going to be empty,\n because it'll either find the portal and render content elsewhere,\n it it won't find the portal and won't render anything.\n --}}\n {{!-- template-lint-disable no-inline-styles --}}\n <div style=\"display:contents;\" {{anchor @to target.set}}>\n {{#if target.current}}\n {{#if @append}}\n {{#in-element target.current insertBefore=null}}\n {{yield}}\n {{/in-element}}\n {{else}}\n {{#in-element target.current}}\n {{yield}}\n {{/in-element}}\n {{/if}}\n {{/if}}\n </div>\n{{/let}}", {
|
|
79
75
|
strictMode: true,
|
|
80
76
|
scope: () => ({
|
|
81
77
|
ElementValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"portal.js","sources":["../../src/components/portal.gts"],"sourcesContent":["import { assert } from \"@ember/debug\";\nimport { schedule } from \"@ember/runloop\";\nimport { buildWaiter } from \"@ember/test-waiters\";\n\nimport { modifier } from \"ember-modifier\";\nimport { cell, resource, resourceFactory } from \"ember-resources\";\n\nimport { isElement } from \"../narrowing.ts\";\nimport { findNearestTarget, type TARGETS } from \"./portal-targets.gts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\n\ntype Targets = (typeof TARGETS)[keyof typeof TARGETS];\n\ninterface ToSignature {\n Args: {\n to: string;\n append?: boolean;\n };\n Blocks: {\n default: [];\n };\n}\ninterface ElementSignature {\n Args: {\n to: Element;\n append?: boolean;\n };\n Blocks: {\n default: [];\n };\n}\n\nexport interface Signature {\n Args: {\n /**\n * The name of the PortalTarget to render in to.\n * This is the value of the `data-portal-name` attribute\n * of the element you wish to render in to.\n *\n * This can also be an Element which pairs nicely with query-utilities such as the platform-native `querySelector`\n */\n to?: (Targets | (string & {})) | Element;\n\n /**\n * Set to true to append to the portal instead of replace\n *\n * Default: false\n */\n append?: boolean;\n /**\n * For ember-wormhole style behavior, this argument may be an id,\n * or a selector.\n * This can also be an element, in which case the behavior is identical to `@to`\n */\n wormhole?: string | Element;\n };\n Blocks: {\n /**\n * The portaled content\n */\n default: [];\n };\n}\n\n/**\n * Polyfill for ember-wormhole behavior\n *\n * Example usage:\n * ```gjs\n * import { wormhole, Portal } from 'ember-primitives/components/portal';\n *\n * <template>\n * <div id=\"the-portal\"></div>\n *\n * <Portal @to={{wormhole \"the-portal\"}}>\n * content renders in the above div\n * </Portal>\n * </template>\n *\n * ```\n */\nexport function wormhole(query: string | null | undefined | Element) {\n assert(`Expected query/element to be truthy.`, query);\n\n if (isElement(query)) {\n return query;\n }\n\n let found = document.getElementById(query);\n\n found ??= document.querySelector(query);\n\n return found;\n}\n\nconst anchor = modifier(\n (element: Element, [to, update]: [string, ReturnType<typeof ElementValue>[\"set\"]]) => {\n const found = findNearestTarget(element, to);\n\n update(found);\n },\n);\n\nconst ElementValue = () => cell<Element | ShadowRoot | null | undefined>();\n\nconst waiter = buildWaiter(\"ember-primitives:portal\");\n\nfunction wormholeCompat(selector: string | Element) {\n const target = wormhole(selector);\n\n if (target) return target;\n\n return resource(() => {\n const target = cell<Element | undefined | null>();\n\n const token = waiter.beginAsync();\n\n // eslint-disable-next-line ember/no-runloop\n schedule(\"afterRender\", () => {\n const result = wormhole(selector);\n\n waiter.endAsync(token);\n target.current = result;\n assert(\n `Could not find element with id/selector \\`${typeof selector === \"string\" ? selector : \"<Element>\"}\\``,\n result,\n );\n });\n\n return () => target.current;\n });\n}\n\nresourceFactory(wormholeCompat);\n\nexport const Portal: TOC<Signature> = <template>\n {{#if (isElement @to)}}\n <ToElement @to={{@to}} @append={{@append}}>\n {{yield}}\n </ToElement>\n {{else if @wormhole}}\n {{#let (wormholeCompat @wormhole) as |target|}}\n {{#if target}}\n {{#in-element target insertBefore=null}}\n {{yield}}\n {{/in-element}}\n {{/if}}\n {{/let}}\n {{else if @to}}\n <Nestable @to={{@to}} @append={{@append}}>\n {{yield}}\n </Nestable>\n {{else}}\n {{assert \"either @to or @wormhole is required. Received neither\"}}\n {{/if}}\n</template>;\n\nconst ToElement: TOC<ElementSignature> = <template>\n {{#if @append}}\n {{#in-element @to insertBefore=null}}\n {{yield}}\n {{/in-element}}\n {{else}}\n {{#in-element @to}}\n {{yield}}\n {{/in-element}}\n {{/if}}\n</template>;\n\nconst Nestable: TOC<ToSignature> = <template>\n {{#let (ElementValue) as |target|}}\n {{! This div is always going to be empty,\n because it'll either find the portal and render content elsewhere,\n it it won't find the portal and won't render anything.\n }}\n {{! template-lint-disable no-inline-styles }}\n <div style=\"display:contents;\" {{anchor @to target.set}}>\n {{#if target.current}}\n {{#if @append}}\n {{#in-element target.current insertBefore=null}}\n {{yield}}\n {{/in-element}}\n {{else}}\n {{#in-element target.current}}\n {{yield}}\n {{/in-element}}\n {{/if}}\n {{/if}}\n </div>\n {{/let}}\n</template>;\n\nexport default Portal;\n"],"names":["wormhole","query","assert","isElement","found","document","getElementById","querySelector","anchor","modifier","element","to","update","findNearestTarget","ElementValue","cell","waiter","buildWaiter","wormholeCompat","selector","target","resource","token","beginAsync","schedule","result","endAsync","current","resourceFactory","Portal","setComponentTemplate","precompileTemplate","strictMode","scope","ToElement","Nestable","templateOnly"],"mappings":";;;;;;;;;;;AAiEA;;;;;;;;;;;;;;;;;AAiBO,SAASA,QAAAA,CAASC,KAA0C,EAAA;AACjEC,EAAAA,MAAA,CAAO,CAAA,oCAAA,CAAsC,EAAED,KAAA,CAAA;AAE/C,EAAA,IAAIE,UAAUF,KAAA,CAAA,EAAQ;AACpB,IAAA,OAAOA,KAAA;AACT,EAAA;AAEA,EAAA,IAAIG,KAAA,GAAQC,QAAA,CAASC,cAAc,CAACL,KAAA,CAAA;AAEpCG,EAAAA,KAAA,KAAUC,QAAA,CAASE,aAAa,CAACN,KAAA,CAAA;AAEjC,EAAA,OAAOG,KAAA;AACT;AAEA,MAAMI,MAAA,GAASC,QAAA,CACb,CAACC,OAAS,EAAS,CAACC,EAAA,EAAIC,MAAA,CAAyD,KAAA;AAC/E,EAAA,MAAMR,KAAA,GAAQS,kBAAkBH,OAAA,EAASC,EAAA,CAAA;EAEzCC,MAAA,CAAOR,KAAA,CAAA;AACT,CAAA,CAAA;AAGF,MAAMU,eAAeA,MAAMC,IAAA,EAA4C;AAEvE,MAAMC,SAASC,WAAA,CAAY,yBAAA,CAAA;AAE3B,SAASC,cAAAA,CAAeC,QAA0B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AA4B,YAAA,EAAA,CAAA;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { hash } from '@ember/helper';
|
|
4
3
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
@@ -33,7 +32,7 @@ function getValue(userValue, maxValue) {
|
|
|
33
32
|
function getValueLabel(value, max) {
|
|
34
33
|
return `${Math.round(value / max * 100)}%`;
|
|
35
34
|
}
|
|
36
|
-
const Indicator = setComponentTemplate(precompileTemplate("
|
|
35
|
+
const Indicator = setComponentTemplate(precompileTemplate("<div ...attributes data-max={{@max}} data-value={{@value}} data-state={{progressState @value @max}} data-percent={{@percent}}>\n {{yield}}\n</div>", {
|
|
37
36
|
strictMode: true,
|
|
38
37
|
scope: () => ({
|
|
39
38
|
progressState
|
|
@@ -56,7 +55,7 @@ class Progress extends Component {
|
|
|
56
55
|
return Math.round(this.decimal * 100 * 100) / 100;
|
|
57
56
|
}
|
|
58
57
|
static {
|
|
59
|
-
setComponentTemplate(precompileTemplate("
|
|
58
|
+
setComponentTemplate(precompileTemplate("<div ...attributes aria-valuemax={{this.max}} aria-valuemin=\"0\" aria-valuenow={{this.value}} aria-valuetext={{this.valueLabel}} role=\"progressbar\" data-value={{this.value}} data-state={{progressState this.value this.max}} data-max={{this.max}} data-min=\"0\" data-percent={{this.percent}}>\n\n {{yield (hash Indicator=(component Indicator value=this.value max=this.max percent=this.percent) value=this.value percent=this.percent decimal=this.decimal)}}\n</div>", {
|
|
60
59
|
strictMode: true,
|
|
61
60
|
scope: () => ({
|
|
62
61
|
progressState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"progress.js","sources":["../../src/components/progress.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\nimport { hash } from \"@ember/helper\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type { WithBoundArgs } from \"@glint/template\";\n\nexport interface Signature {\n Element: HTMLDivElement;\n Args: {\n /**\n * The current progress\n * This may be less than 0 or more than `max`,\n * but the resolved value (managed internally, and yielded out)\n * does not exceed the range [0, max]\n */\n value: number;\n /**\n * The max value, defaults to 100\n */\n max?: number;\n };\n Blocks: {\n default: [\n {\n /**\n * The indicator element with some state applied.\n * This can be used to style the progress of bar.\n */\n Indicator: WithBoundArgs<typeof Indicator, \"value\" | \"max\" | \"percent\">;\n /**\n * The value as a percent of how far along the indicator should be\n * positioned, between 0 and 100.\n * Will be rounded to two decimal places.\n */\n percent: number;\n /**\n * The value as a percent of how far along the indicator should be positioned,\n * between 0 and 1\n */\n decimal: number;\n /**\n * The resolved value within the limits of the progress bar.\n */\n value: number;\n },\n ];\n };\n}\n\ntype ProgressState = \"indeterminate\" | \"complete\" | \"loading\";\n\nconst DEFAULT_MAX = 100;\n\n/**\n * Non-negative, non-NaN, non-Infinite, positive, rational\n */\nfunction isValidProgressNumber(value: number | undefined | null): value is number {\n if (typeof value !== \"number\") return false;\n if (!Number.isFinite(value)) return false;\n\n return value >= 0;\n}\n\nfunction progressState(value: number | undefined | null, maxValue: number): ProgressState {\n return value == null ? \"indeterminate\" : value === maxValue ? \"complete\" : \"loading\";\n}\n\nfunction getMax(userMax: number | undefined | null): number {\n return isValidProgressNumber(userMax) ? userMax : DEFAULT_MAX;\n}\n\nfunction getValue(userValue: number | undefined | null, maxValue: number): number {\n const max = getMax(maxValue);\n\n if (!isValidProgressNumber(userValue)) {\n return 0;\n }\n\n if (userValue > max) {\n return max;\n }\n\n return userValue;\n}\n\nfunction getValueLabel(value: number, max: number) {\n return `${Math.round((value / max) * 100)}%`;\n}\n\nconst Indicator: TOC<{\n Element: HTMLDivElement;\n Args: { max: number; value: number; percent: number };\n Blocks: { default: [] };\n}> = <template>\n <div\n ...attributes\n data-max={{@max}}\n data-value={{@value}}\n data-state={{progressState @value @max}}\n data-percent={{@percent}}\n >\n {{yield}}\n </div>\n</template>;\n\nexport class Progress extends Component<Signature> {\n get max() {\n return getMax(this.args.max);\n }\n\n get value() {\n return getValue(this.args.value, this.max);\n }\n\n get valueLabel() {\n return getValueLabel(this.value, this.max);\n }\n\n get decimal() {\n return this.value / this.max;\n }\n\n get percent() {\n return Math.round(this.decimal * 100 * 100) / 100;\n }\n\n <template>\n <div\n ...attributes\n aria-valuemax={{this.max}}\n aria-valuemin=\"0\"\n aria-valuenow={{this.value}}\n aria-valuetext={{this.valueLabel}}\n role=\"progressbar\"\n data-value={{this.value}}\n data-state={{progressState this.value this.max}}\n data-max={{this.max}}\n data-min=\"0\"\n data-percent={{this.percent}}\n >\n\n {{yield\n (hash\n Indicator=(component Indicator value=this.value max=this.max percent=this.percent)\n value=this.value\n percent=this.percent\n decimal=this.decimal\n )\n }}\n </div>\n </template>\n}\n\nexport default Progress;\n"],"names":["DEFAULT_MAX","isValidProgressNumber","value","Number","isFinite","progressState","maxValue","getMax","userMax","getValue","userValue","max","getValueLabel","Math","round","Indicator","setComponentTemplate","precompileTemplate","strictMode","scope","templateOnly","Progress","Component","args","valueLabel","decimal","percent","hash"],"mappings":";;;;;;AAmDA,MAAMA,WAAA,GAAc,GAAA;AAEpB;;;AAGA,SAASC,qBAAAA,CAAsBC,KAAgC,EAAkB;AAC/E,EAAA,IAAI,OAAOA,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;EACtC,IAAI,CAACC,MAAA,CAAOC,QAAQ,CAACF,QAAQ,OAAO,KAAA;EAEpC,OAAOA,KAAA,IAAS,CAAA;AAClB;AAEA,SAASG,aAAAA,CAAcH,KAAgC,EAAEI,QAAgB,EAAG;AAC1E,EAAA,OAAOJ,KAAA,IAAS,IAAA,GAAO,eAAA,GAAkBA,KAAA,KAAUI,WAAW,UAAA,GAAa,SAAA;AAC7E;AAEA,SAASC,MAAAA,CAAOC,OAAkC,EAAS;AACzD,EAAA,OAAOP,qBAAA,CAAsBO,WAAWA,OAAA,GAAUR,WAAA;AACpD;AAEA,SAASS,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AAA,GAAO,GAAA;AAChD,EAAA;AAEA,EAAA;IAAAT,oBAAA,CAAAC,kBAAA,CAAA,mdAAA,EAwBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAd,aAAA;QAAAsB,IAAA;AAAAZ,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 { isDestroyed, isDestroying } from '@ember/destroyable';
|
|
4
3
|
import { hash } from '@ember/helper';
|
|
@@ -60,7 +59,7 @@ class Scroller extends Component {
|
|
|
60
59
|
});
|
|
61
60
|
};
|
|
62
61
|
static {
|
|
63
|
-
setComponentTemplate(precompileTemplate("
|
|
62
|
+
setComponentTemplate(precompileTemplate("<div tabindex=\"0\" ...attributes {{this.ref}}>\n {{yield (hash scrollToBottom=this.scrollToBottom scrollToTop=this.scrollToTop scrollToLeft=this.scrollToLeft scrollToRight=this.scrollToRight)}}\n</div>", {
|
|
64
63
|
strictMode: true,
|
|
65
64
|
scope: () => ({
|
|
66
65
|
hash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroller.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"scroller.js","sources":["../../src/components/scroller.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\nimport { isDestroyed, isDestroying } from \"@ember/destroyable\";\nimport { hash } from \"@ember/helper\";\n\nimport { modifier } from \"ember-modifier\";\n\n/**\n * Utility component for helping with scrolling in any direction within\n * any of the 4 directions: up, down, left, right.\n *\n * This can be used to auto-scroll content as new content is inserted into the scrollable area, or possibly to bring focus to something on the page.\n */\nexport class Scroller extends Component<{\n /**\n * A containing element is required - in this case, a div.\n * It must be scrollable for this component to work, but can be customized.\n *\n * By default, this element will have some styling applied:\n * overflow: auto;\n *\n * By default, this element will have tabindex=\"0\" to support keyboard usage.\n *\n * The scroll-behavior is \"auto\", which can be controlled via CSS\n * https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior\n *\n */\n Element: HTMLDivElement;\n Blocks: {\n default: [\n {\n /**\n * Scroll the content to the bottom\n *\n * ```gjs\n * import { Scroller } from 'ember-primitives';\n *\n * <template>\n * <Scroller as |s|>\n * ...\n *\n * {{ (s.scrollToBottom) }}\n * </Scroller>\n * </template>\n * ```\n */\n scrollToBottom: () => void;\n /**\n * Scroll the content to the top\n *\n * ```gjs\n * import { Scroller } from 'ember-primitives';\n *\n * <template>\n * <Scroller as |s|>\n * ...\n *\n * {{ (s.scrollToTop) }}\n * </Scroller>\n * </template>\n * ```\n */\n scrollToTop: () => void;\n /**\n * Scroll the content to the left\n *\n * ```gjs\n * import { Scroller } from 'ember-primitives';\n *\n * <template>\n * <Scroller as |s|>\n * ...\n *\n * {{ (s.scrollToLeft) }}\n * </Scroller>\n * </template>\n * ```\n */\n scrollToLeft: () => void;\n /**\n * Scroll the content to the right\n *\n * ```gjs\n * import { Scroller } from 'ember-primitives';\n *\n * <template>\n * <Scroller as |s|>\n * ...\n *\n * {{ (s.scrollToRight) }}\n * </Scroller>\n * </template>\n * ```\n */\n scrollToRight: () => void;\n },\n ];\n };\n}> {\n declare withinElement: HTMLDivElement;\n\n ref = modifier((el: HTMLDivElement) => {\n this.withinElement = el;\n });\n\n #frame?: number;\n\n scrollToBottom = () => {\n if (this.#frame) {\n cancelAnimationFrame(this.#frame);\n }\n\n this.#frame = requestAnimationFrame(() => {\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this.withinElement.scrollTo({\n top: this.withinElement.scrollHeight,\n behavior: \"auto\",\n });\n });\n };\n\n scrollToTop = () => {\n if (this.#frame) {\n cancelAnimationFrame(this.#frame);\n }\n\n this.#frame = requestAnimationFrame(() => {\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this.withinElement.scrollTo({\n top: 0,\n behavior: \"auto\",\n });\n });\n };\n\n scrollToLeft = () => {\n if (this.#frame) {\n cancelAnimationFrame(this.#frame);\n }\n\n this.#frame = requestAnimationFrame(() => {\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this.withinElement.scrollTo({\n left: 0,\n behavior: \"auto\",\n });\n });\n };\n\n scrollToRight = () => {\n if (this.#frame) {\n cancelAnimationFrame(this.#frame);\n }\n\n this.#frame = requestAnimationFrame(() => {\n if (isDestroyed(this) || isDestroying(this)) return;\n\n this.withinElement.scrollTo({\n left: this.withinElement.scrollWidth,\n behavior: \"auto\",\n });\n });\n };\n\n <template>\n <div tabindex=\"0\" ...attributes {{this.ref}}>\n {{yield\n (hash\n scrollToBottom=this.scrollToBottom\n scrollToTop=this.scrollToTop\n scrollToLeft=this.scrollToLeft\n scrollToRight=this.scrollToRight\n )\n }}\n </div>\n </template>\n}\n"],"names":["Scroller","Component","ref","modifier","el","withinElement","scrollToBottom","cancelAnimationFrame","requestAnimationFrame","isDestroyed","isDestroying","scrollTo","top","scrollHeight","behavior","scrollToTop","scrollToLeft","left","scrollToRight","scrollWidth","setComponentTemplate","precompileTemplate","strictMode","scope","hash"],"mappings":";;;;;;;AAYO,MAAMA,QAAA,SAAiBC,SAAA;AAwF5BC,EAAAA,GAAA,GAAMC,QAAA,CAAUC,EAAI,IAAA;IAClB,IAAI,CAACC,aAAa,GAAGD,EAAA;AACvB,EAAA,CAAA,CAAA;AAEA,EAAA,MAAM;EAENE,cAAA,GAAiBA,MAAA;AACf,IAAA,IAAI,IAAI,CAAC,MAAM,EAAE;AACfC,MAAAA,oBAAA,CAAqB,IAAI,CAAC,MAAM,CAAA;AAClC,IAAA;AAEA,IAAA,IAAI,CAAC,MAAM,GAAGC,qBAAA,CAAsB,MAAA;MAClC,IAAIC,WAAA,CAAY,IAAI,CAAA,IAAKC,YAAA,CAAa,IAAI,CAAA,EAAG;AAE7C,MAAA,IAAI,CAACL,aAAa,CAACM,QAAQ,CAAC;AAC1BC,QAAAA,GAAA,EAAK,IAAI,CA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AI,CAACL,aAAa,CAACM,QAAQ,CAAC;AAC1BM,QAAAA,IAAA,EAAM,IAAI,CAACZ,aAAa,CAACc,WAAW;AACpCL,QAAAA,QAAA,EAAU;AACZ,OAAA,CAAA;AACF,IAAA,CAAA,CAAA;EACF,CAAA;AAEA,EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,6MAAA,EAWA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,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 { precompileTemplate } from '@ember/template-compilation';
|
|
4
3
|
import { setComponentTemplate } from '@ember/component';
|
|
@@ -11,7 +10,7 @@ const getStyles = () => [...document.querySelectorAll("link")].map(link => link.
|
|
|
11
10
|
*
|
|
12
11
|
* link is only valid in the head element.
|
|
13
12
|
*/
|
|
14
|
-
const Styles = setComponentTemplate(precompileTemplate("
|
|
13
|
+
const Styles = setComponentTemplate(precompileTemplate("<style>\n {{#each (getStyles) as |styleHref|}}\n\n @import \"{{styleHref}}\";\n\n {{/each}}\n</style>", {
|
|
15
14
|
strictMode: true,
|
|
16
15
|
scope: () => ({
|
|
17
16
|
getStyles
|
|
@@ -64,7 +63,7 @@ class Shadowed extends Component {
|
|
|
64
63
|
this.shadow = div;
|
|
65
64
|
}
|
|
66
65
|
static {
|
|
67
|
-
setComponentTemplate(precompileTemplate("
|
|
66
|
+
setComponentTemplate(precompileTemplate("<div ...attributes>{{this.host}}</div>\n\n{{#in-element this.shadow}}\n\n {{#if @includeStyles}}\n <Styles />\n {{/if}}\n\n {{yield}}\n\n{{/in-element}}", {
|
|
68
67
|
strictMode: true,
|
|
69
68
|
scope: () => ({
|
|
70
69
|
Styles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadowed.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"shadowed.js","sources":["../../src/components/shadowed.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\n\nimport type Owner from \"@ember/owner\";\n\n// index.html has the production-fingerprinted references to these links\n// Ideally, we'd have some pre-processor scan everything for references to\n// assets in public, but idk how to set that up\nconst getStyles = () => [...document.querySelectorAll(\"link\")].map((link) => link.href);\n\n/**\n * style + native @import\n * is the only robust way to load styles in a shadowroot.\n *\n * link is only valid in the head element.\n */\nconst Styles = <template>\n <style>\n {{#each (getStyles) as |styleHref|}}\n\n @import \"{{styleHref}}\";\n\n {{/each}}\n </style>\n</template>;\n\n/**\n * Render content in a shadow dom, attached to a div.\n *\n * Uses the [shadow DOM][mdn-shadow-dom] API.\n *\n * [mdn-shadow-dom]: https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM\n *\n * This is useful when you want to render content that escapes your app's styles.\n */\nexport class Shadowed extends Component<{\n /**\n * The shadow dom attaches to a div element.\n * You may specify any attribute, and it'll be applied to this host element.\n */\n Element: HTMLDivElement;\n Args: {\n /**\n * @public\n *\n * By default, shadow-dom does not include any styles.\n * Setting this to true will include all the `<style>` tags\n * that are present in the `<head>` element.\n */\n includeStyles?: boolean;\n };\n Blocks: {\n /**\n * Content to be placed within the ShadowDOM\n */\n default: [];\n };\n}> {\n shadow: HTMLDivElement;\n host: HTMLDivElement;\n /**\n * ember-source 5.6 broke the ability to in-element\n * natively into a shadowroot.\n *\n * We have two or three more dives than we should have here.\n *\n *\n * See these ember-source bugs:\n * - https://github.com/emberjs/ember.js/issues/20643\n * - https://github.com/emberjs/ember.js/issues/20642\n * - https://github.com/emberjs/ember.js/issues/20641\n *\n * Ideally, shadowdom should be built in.\n * Couple paths forward:\n * - (as the overall template tag)\n * <template shadowrootmode=\"open\">\n * </template>\n *\n * - Build a component into the framework that does the above ^\n * - add additional parsing in content-tag to allow\n * nested <template>\n *\n */\n constructor(owner: Owner, args: { includeStyles?: boolean }) {\n super(owner, args);\n\n const element = document.createElement(\"div\");\n const shadowRoot = element.attachShadow({ mode: \"open\" });\n const div = document.createElement(\"div\");\n\n shadowRoot.appendChild(div);\n this.host = element;\n this.shadow = div;\n }\n\n <template>\n <div ...attributes>{{this.host}}</div>\n\n {{#in-element this.shadow}}\n\n {{#if @includeStyles}}\n <Styles />\n {{/if}}\n\n {{yield}}\n\n {{/in-element}}\n </template>\n}\n\nexport default Shadowed;\n"],"names":["getStyles","document","querySelectorAll","map","link","href","Styles","setComponentTemplate","precompileTemplate","strictMode","scope","templateOnly","Shadowed","Component","shadow","host","constructor","owner","args","element","createElement","shadowRoot","attachShadow","mode","div","appendChild"],"mappings":";;;;;AAOA,MAAMA,YAAYA,MAAM,CAAI,GAAAC,QAAA,CAASC,gBAAgB,CAAC,MAAA,CAAA,CAAQ,CAACC,GAAG,CAAEC,IAAA,IAASA,KAAKC,IAAI,CAAA;AAEtF;;;;;;AAMA,MAAMC,MAAA,GAAAC,oBAAA,CAASC,kBAAA,CAAA,4GAAA,EAQf;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAV,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAW,YAAA,EAAA,CAAA;AAEV;;;;;;;;;AASO,MAAMC,QAAA,SAAiBC,SAAA;EAuB5BC,MAAA;EACAC,IAAA;AACA;;;;;;;;;;;;;;;;;;;;;;;AAuBAC,EAAAA,WAAAA,CAAYC,KAAY,EAAEC,IAAiC,EAAE;AAC3D,IAAA,KAAK,CAACD,KAAA,EAAOC,IAAA,CAAA;AAEb,IAAA,MAAMC,OAAA,GAAUlB,QAAA,CAASmB,aAAa,CAAC,KAAA,CAAA;AACvC,IAAA,MAAMC,UAAA,GAAaF,OAAA,CAAQG,YAAY,CAAC;AAAEC,MAAAA,IAAA,EAAM;AAAO,KAAA,CAAA;AACvD,IAAA,MAAMC,GAAA,GAAMvB,QAAA,CAASmB,aAAa,CAAC,KAAA,CAAA;AAEnCC,IAAAA,UAAA,CAAWI,WAAW,CAACD,GAAA,CAAA;IACvB,IAAI,CAACT,IAAI,GAAGI,OAAA;IACZ,IAAI,CAACL,MAAM,GAAGU,GAAA;AAChB,EAAA;AAEA,EAAA;IAAAjB,oBAAA,CAAAC,kBAAA,CAAA,gKAAA,EAYA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAJ,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -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;AAGF,MAAMC,OAeD,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,8GAAA,EAIL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;AAUV,MAAMC,SAiCD,GAAAJ,oBAAA,CAAAC,kBAAA,CAAA,kVAAA,EAeL;EAAAC,UAAA,EAAA,IAAA;AAAAG,EAAAA,KAAA,EAAAA,OAAA;IAAAC,MAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAJ,YAAA,EAAA,CAAA;AAaV,MAAMK,UAqBD,GAAAR,oBAAA,CAAAC,kBAAA,C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IAEA,OAAO,IAAI,CAACyD,MAAM;AACpB,EAAA;AAEAU,EAAAA,YAAA,GAAeA,CAAClC,KAAa,EAAEsB,QAA4B,KAAA;AACzD,IAAA,MAAMa,QAAA,GAAW,IAAI,CAACX,MAAM;AAC5B,IAAA,MAAME,OAAOJ,QAAA,IAAYtB,KAAA;AAEzB;IACA,IAAI0B,SAASS,QAAA,EAAU;AAEvB,IAAA,IAAI,CAACP,OAAO,GAAG,IAAI,CAACG,MAAM,GAAGL,IAAA;AAE7B,IAAA,IAAI,CAACvB,IAAI,CAACiC,QAAQ,GAAGV,IAAA,EAAMS,QAAA,KAAapE,QAAQ,IAAA,GAAOoE,QAAA,CAAA;EACzD,CAAA;AACF;AAEO,MAAME,aAAaxC,SAAA,CAAU;EAClCyC,KAAA;AAEA;AACApB,EAAAA,WAAAA,CAAYqB,KAAY,EAAEpC,IAAQ,EAAE;AAClC,IAAA,KAAK,CAACoC,KAAA,EAAOpC,IAAA,CAAA;AAEb,IAAA,IAAI,CAACmC,KAAK,GAAG,IAAI3B,QAAA,CAASR,IAAA,CAAA;AAC5B,EAAA;AAEA,EAAA;IAAAvB,oBAAA,CAAAC,kBAAA,CAAA,uwBAAA,EAyBA;MAAAC,UAAA,EAAA,IAAA;AAAAG,MAAAA,KAAA,EAAAA,OAAA;QAAAK,QAAA;QAAApB,cAAA;QAAAoC,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","has","delete","add","values"],"mappings":";;;;;;;;;;;AAgBA,MAAMA,iBAAiBC,mBAAA,CACrB;AACEC,EAAAA,KAAA,EAAO;IACLC,SAAA,EAAWC,gBAAgBC,IAAI;AAC/BC,IAAAA,MAAA,EAAQ;AACV;AACF,CAAA,EACA,IAAA,CAAA;AA+IF,SAASC,QAAQC,CAAiC,EAAQ;EACxD,OAAOA,CAAA,KAAM,OAAA;AACf;AAEO,MAAMC,oBAAiCC,SAAA,CACU;AAEtD;AACA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,qVAAA,EAoBA;MAAAC,UAAA,EAAA,IAAA;AAAA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A;AACxB,IAAA;IAEA,IAAIA,iBAAiBW,GAAA,EAAK;AACxB,MAAA,OAAO,IAAIH,UAAA,CAAWR,KAAA,CAAA;AACxB,IAAA;AAEA,IAAA,OAAO,IAAIQ,UAAA,CAAW,CAACR,KAAA,CAAM,CAAA;AAC/B,EAAA;AAAA,EAAA;IAAAY,CAAA,CAAA,IAAA,CAAAhB,SAAA,EAAA,eAAA,EAAA,CAjBCiB,MAAA,CAAA,CAAA;AAAA;EAmBDd,YAAA,GAAgBC,KAAO,IAAA;IACrB,IAAI,IAAI,CAACC,aAAa,CAACa,GAAG,CAACd,KAAA,CAAA,EAAQ;AACjC,MAAA,IAAI,CAACC,aAAa,CAACc,MAAM,CAACf,KAAA,CAAA;AAC5B,IAAA,CAAA,MAAO;AACL,MAAA,IAAI,CAACC,aAAa,CAACe,GAAG,CAAChB,KAAA,CAAA;AACzB,IAAA;AAEA,IAAA,IAAI,CAACG,IAAI,CAACC,QAAQ,GAAG,IAAIO,GAAA,CAAW,IAAI,CAACV,aAAa,CAACgB,MAAM,EAAA,CAAA,CAAA;EAC/D,CAAA;EAEAZ,SAAA,GAAaL,KAAO,IAAU,IAAI,CAACC,aAAa,CAACa,GAAG,CAACd,KAAA,CAAA;AAErD,EAAA;IAAAX,oBAAA,CAAAC,kBAAA,CAAA,6JAAA,EAIA;MAAAC,UAAA,EAAA,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,EAAOJ,IAAA,CAAA;IAEbD,MAAA,CACE,CAAA,gFAAA,CAAkF,EAClF,IAAI,CAACC,IAAI,CAACE,OAAO,KAAKG,SAAA,IACpB,IAAI,CAACL,IAAI,CAACE,OAAO,KAAK,KAAA,IACtB,OAAO,IAAI,CAACF,IAAI,CAACE,OAAO,KAAK,QAAA,CAAA;IAGjC,IAAI,IAAI,CAACI,kBAAkB,EAAE;AAC3B,MAAA,IAAI,CAACJ,OAAO,GAAGK,QAAA,CAASC,aAAa,CAAC,IAAI,CAACR,IAAI,CAACE,OAAO,IAAI,KAAA,CAAA;AAE3D;AACA,MAAA,IAAI,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CAAE,KAAKd,GAAA,EAAK;QACpB,OAAOc,KAAK,CAAC,CAAA,CAAE;AACjB,MAAA;AACF,IAAA;IAEAL,MAAA,GAASA,OAAOO,aAAa;AAC/B,EAAA;AACF;AAUO,MAAMC,OAAA,SAA6ChC,SAAA;;kCAavDiC,OAAA,CAAA,CAAA;AAAA;EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAA,MAAA,EAAA;EAED7B,OAAA;AAEAC,EAAAA,WAAAA,CAAYC,KAAY,EAAEJ,IAAkB,EAAE;AAC5C,IAAA,KAAK,CAACI,KAAA,EAAOJ,IAAA,CAAA;IAEb,IAAI,CAACE,OAAO,GAAGK,QAAA,CAASI,cAAc,CAAC,EAAA,CAAA;AACzC,EAAA;EAEA,IACIqB,OAAAA,GAAU;AACZ;IACA,MAAMC,OAAO,IAAI;IAEjB,OAAO;MACL,IAAInC,IAAAA,GAAwB;AAC1B,QAAA,MAAMoC,OAAA,GAAUf,WAAgBc,IAAA,CAAK/B,OAAO,EAAE+B,IAAA,CAAKjC,IAAI,CAACY,GAAG,CAAA;AAE3Db,QAAAA,MAAA,CACE,CAAA,mJAAA,CAAqJ,EACrJmC,OAAA,CAAA;AAGF;AACA;QACA,OAAOA;AACT,MAAA;KACF;AACF,EAAA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,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,KAAa;AACjB,IAAIC,WAAoB;AAExB,SAASC,WAAWA,GAAG;AACrBD,EAAAA,WAAW,KAAKb,MAAM,CAACe,UAAU,EAAE;EAEnCC,oBAAoB,CAACJ,KAAK,CAAC;EAC3BA,KAAK,GAAGK,qBAAqB,CAAC,MAAM;AAClCC,IAAAA,eAAe,EAAE;AACjBlB,IAAAA,MAAM,CAACmB,QAAQ,CAACN,WAAW,CAAC;AAC5BA,IAAAA,WAAW,GAAGO,SAAS;AACzB,EAAA,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASF,eAAeA,GAAG;AACzB,EAAA,MA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