ember-primitives 0.48.2 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/components/portal.d.ts.map +1 -1
- package/declarations/tabster.d.ts.map +1 -1
- package/declarations/utils.d.ts.map +1 -1
- package/declarations/viewport/in-viewport.d.ts +70 -0
- package/declarations/viewport/in-viewport.d.ts.map +1 -0
- package/declarations/viewport/viewport.d.ts +59 -0
- package/declarations/viewport/viewport.d.ts.map +1 -0
- package/declarations/viewport.d.ts +3 -0
- package/declarations/viewport.d.ts.map +1 -0
- package/dist/-private.js +0 -1
- package/dist/-private.js.map +1 -1
- package/dist/color-scheme.js +0 -1
- package/dist/color-scheme.js.map +1 -1
- package/dist/{component-Bs3N-G9z.js → component-BXy_iafw.js} +2 -3
- package/dist/component-BXy_iafw.js.map +1 -0
- package/dist/components/accordion.js +5 -6
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/avatar.js +3 -4
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/dialog.js +2 -3
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/external-link.js +1 -2
- package/dist/components/external-link.js.map +1 -1
- package/dist/components/form.js +1 -2
- package/dist/components/form.js.map +1 -1
- package/dist/components/heading.js +1 -2
- package/dist/components/heading.js.map +1 -1
- package/dist/components/keys.js +2 -3
- package/dist/components/keys.js.map +1 -1
- package/dist/components/layout/hero.js +1 -1
- package/dist/components/layout/sticky-footer.js +1 -1
- package/dist/components/link.js +1 -2
- package/dist/components/link.js.map +1 -1
- package/dist/components/menu.js +6 -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-D052JWRa.js → rating-CjBVsX6q.js} +5 -6
- package/dist/rating-CjBVsX6q.js.map +1 -0
- package/dist/resize-observer.js +0 -1
- package/dist/resize-observer.js.map +1 -1
- package/dist/service.js +0 -1
- package/dist/service.js.map +1 -1
- package/dist/store.js +0 -1
- package/dist/store.js.map +1 -1
- package/dist/styles.css.js +0 -1
- package/dist/tabster.js +0 -1
- package/dist/tabster.js.map +1 -1
- package/dist/test-support.js +0 -1
- package/dist/test-support.js.map +1 -1
- package/dist/{utils-C5796IKA.js → utils-D0v9WKmV.js} +1 -2
- package/dist/utils-D0v9WKmV.js.map +1 -0
- package/dist/utils.js +4 -1
- package/dist/utils.js.map +1 -1
- package/dist/viewport/in-viewport.js +82 -0
- package/dist/viewport/in-viewport.js.map +1 -0
- package/dist/viewport/viewport.js +92 -0
- package/dist/viewport/viewport.js.map +1 -0
- package/dist/viewport.js +3 -0
- package/dist/viewport.js.map +1 -0
- package/package.json +20 -20
- package/dist/component-Bs3N-G9z.js.map +0 -1
- package/dist/index-DKE67I8L.js.map +0 -1
- package/dist/otp-C6hCCXKx.js.map +0 -1
- package/dist/rating-D052JWRa.js.map +0 -1
- package/dist/utils-C5796IKA.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/components/portal.gts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/components/portal.gts"],"names":[],"mappings":"AA0MA,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAE1D,KAAK,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAqBtD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE;QACJ;;;;;;WAMG;QACH,EAAE,CAAC,EAAE,CAAC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC;QAEzC;;;;WAIG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB;;;;WAIG;QACH,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KAC7B,CAAC;IACF,MAAM,EAAE;QACN;;WAEG;QACH,OAAO,EAAE,EAAE,CAAC;KACb,CAAC;CACH;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,kBAYlE;AA0CD,eAAO,MAAM,MAAM,EAAE,GAAG,CAAC,SAAS,CA+ChC,CAAC;AAkEH,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabster.d.ts","sourceRoot":"","sources":["../src/tabster.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY;AAChC;;;;GAIG;AACH,OAAO,EAAE,MAAM,EACf,EACE,OAAO,EACP,cAAc,GACf,GAAE;IACD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"tabster.d.ts","sourceRoot":"","sources":["../src/tabster.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY;AAChC;;;;GAIG;AACH,OAAO,EAAE,MAAM,EACf,EACE,OAAO,EACP,cAAc,GACf,GAAE;IACD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CACrB,iBAyBP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,wBAAgB,QAAQ,IAAI,MAAM,CAQjC;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,WAAW,CAAC,MAAM,CAAC,CAMtF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,CAI9C;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAKxE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,cAAc,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,wBAAgB,QAAQ,IAAI,MAAM,CAQjC;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,WAAW,CAAC,MAAM,CAAC,CAMtF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,CAI9C;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAKxE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,cAAc,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAiBpE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Component from "@glimmer/component";
|
|
2
|
+
export type InViewportMode = "replace" | "contain";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the InViewport component
|
|
5
|
+
*/
|
|
6
|
+
export interface InViewportSignature {
|
|
7
|
+
Element: HTMLElement;
|
|
8
|
+
Args: {
|
|
9
|
+
/**
|
|
10
|
+
* The tag name for the placeholder element.
|
|
11
|
+
* Can be any valid HTML tag name.
|
|
12
|
+
* Default: 'div'
|
|
13
|
+
*/
|
|
14
|
+
tagName?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The mode determines how yielded content is rendered:
|
|
17
|
+
* - 'replace': yielded content replaces the placeholder element
|
|
18
|
+
* - 'contain': yielded content is rendered within the placeholder
|
|
19
|
+
* Default: 'contain'
|
|
20
|
+
*/
|
|
21
|
+
mode?: InViewportMode;
|
|
22
|
+
};
|
|
23
|
+
Blocks: {
|
|
24
|
+
/**
|
|
25
|
+
* Default block - rendered when the element is in the viewport
|
|
26
|
+
*/
|
|
27
|
+
default: [];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A component that only renders its content when the element is near the viewport.
|
|
32
|
+
*
|
|
33
|
+
* This is useful for deferring the rendering of heavy components until they're
|
|
34
|
+
* actually needed, improving performance for pages with many components.
|
|
35
|
+
*
|
|
36
|
+
* Example usage:
|
|
37
|
+
* ```gjs
|
|
38
|
+
* import { InViewport } from 'ember-primitives';
|
|
39
|
+
*
|
|
40
|
+
* <template>
|
|
41
|
+
* <InViewport>
|
|
42
|
+
* <ExpensiveComponent />
|
|
43
|
+
* </InViewport>
|
|
44
|
+
* </template>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* The component uses the Intersection Observer API to detect when the element
|
|
48
|
+
* is near the viewport. Once detected, the observer is destroyed and the content
|
|
49
|
+
* is rendered permanently.
|
|
50
|
+
*/
|
|
51
|
+
export declare class InViewport extends Component<InViewportSignature> {
|
|
52
|
+
#private;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the element has been detected as in/near the viewport
|
|
55
|
+
*/
|
|
56
|
+
hasIntersected: boolean;
|
|
57
|
+
setupObserver: import("ember-modifier").FunctionBasedModifier<{
|
|
58
|
+
Args: {
|
|
59
|
+
Positional: unknown[];
|
|
60
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
61
|
+
};
|
|
62
|
+
Element: Element;
|
|
63
|
+
}>;
|
|
64
|
+
handle: (entry: IntersectionObserverEntry) => void;
|
|
65
|
+
get mode(): InViewportMode;
|
|
66
|
+
get tagName(): string;
|
|
67
|
+
get hasReachedViewport(): boolean;
|
|
68
|
+
get isReplacing(): boolean;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=in-viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-viewport.d.ts","sourceRoot":"","sources":["../../src/viewport/in-viewport.gts"],"names":[],"mappings":"AAgIA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAS3C,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE;QACJ;;;;WAIG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB;;;;;WAKG;QACH,IAAI,CAAC,EAAE,cAAc,CAAC;KACvB,CAAC;IACF,MAAM,EAAE;QACN;;WAEG;QACH,OAAO,EAAE,EAAE,CAAC;KACb,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,UAAW,SAAQ,SAAS,CAAC,mBAAmB,CAAC;;IAC5D;;OAEG;IACM,cAAc,UAAS;IAMhC,aAAa;;;;;;OAQV;IAEH,MAAM,GAAI,OAAO,yBAAyB,UAMxC;IAEF,IAAI,IAAI,IAAI,cAAc,CAOzB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAED,IAAI,WAAW,IAAI,OAAO,CAEzB;CAmCF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates or returns the ViewportObserverManager.
|
|
3
|
+
*
|
|
4
|
+
* Only one of these will exist per owner.
|
|
5
|
+
*
|
|
6
|
+
* Has only two methods:
|
|
7
|
+
* - observe(element, callback: (intersectionObserverEntry) => void, options?)
|
|
8
|
+
* - unobserve(element, callback: (intersectionObserverEntry) => void)
|
|
9
|
+
*
|
|
10
|
+
* Like with the underlying IntersectionObserver API (and all event listeners),
|
|
11
|
+
* the callback passed to unobserve must be the same reference as the one
|
|
12
|
+
* passed to observe.
|
|
13
|
+
*/
|
|
14
|
+
export declare function viewport(context: object): ViewportObserverManager;
|
|
15
|
+
export interface ViewportOptions {
|
|
16
|
+
/**
|
|
17
|
+
* A margin around the root. Can have values similar to the CSS margin property.
|
|
18
|
+
* The values can be percentages. This set of values serves to grow or shrink each
|
|
19
|
+
* side of the root element's bounding box before computing intersections.
|
|
20
|
+
* Defaults to all zeros.
|
|
21
|
+
*/
|
|
22
|
+
rootMargin?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Either a single number or an array of numbers which indicate at what percentage
|
|
25
|
+
* of the target's visibility the observer's callback should be executed. If you only
|
|
26
|
+
* want to detect when visibility passes the 50% mark, you can use a value of 0.5.
|
|
27
|
+
* If you want the callback to run every time visibility passes another 25%, you would
|
|
28
|
+
* specify the array [0, 0.25, 0.5, 0.75, 1]. The default is 0 (meaning as soon as
|
|
29
|
+
* even one pixel is visible, the callback will be run).
|
|
30
|
+
*/
|
|
31
|
+
threshold?: number | number[];
|
|
32
|
+
}
|
|
33
|
+
declare class ViewportObserverManager {
|
|
34
|
+
#private;
|
|
35
|
+
constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Initiate the observing of the `element` or add an additional `callback`
|
|
38
|
+
* if the `element` is already observed.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} element
|
|
41
|
+
* @param {function} callback The `callback` is called whenever the `element`
|
|
42
|
+
* intersects with the viewport. It is called with an `IntersectionObserverEntry`
|
|
43
|
+
* object for the particular `element`.
|
|
44
|
+
*/
|
|
45
|
+
observe(element: Element, callback: (entry: IntersectionObserverEntry) => unknown): void;
|
|
46
|
+
/**
|
|
47
|
+
* End the observing of the `element` or just remove the provided `callback`.
|
|
48
|
+
*
|
|
49
|
+
* It will unobserve the `element` if the `callback` is not provided
|
|
50
|
+
* or there are no more callbacks left for this `element`.
|
|
51
|
+
*
|
|
52
|
+
* @param {Element | undefined | null} element
|
|
53
|
+
* @param {function?} callback - The `callback` to remove from the listeners
|
|
54
|
+
* of the `element` intersection changes.
|
|
55
|
+
*/
|
|
56
|
+
unobserve(element: Element | undefined | null, callback: (entry: IntersectionObserverEntry) => unknown): void;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../src/viewport/viewport.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,2BAEvC;AAED,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/B;AAED,cAAM,uBAAuB;;;IA8B3B;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,OAAO;IAWjF;;;;;;;;;OASG;IACH,SAAS,CACP,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,OAAO;CAmB1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/-private.js
CHANGED
package/dist/-private.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"-private.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"-private.js","sources":["../src/-private.ts"],"sourcesContent":["/**\n * @internal\n */\nexport const PRIMITIVES = Symbol.for('ember-primitives-globals');\n"],"names":["PRIMITIVES","Symbol","for"],"mappings":"AAAA;AACA;AACA;AACO,MAAMA,UAAU,GAAGC,MAAM,CAACC,GAAG,CAAC,0BAA0B;;;;"}
|
package/dist/color-scheme.js
CHANGED
package/dist/color-scheme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-scheme.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"color-scheme.js","sources":["../src/color-scheme.ts"],"sourcesContent":["import { waitForPromise } from '@ember/test-waiters';\n\nimport { cell } from 'ember-resources';\n\nconst _colorScheme = cell<string | undefined>();\n\nlet callbacks: Set<(colorScheme: string) => void> = new Set();\n\nasync function runCallbacks(theme: string) {\n await Promise.resolve();\n\n for (const callback of callbacks.values()) {\n callback(theme);\n }\n}\n\n/**\n * Object for managing the color scheme\n */\nexport const colorScheme = {\n /**\n * Set's the current color scheme to the passed value\n */\n update: (value: string) => {\n colorScheme.current = value;\n\n void waitForPromise(runCallbacks(value));\n },\n\n on: {\n /**\n * register a function to be called when the color scheme changes.\n */\n update: (callback: (colorScheme: string) => void) => {\n callbacks.add(callback);\n },\n },\n off: {\n /**\n * unregister a function that would have been called when the color scheme changes.\n */\n update: (callback: (colorScheme: string) => void) => {\n callbacks.delete(callback);\n },\n },\n\n /**\n * the current valuel of the \"color scheme\"\n */\n get current(): string | undefined {\n return _colorScheme.current;\n },\n set current(value: string | undefined) {\n _colorScheme.current = value;\n\n if (!value) {\n localPreference.delete();\n\n return;\n }\n\n localPreference.update(value);\n setColorScheme(value);\n },\n};\n\n/**\n * Synchronizes state of `colorScheme` with the users preferences as well as reconciles with previously set theme in local storage.\n *\n * This may only be called once per app.\n */\nexport function sync() {\n /**\n * reset the callbacks\n */\n callbacks = new Set();\n\n /**\n * If local prefs are set, then we don't care what prefers-color-scheme is\n */\n const userPreference = localPreference.read();\n\n if (userPreference) {\n setColorScheme(userPreference);\n _colorScheme.current = userPreference;\n\n return;\n }\n\n if (prefers.dark()) {\n setColorScheme('dark');\n _colorScheme.current = 'dark';\n } else if (prefers.light()) {\n setColorScheme('light');\n _colorScheme.current = 'light';\n }\n}\n\n/**\n * Helper methods to determining what the user's preferred color scheme is\n * based on the system preferences rather than the users explicit preference.\n */\nexport const prefers = {\n dark: () => window.matchMedia('(prefers-color-scheme: dark)').matches,\n light: () => window.matchMedia('(prefers-color-scheme: light)').matches,\n custom: (name: string) => window.matchMedia(`(prefers-color-scheme: ${name})`).matches,\n none: () => window.matchMedia('(prefers-color-scheme: no-preference)').matches,\n};\n\nconst LOCAL_PREF_KEY = 'ember-primitives/color-scheme#local-preference';\n\n/**\n * Helper methods for working with the color scheme preference in local storage\n */\nexport const localPreference = {\n isSet: () => Boolean(localPreference.read()),\n read: () => localStorage.getItem(LOCAL_PREF_KEY),\n update: (value: string) => localStorage.setItem(LOCAL_PREF_KEY, value),\n delete: () => localStorage.removeItem(LOCAL_PREF_KEY),\n};\n\n/**\n * For the given element, returns the `color-scheme` of that element.\n */\nexport function getColorScheme(element?: HTMLElement) {\n const style = styleOf(element);\n\n return style.getPropertyValue('color-scheme');\n}\n\nexport function setColorScheme(element: HTMLElement, value: string): void;\nexport function setColorScheme(value: string): void;\n\nexport function setColorScheme(...args: [string] | [HTMLElement, string]): void {\n if (typeof args[0] === 'string') {\n styleOf().setProperty('color-scheme', args[0]);\n\n return;\n }\n\n if (typeof args[1] === 'string') {\n styleOf(args[0]).setProperty('color-scheme', args[1]);\n\n return;\n }\n\n throw new Error(`Invalid arity, expected up to 2 args, received ${args.length}`);\n}\n\n/**\n * Removes the `color-scheme` from the given element\n */\nexport function removeColorScheme(element?: HTMLElement) {\n const style = styleOf(element);\n\n style.removeProperty('color-scheme');\n}\n\nfunction styleOf(element?: HTMLElement) {\n if (element) {\n return element.style;\n }\n\n return document.documentElement.style;\n}\n"],"names":["_colorScheme","cell","callbacks","Set","runCallbacks","theme","Promise","resolve","callback","values","colorScheme","update","value","current","waitForPromise","on","add","off","delete","localPreference","setColorScheme","sync","userPreference","read","prefers","dark","light","window","matchMedia","matches","custom","name","none","LOCAL_PREF_KEY","isSet","Boolean","localStorage","getItem","setItem","removeItem","getColorScheme","element","style","styleOf","getPropertyValue","args","setProperty","Error","length","removeColorScheme","removeProperty","document","documentElement"],"mappings":";;;AAIA,MAAMA,YAAY,GAAGC,IAAI,EAAsB;AAE/C,IAAIC,SAA6C,GAAG,IAAIC,GAAG,EAAE;AAE7D,eAAeC,YAAYA,CAACC,KAAa,EAAE;AACzC,EAAA,MAAMC,OAAO,CAACC,OAAO,EAAE;EAEvB,KAAK,MAAMC,QAAQ,IAAIN,SAAS,CAACO,MAAM,EAAE,EAAE;IACzCD,QAAQ,CAACH,KAAK,CAAC;AACjB,EAAA;AACF;;AAEA;AACA;AACA;AACO,MAAMK,WAAW,GAAG;AACzB;AACF;AACA;EACEC,MAAM,EAAGC,KAAa,IAAK;IACzBF,WAAW,CAACG,OAAO,GAAGD,KAAK;AAE3B,IAAA,KAAKE,cAAc,CAACV,YAAY,CAACQ,KAAK,CAAC,CAAC;EAC1C,CAAC;AAEDG,EAAAA,EAAE,EAAE;AACF;AACJ;AACA;IACIJ,MAAM,EAAGH,QAAuC,IAAK;AACnDN,MAAAA,SAAS,CAACc,GAAG,CAACR,QAAQ,CAAC;AACzB,IAAA;GACD;AACDS,EAAAA,GAAG,EAAE;AACH;AACJ;AACA;IACIN,MAAM,EAAGH,QAAuC,IAAK;AACnDN,MAAAA,SAAS,CAACgB,MAAM,CAACV,QAAQ,CAAC;AAC5B,IAAA;GACD;AAED;AACF;AACA;EACE,IAAIK,OAAOA,GAAuB;IAChC,OAAOb,YAAY,CAACa,OAAO;EAC7B,CAAC;EACD,IAAIA,OAAOA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,CAAC;AACtC;AAEA,SAASP,OAAOA,CAACF,OAAqB,EAAE;AACtC,EAAA,IAAIA,OAAO,EAAE;IACX,OAAOA,OAAO,CAACC,KAAK;AACtB,EAAA;AAEA,EAAA,OAAOS,QAAQ,CAACC,eAAe,CAACV,KAAK;AACvC;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { tracked } from '@glimmer/tracking';
|
|
4
3
|
import { hash } from '@ember/helper';
|
|
@@ -132,7 +131,7 @@ class FloatingUI extends Component {
|
|
|
132
131
|
this.reference = element;
|
|
133
132
|
};
|
|
134
133
|
static {
|
|
135
|
-
setComponentTemplate(precompileTemplate("
|
|
134
|
+
setComponentTemplate(precompileTemplate("{{#let (modifier anchorTo flipOptions=@flipOptions hideOptions=@hideOptions middleware=@middleware offsetOptions=@offsetOptions placement=@placement shiftOptions=@shiftOptions strategy=@strategy setData=this.setData) as |prewiredAnchorTo|}}\n {{#let (if this.reference (modifier prewiredAnchorTo this.reference)) as |floating|}}\n {{!-- @glint-nocheck -- Excessively deep, possibly infinite --}}\n {{yield (modifier ref this.setReference) floating (hash setReference=this.setReference data=this.data)}}\n {{/let}}\n{{/let}}", {
|
|
136
135
|
strictMode: true,
|
|
137
136
|
scope: () => ({
|
|
138
137
|
anchorTo,
|
|
@@ -144,4 +143,4 @@ class FloatingUI extends Component {
|
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
export { FloatingUI as F, anchorTo as a };
|
|
147
|
-
//# sourceMappingURL=component-
|
|
146
|
+
//# sourceMappingURL=component-BXy_iafw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-BXy_iafw.js","sources":["../src/floating-ui/middleware.ts","../src/floating-ui/modifier.ts","../src/floating-ui/component.gts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\n\nexport function exposeMetadata(): Middleware {\n return {\n name: 'metadata',\n fn: (data) => {\n // https://floating-ui.com/docs/middleware#always-return-an-object\n return {\n data,\n };\n },\n };\n}\n","import { assert } from '@ember/debug';\n\nimport { autoUpdate, computePosition, flip, hide, offset, shift } from '@floating-ui/dom';\nimport { modifier as eModifier } from 'ember-modifier';\n\nimport { exposeMetadata } from './middleware.ts';\n\nimport type {\n FlipOptions,\n HideOptions,\n Middleware,\n OffsetOptions,\n Placement,\n ShiftOptions,\n Strategy,\n} from '@floating-ui/dom';\n\nexport interface Signature {\n /**\n *\n */\n Element: HTMLElement;\n Args: {\n Positional: [\n /**\n * What do use as the reference element.\n * Can be a selector or element instance.\n *\n * Example:\n * ```gjs\n * import { anchorTo } from 'ember-primitives/floating-ui';\n *\n * <template>\n * <div id=\"reference\">...</div>\n * <div {{anchorTo \"#reference\"}}> ... </div>\n * </template>\n * ```\n */\n referenceElement: string | HTMLElement | SVGElement,\n ];\n Named: {\n /**\n * This is the type of CSS position property to use.\n * By default this is 'fixed', but can also be 'absolute'.\n *\n * See: [The strategy docs](https://floating-ui.com/docs/computePosition#strategy)\n */\n strategy?: Strategy;\n /**\n * Options to pass to the [offset middleware](https://floating-ui.com/docs/offset)\n */\n offsetOptions?: OffsetOptions;\n /**\n * Where to place the floating element relative to its reference element.\n * The default is 'bottom'.\n *\n * See: [The placement docs](https://floating-ui.com/docs/computePosition#placement)\n */\n placement?: Placement;\n /**\n * Options to pass to the [flip middleware](https://floating-ui.com/docs/flip)\n */\n flipOptions?: FlipOptions;\n /**\n * Options to pass to the [shift middleware](https://floating-ui.com/docs/shift)\n */\n shiftOptions?: ShiftOptions;\n /**\n * Options to pass to the [hide middleware](https://floating-ui.com/docs/hide)\n */\n hideOptions?: HideOptions;\n /**\n * Additional middleware to pass to FloatingUI.\n *\n * See: [The middleware docs](https://floating-ui.com/docs/middleware)\n */\n middleware?: Middleware[];\n /**\n * A callback for when data changes about the position / placement / etc\n * of the floating element.\n */\n setData?: Middleware['fn'];\n };\n };\n}\n\n/**\n * A modifier to apply to the _floating_ element.\n * This is what will anchor to the reference element.\n *\n * Example\n * ```gjs\n * import { anchorTo } from 'ember-primitives/floating-ui';\n *\n * <template>\n * <button id=\"my-button\"> ... </button>\n * <menu {{anchorTo \"#my-button\"}}> ... </menu>\n * </template>\n * ```\n */\nexport const anchorTo = eModifier<Signature>(\n (\n floatingElement,\n [_referenceElement],\n {\n strategy = 'fixed',\n offsetOptions = 0,\n placement = 'bottom',\n flipOptions,\n shiftOptions,\n middleware = [],\n setData,\n }\n ) => {\n const referenceElement: null | HTMLElement | SVGElement =\n typeof _referenceElement === 'string'\n ? document.querySelector(_referenceElement)\n : _referenceElement;\n\n assert(\n 'no reference element defined',\n referenceElement instanceof HTMLElement || referenceElement instanceof SVGElement\n );\n\n assert(\n 'no floating element defined',\n floatingElement instanceof HTMLElement || _referenceElement instanceof SVGElement\n );\n\n assert(\n 'reference and floating elements cannot be the same element',\n floatingElement !== _referenceElement\n );\n\n assert('@middleware must be an array of one or more objects', Array.isArray(middleware));\n\n Object.assign(floatingElement.style, {\n position: strategy,\n top: '0',\n left: '0',\n });\n\n const update = async () => {\n const { middlewareData, x, y } = await computePosition(referenceElement, floatingElement, {\n middleware: [\n offset(offsetOptions),\n flip(flipOptions),\n shift(shiftOptions),\n ...middleware,\n hide({ strategy: 'referenceHidden' }),\n hide({ strategy: 'escaped' }),\n exposeMetadata(),\n ],\n placement,\n strategy,\n });\n\n const referenceHidden = middlewareData.hide?.referenceHidden;\n\n Object.assign(floatingElement.style, {\n top: `${y}px`,\n left: `${x}px`,\n margin: 0,\n visibility: referenceHidden ? 'hidden' : 'visible',\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n void setData?.(middlewareData['metadata']);\n };\n\n void update();\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const cleanup = autoUpdate(referenceElement, floatingElement, update);\n\n /**\n * in the function-modifier manager, teardown of the previous modifier\n * occurs before setup of the next\n * https://github.com/ember-modifier/ember-modifier/blob/main/ember-modifier/src/-private/function-based/modifier-manager.ts#L58\n */\n return cleanup;\n }\n);\n","import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { hash } from \"@ember/helper\";\n\nimport { modifier as eModifier } from \"ember-modifier\";\n\nimport { anchorTo } from \"./modifier.ts\";\n\nimport type { Signature as ModifierSignature } from \"./modifier.ts\";\nimport type { MiddlewareState } from \"@floating-ui/dom\";\nimport type { ModifierLike } from \"@glint/template\";\n\ntype ModifierArgs = ModifierSignature[\"Args\"][\"Named\"];\n\ninterface ReferenceSignature {\n Element: HTMLElement | SVGElement;\n}\n\nexport interface Signature {\n Args: {\n /**\n * Additional middleware to pass to FloatingUI.\n *\n * See: [The middleware docs](https://floating-ui.com/docs/middleware)\n */\n middleware?: ModifierArgs[\"middleware\"];\n /**\n * Where to place the floating element relative to its reference element.\n * The default is 'bottom'.\n *\n * See: [The placement docs](https://floating-ui.com/docs/computePosition#placement)\n */\n placement?: ModifierArgs[\"placement\"];\n /**\n * This is the type of CSS position property to use.\n * By default this is 'fixed', but can also be 'absolute'.\n *\n * See: [The strategy docs](https://floating-ui.com/docs/computePosition#strategy)\n */\n strategy?: ModifierArgs[\"strategy\"];\n /**\n * Options to pass to the [flip middleware](https://floating-ui.com/docs/flip)\n */\n flipOptions?: ModifierArgs[\"flipOptions\"];\n /**\n * Options to pass to the [hide middleware](https://floating-ui.com/docs/hide)\n */\n hideOptions?: ModifierArgs[\"hideOptions\"];\n /**\n * Options to pass to the [shift middleware](https://floating-ui.com/docs/shift)\n */\n shiftOptions?: ModifierArgs[\"shiftOptions\"];\n /**\n * Options to pass to the [offset middleware](https://floating-ui.com/docs/offset)\n */\n offsetOptions?: ModifierArgs[\"offsetOptions\"];\n };\n Blocks: {\n default: [\n /**\n * A modifier to apply to the _reference_ element.\n * This is what the floating element will use to anchor to.\n *\n * Example\n * ```gjs\n * import { FloatingUI } from 'ember-primitives/floating-ui';\n *\n * <template>\n * <FloatingUI as |reference floating|>\n * <button {{reference}}> ... </button>\n * ...\n * </FloatingUI>\n * </template>\n * ```\n */\n reference: ModifierLike<ReferenceSignature>,\n /**\n * A modifier to apply to the _floating_ element.\n * This is what will anchor to the reference element.\n *\n * Example\n * ```gjs\n * import { FloatingUI } from 'ember-primitives/floating-ui';\n *\n * <template>\n * <FloatingUI as |reference floating|>\n * <button {{reference}}> ... </button>\n * <menu {{floating}}> ... </menu>\n * </FloatingUI>\n * </template>\n * ```\n */\n floating:\n | undefined\n | ModifierLike<{\n Element: HTMLElement;\n Args: {\n Named: ModifierArgs;\n };\n }>,\n /**\n * Special utilities for advanced usage\n */\n util: {\n /**\n * If you want to have a single modifier with custom behavior\n * on your reference element, you may use this `setReference`\n * function to set the reference, rather than having multiple modifiers\n * on that element.\n */\n setReference: (element: HTMLElement | SVGElement) => void;\n /**\n * Metadata exposed from floating-ui.\n * Gives you x, y position, among other things.\n */\n data?: MiddlewareState;\n },\n ];\n };\n}\n\nconst ref = eModifier<{\n Element: HTMLElement | SVGElement;\n Args: {\n Positional: [setRef: (element: HTMLElement | SVGElement) => void];\n };\n}>((element: HTMLElement | SVGElement, positional) => {\n const fn = positional[0];\n\n fn(element);\n});\n\n/**\n * A component that provides no DOM and yields two modifiers for creating\n * creating floating uis, such as menus, popovers, tooltips, etc.\n * This component currently uses [Floating UI](https://floating-ui.com/)\n * but will be switching to [CSS Anchor Positioning](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_anchor_positioning) when that lands.\n *\n * Example usage:\n * ```gjs\n * import { FloatingUI } from 'ember-primitives/floating-ui';\n *\n * <template>\n * <FloatingUI as |reference floating|>\n * <button {{reference}}> ... </button>\n * <menu {{floating}}> ... </menu>\n * </FloatingUI>\n * </template>\n * ```\n */\nexport class FloatingUI extends Component<Signature> {\n @tracked reference?: HTMLElement | SVGElement = undefined;\n @tracked data?: MiddlewareState = undefined;\n\n setData: ModifierArgs[\"setData\"] = (data) => (this.data = data);\n\n setReference = (element: HTMLElement | SVGElement) => {\n this.reference = element;\n };\n\n <template>\n {{#let\n (modifier\n anchorTo\n flipOptions=@flipOptions\n hideOptions=@hideOptions\n middleware=@middleware\n offsetOptions=@offsetOptions\n placement=@placement\n shiftOptions=@shiftOptions\n strategy=@strategy\n setData=this.setData\n )\n as |prewiredAnchorTo|\n }}\n {{#let (if this.reference (modifier prewiredAnchorTo this.reference)) as |floating|}}\n {{! @glint-nocheck -- Excessively deep, possibly infinite }}\n {{yield\n (modifier ref this.setReference)\n floating\n (hash setReference=this.setReference data=this.data)\n }}\n {{/let}}\n {{/let}}\n </template>\n}\n"],"names":["exposeMetadata","name","fn","data","anchorTo","eModifier","floatingElement","_referenceElement","strategy","offsetOptions","placement","flipOptions","shiftOptions","middleware","setData","referenceElement","document","querySelector","assert","HTMLElement","SVGElement","Array","isArray","Object","assign","style","position","top","left","update","middlewareData","x","y","computePosition","offset","flip","shift","hide","referenceHidden","margin","visibility","cleanup","autoUpdate","ref","element","positional","FloatingUI","Component","g","prototype","tracked","undefined","i","setReference","reference","setComponentTemplate","precompileTemplate","strictMode","scope","hash"],"mappings":";;;;;;;;;;AAEO,SAASA,cAAcA,GAAe;EAC3C,OAAO;AACLC,IAAAA,IAAI,EAAE,UAAU;IAChBC,EAAE,EAAGC,IAAI,IAAK;AACZ;MACA,OAAO;AACLA,QAAAA;OACD;AACH,IAAA;GACD;AACH;;AC0EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,QAAQ,GAAGC,QAAS,CAC/B,CACEC,eAAe,EACf,CAACC,iBAAiB,CAAC,EACnB;AACEC,EAAAA,QAAQ,GAAG,OAAO;AAClBC,EAAAA,aAAa,GAAG,CAAC;AACjBC,EAAAA,SAAS,GAAG,QAAQ;EACpBC,WAAW;EACXC,YAAY;AACZC,EAAAA,UAAU,GAAG,EAAE;AACfC,EAAAA;AACF,CAAC,KACE;AACH,EAAA,MAAMC,gBAAiD,GACrD,OAAOR,iBAAiB,KAAK,QAAQ,GACjCS,QAAQ,CAACC,aAAa,CA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I,CAACU,SAAS,GAAGV,OAAA;EACnB,CAAA;AAEA,EAAA;IAAAW,oBAAA,CAAAC,kBAAA,CAAA,qhBAAA,EAwBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAtD,QAAA;QAAAuC,GAAA;AAAAgB,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 { assert } from '@ember/debug';
|
|
4
3
|
import { hash } from '@ember/helper';
|
|
@@ -11,7 +10,7 @@ import { g, i } from 'decorator-transforms/runtime';
|
|
|
11
10
|
|
|
12
11
|
class AccordionContent extends Component {
|
|
13
12
|
static {
|
|
14
|
-
setComponentTemplate(precompileTemplate("
|
|
13
|
+
setComponentTemplate(precompileTemplate("<div role=\"region\" id={{@value}} data-state={{getDataState @isExpanded}} hidden={{this.isHidden}} data-disabled={{@disabled}} ...attributes>\n {{yield}}\n</div>", {
|
|
15
14
|
strictMode: true,
|
|
16
15
|
scope: () => ({
|
|
17
16
|
getDataState
|
|
@@ -23,7 +22,7 @@ class AccordionContent extends Component {
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const AccordionTrigger = setComponentTemplate(precompileTemplate("
|
|
25
|
+
const AccordionTrigger = setComponentTemplate(precompileTemplate("<button type=\"button\" aria-controls={{@value}} aria-expanded={{@isExpanded}} data-state={{getDataState @isExpanded}} data-disabled={{@disabled}} aria-disabled={{if @disabled \"true\" \"false\"}} {{on \"click\" @toggleItem}} ...attributes>\n {{yield}}\n</button>", {
|
|
27
26
|
strictMode: true,
|
|
28
27
|
scope: () => ({
|
|
29
28
|
getDataState,
|
|
@@ -31,7 +30,7 @@ const AccordionTrigger = setComponentTemplate(precompileTemplate("\n <button ty
|
|
|
31
30
|
})
|
|
32
31
|
}), templateOnly());
|
|
33
32
|
|
|
34
|
-
const AccordionHeader = setComponentTemplate(precompileTemplate("
|
|
33
|
+
const AccordionHeader = setComponentTemplate(precompileTemplate("<div role=\"heading\" aria-level=\"3\" data-state={{getDataState @isExpanded}} data-disabled={{@disabled}} ...attributes>\n {{yield (hash Trigger=(component Trigger value=@value isExpanded=@isExpanded disabled=@disabled toggleItem=@toggleItem))}}\n</div>", {
|
|
35
34
|
strictMode: true,
|
|
36
35
|
scope: () => ({
|
|
37
36
|
getDataState,
|
|
@@ -45,7 +44,7 @@ function getDataState(isExpanded) {
|
|
|
45
44
|
}
|
|
46
45
|
class AccordionItem extends Component {
|
|
47
46
|
static {
|
|
48
|
-
setComponentTemplate(precompileTemplate("
|
|
47
|
+
setComponentTemplate(precompileTemplate("<div data-state={{getDataState this.isExpanded}} data-disabled={{@disabled}} ...attributes>\n {{yield (hash isExpanded=this.isExpanded Header=(component Header value=@value isExpanded=this.isExpanded disabled=@disabled toggleItem=this.toggleItem) Content=(component Content value=@value isExpanded=this.isExpanded disabled=@disabled))}}\n</div>", {
|
|
49
48
|
strictMode: true,
|
|
50
49
|
scope: () => ({
|
|
51
50
|
getDataState,
|
|
@@ -69,7 +68,7 @@ class AccordionItem extends Component {
|
|
|
69
68
|
|
|
70
69
|
class Accordion extends Component {
|
|
71
70
|
static {
|
|
72
|
-
setComponentTemplate(precompileTemplate("
|
|
71
|
+
setComponentTemplate(precompileTemplate("<div data-disabled={{@disabled}} ...attributes>\n {{yield (hash Item=(component AccordionItem selectedValue=this.selectedValue toggleItem=this.toggleItem disabled=@disabled))}}\n</div>", {
|
|
73
72
|
strictMode: true,
|
|
74
73
|
scope: () => ({
|
|
75
74
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"accordion.js","sources":["../../src/components/accordion/content.gts","../../src/components/accordion/trigger.gts","../../src/components/accordion/header.gts","../../src/components/accordion/item.gts","../../src/components/accordion.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\n\nimport { getDataState } from \"./item.gts\";\n\nimport type { AccordionContentExternalSignature } from \"./public.ts\";\n\ninterface Signature extends AccordionContentExternalSignature {\n Args: {\n isExpanded: boolean;\n value: string;\n disabled?: boolean;\n };\n}\n\nexport class AccordionContent extends Component<Signature> {\n <template>\n <div\n role=\"region\"\n id={{@value}}\n data-state={{getDataState @isExpanded}}\n hidden={{this.isHidden}}\n data-disabled={{@disabled}}\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n\n get isHidden() {\n return !this.args.isExpanded;\n }\n}\n\nexport default AccordionContent;\n","import { on } from \"@ember/modifier\";\n\nimport { getDataState } from \"./item.gts\";\n\nimport type { AccordionTriggerExternalSignature } from \"./public.ts\";\nimport type { TOC } from \"@ember/component/template-only\";\n\ninterface Signature extends AccordionTriggerExternalSignature {\n Args: {\n isExpanded: boolean;\n value: string;\n disabled?: boolean;\n toggleItem: () => void;\n };\n}\n\nexport const AccordionTrigger: TOC<Signature> = <template>\n <button\n type=\"button\"\n aria-controls={{@value}}\n aria-expanded={{@isExpanded}}\n data-state={{getDataState @isExpanded}}\n data-disabled={{@disabled}}\n aria-disabled={{if @disabled \"true\" \"false\"}}\n {{on \"click\" @toggleItem}}\n ...attributes\n >\n {{yield}}\n </button>\n</template>;\n\nexport default AccordionTrigger;\n","import { hash } from \"@ember/helper\";\n\nimport { getDataState } from \"./item.gts\";\nimport Trigger from \"./trigger.gts\";\n\nimport type { AccordionHeaderExternalSignature } from \"./public.ts\";\nimport type { TOC } from \"@ember/component/template-only\";\n\ninterface Signature extends AccordionHeaderExternalSignature {\n Args: {\n value: string;\n isExpanded: boolean;\n disabled?: boolean;\n toggleItem: () => void;\n };\n}\n\nexport const AccordionHeader: TOC<Signature> = <template>\n <div\n role=\"heading\"\n aria-level=\"3\"\n data-state={{getDataState @isExpanded}}\n data-disabled={{@disabled}}\n ...attributes\n >\n {{yield\n (hash\n Trigger=(component\n Trigger value=@value isExpanded=@isExpanded disabled=@disabled toggleItem=@toggleItem\n )\n )\n }}\n </div>\n</template>;\n\nexport default AccordionHeader;\n","import Component from \"@glimmer/component\";\nimport { hash } from \"@ember/helper\";\n\nimport Content from \"./content.gts\";\nimport Header from \"./header.gts\";\n\nimport type { AccordionItemExternalSignature } from \"./public.ts\";\n\nexport function getDataState(isExpanded: boolean): string {\n return isExpanded ? \"open\" : \"closed\";\n}\n\ninterface Signature extends AccordionItemExternalSignature {\n Args: AccordionItemExternalSignature[\"Args\"] & {\n selectedValue?: string | string[];\n disabled?: boolean;\n toggleItem: (value: string) => void;\n };\n}\n\nexport class AccordionItem extends Component<Signature> {\n <template>\n <div data-state={{getDataState this.isExpanded}} data-disabled={{@disabled}} ...attributes>\n {{yield\n (hash\n isExpanded=this.isExpanded\n Header=(component\n Header\n value=@value\n isExpanded=this.isExpanded\n disabled=@disabled\n toggleItem=this.toggleItem\n )\n Content=(component Content value=@value isExpanded=this.isExpanded disabled=@disabled)\n )\n }}\n </div>\n </template>\n\n get isExpanded(): boolean {\n if (Array.isArray(this.args.selectedValue)) {\n return this.args.selectedValue.includes(this.args.value);\n }\n\n return this.args.selectedValue === this.args.value;\n }\n\n toggleItem = (): void => {\n if (this.args.disabled) return;\n\n this.args.toggleItem(this.args.value);\n };\n}\n\nexport default AccordionItem;\n","import Component from \"@glimmer/component\";\nimport { assert } from \"@ember/debug\";\nimport { hash } from \"@ember/helper\";\n\n// temp\n// https://github.com/tracked-tools/tracked-toolbox/issues/38\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { localCopy } from \"tracked-toolbox\";\n\nimport AccordionItem from \"./accordion/item.gts\";\n\nimport type { WithBoundArgs } from \"@glint/template\";\n\ntype AccordionSingleArgs = {\n /**\n * The type of accordion. If `single`, only one item can be selected at a time. If `multiple`, multiple items can be selected at a time.\n */\n type: \"single\";\n /**\n * Whether the accordion is disabled. When `true`, all items cannot be expanded or collapsed.\n */\n disabled?: boolean;\n /**\n * When type is `single`, whether the accordion is collapsible. When `true`, the selected item can be collapsed by clicking its trigger.\n */\n collapsible?: boolean;\n} & (\n | {\n /**\n * The currently selected value. To be used in a controlled fashion in conjunction with `onValueChange`.\n */\n value: string;\n /**\n * A callback that is called when the selected value changes. To be used in a controlled fashion in conjunction with `value`.\n */\n onValueChange: (value: string | undefined) => void;\n /**\n * Not available in a controlled fashion.\n */\n defaultValue?: never;\n }\n | {\n /**\n * Not available in an uncontrolled fashion.\n */\n value?: never;\n /**\n * Not available in an uncontrolled fashion.\n */\n onValueChange?: never;\n /**\n * The default value of the accordion. To be used in an uncontrolled fashion.\n */\n defaultValue?: string;\n }\n);\n\ntype AccordionMultipleArgs = {\n /**\n * The type of accordion. If `single`, only one item can be selected at a time. If `multiple`, multiple items can be selected at a time.\n */\n type: \"multiple\";\n /**\n * Whether the accordion is disabled. When `true`, all items cannot be expanded or collapsed.\n */\n disabled?: boolean;\n} & (\n | {\n /**\n * The currently selected values. To be used in a controlled fashion in conjunction with `onValueChange`.\n */\n value: string[];\n /**\n * A callback that is called when the selected values change. To be used in a controlled fashion in conjunction with `value`.\n */\n onValueChange: (value?: string[]) => void;\n /**\n * Not available in a controlled fashion.\n */\n defaultValue?: never;\n }\n | {\n /**\n * Not available in an uncontrolled fashion.\n */\n value?: never;\n /**\n * Not available in an uncontrolled fashion.\n */\n onValueChange?: never;\n /**\n * The default values of the accordion. To be used in an uncontrolled fashion.\n */\n defaultValue?: string[];\n }\n);\n\nexport class Accordion extends Component<{\n Element: HTMLDivElement;\n Args: AccordionSingleArgs | AccordionMultipleArgs;\n Blocks: {\n default: [\n {\n /**\n * The AccordionItem component.\n */\n Item: WithBoundArgs<typeof AccordionItem, \"selectedValue\" | \"toggleItem\" | \"disabled\">;\n },\n ];\n };\n}> {\n <template>\n <div data-disabled={{@disabled}} ...attributes>\n {{yield\n (hash\n Item=(component\n AccordionItem\n selectedValue=this.selectedValue\n toggleItem=this.toggleItem\n disabled=@disabled\n )\n )\n }}\n </div>\n </template>\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n @localCopy(\"args.defaultValue\") declare _internallyManagedValue?: string | string[];\n\n get selectedValue() {\n return this.args.value ?? this._internallyManagedValue;\n }\n\n toggleItem = (value: string) => {\n if (this.args.disabled) {\n return;\n }\n\n if (this.args.type === \"single\") {\n this.toggleItemSingle(value);\n } else if (this.args.type === \"multiple\") {\n this.toggleItemMultiple(value);\n }\n };\n\n toggleItemSingle = (value: string) => {\n assert(\"Cannot call `toggleItemSingle` when `disabled` is true.\", !this.args.disabled);\n assert(\n \"Cannot call `toggleItemSingle` when `type` is not `single`.\",\n this.args.type === \"single\",\n );\n\n if (value === this.selectedValue && !this.args.collapsible) {\n return;\n }\n\n const newValue = value === this.selectedValue ? undefined : value;\n\n if (this.args.onValueChange) {\n this.args.onValueChange(newValue);\n } else {\n this._internallyManagedValue = newValue;\n }\n };\n\n toggleItemMultiple = (value: string) => {\n assert(\"Cannot call `toggleItemMultiple` when `disabled` is true.\", !this.args.disabled);\n assert(\n \"Cannot call `toggleItemMultiple` when `type` is not `multiple`.\",\n this.args.type === \"multiple\",\n );\n\n const currentValues = (this.selectedValue as string[] | undefined) ?? [];\n const indexOfValue = currentValues.indexOf(value);\n let newValue: string[];\n\n if (indexOfValue === -1) {\n newValue = [...currentValues, value];\n } else {\n newValue = [\n ...currentValues.slice(0, indexOfValue),\n ...currentValues.slice(indexOfValue + 1),\n ];\n }\n\n if (this.args.onValueChange) {\n this.args.onValueChange(newValue);\n } else {\n this._internallyManagedValue = newValue;\n }\n };\n}\n\nexport default Accordion;\n"],"names":["AccordionContent","Component","setComponentTemplate","precompileTemplate","strictMode","scope","getDataState","isHidden","args","isExpanded","AccordionTrigger","on","templateOnly","AccordionHeader","hash","Trigger","AccordionItem","Header","Content","Array","isArray","selectedValue","includes","value","toggleItem","disabled","Accordion","g","prototype","localCopy","i","_internallyManagedValue","type","toggleItemSingle","toggleItemMultiple","assert","collapsible","newValue","undefined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AAcG,KAAK,CAAC,CAAA,EAAGF,YAAA,CAAA,KACvBD,aAAA,CAAcG,KAAK,CAACF,YAAA,GAAe,CAAA,CAAA,CACvC;AACH,IAAA;AAEA,IAAA,IAAI,IAAI,CAACjC,IAAI,CAAC+B,aAAa,EAAE;AAC3B,MAAA,IAAI,CAAC/B,IAAI,CAAC+B,aAAa,CAACF,QAAA,CAAA;AAC1B,IAAA,CAAA,MAAO;MACL,IAAI,CAACN,uBAAuB,GAAGM,QAAA;AACjC,IAAA;EACF,CAAA;AACF;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { hash } from '@ember/helper';
|
|
3
2
|
import { ReactiveImage } from 'reactiveweb/image';
|
|
4
3
|
import { WaitUntil } from 'reactiveweb/wait-until';
|
|
@@ -6,16 +5,16 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
6
5
|
import { setComponentTemplate } from '@ember/component';
|
|
7
6
|
import templateOnly from '@ember/component/template-only';
|
|
8
7
|
|
|
9
|
-
const Fallback = setComponentTemplate(precompileTemplate("
|
|
8
|
+
const Fallback = setComponentTemplate(precompileTemplate("{{#unless @isLoaded}}\n {{#let (WaitUntil @delayMs) as |delayFinished|}}\n {{#if delayFinished}}\n {{yield}}\n {{/if}}\n {{/let}}\n{{/unless}}", {
|
|
10
9
|
strictMode: true,
|
|
11
10
|
scope: () => ({
|
|
12
11
|
WaitUntil
|
|
13
12
|
})
|
|
14
13
|
}), templateOnly());
|
|
15
|
-
const Image = setComponentTemplate(precompileTemplate("
|
|
14
|
+
const Image = setComponentTemplate(precompileTemplate("{{#if @isLoaded}}\n <img alt=\"__missing__\" ...attributes src={{@src}} />\n{{/if}}", {
|
|
16
15
|
strictMode: true
|
|
17
16
|
}), templateOnly());
|
|
18
|
-
const Avatar = setComponentTemplate(precompileTemplate("
|
|
17
|
+
const Avatar = setComponentTemplate(precompileTemplate("{{#let (ReactiveImage @src) as |imgState|}}\n <span data-prim-avatar ...attributes data-loading={{imgState.isLoading}} data-error={{imgState.isError}}>\n {{yield (hash Image=(component Image src=@src isLoaded=imgState.isResolved) Fallback=(component Fallback isLoaded=imgState.isResolved) isLoading=imgState.isLoading isError=imgState.isError)}}\n </span>\n{{/let}}", {
|
|
19
18
|
strictMode: true,
|
|
20
19
|
scope: () => ({
|
|
21
20
|
ReactiveImage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"avatar.js","sources":["../../src/components/avatar.gts"],"sourcesContent":["import { hash } from \"@ember/helper\";\n\nimport { ReactiveImage } from \"reactiveweb/image\";\nimport { WaitUntil } from \"reactiveweb/wait-until\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type { WithBoundArgs } from \"@glint/template\";\n\nconst Fallback: TOC<{\n Blocks: { default: [] };\n Args: {\n /**\n * The number of milliseconds to wait for the image to load\n * before displaying the fallback\n */\n delayMs?: number;\n /**\n * @private\n * Bound internally by ember-primitives\n */\n isLoaded: boolean;\n };\n}> = <template>\n {{#unless @isLoaded}}\n {{#let (WaitUntil @delayMs) as |delayFinished|}}\n {{#if delayFinished}}\n {{yield}}\n {{/if}}\n {{/let}}\n {{/unless}}\n</template>;\n\nconst Image: TOC<{\n Element: HTMLImageElement;\n Args: {\n /**\n * @private\n * The `src` value for the image.\n *\n * Bound internally by ember-primitives\n */\n src: string;\n /**\n * @private\n * Bound internally by ember-primitives\n */\n isLoaded: boolean;\n };\n}> = <template>\n {{#if @isLoaded}}\n <img alt=\"__missing__\" ...attributes src={{@src}} />\n {{/if}}\n</template>;\n\nexport const Avatar: TOC<{\n Element: HTMLSpanElement;\n Args: {\n /**\n * The `src` value for the image.\n */\n src: string;\n };\n Blocks: {\n default: [\n avatar: {\n /**\n * The image to render. It will only render when it has loaded.\n */\n Image: WithBoundArgs<typeof Image, \"src\" | \"isLoaded\">;\n /**\n * An element that renders when the image hasn't loaded.\n * This means whilst it's loading, or if there was an error.\n * If you notice a flash during loading,\n * you can provide a delayMs prop to delay its rendering so it only renders for those with slower connections.\n */\n Fallback: WithBoundArgs<typeof Fallback, \"isLoaded\">;\n /**\n * true while the image is loading\n */\n isLoading: boolean;\n /**\n * If the image fails to load, this will be `true`\n */\n isError: boolean;\n },\n ];\n };\n}> = <template>\n {{#let (ReactiveImage @src) as |imgState|}}\n <span\n data-prim-avatar\n ...attributes\n data-loading={{imgState.isLoading}}\n data-error={{imgState.isError}}\n >\n {{yield\n (hash\n Image=(component Image src=@src isLoaded=imgState.isResolved)\n Fallback=(component Fallback isLoaded=imgState.isResolved)\n isLoading=imgState.isLoading\n isError=imgState.isError\n )\n }}\n </span>\n {{/let}}\n</template>;\n\nexport default Avatar;\n"],"names":["Fallback","setComponentTemplate","precompileTemplate","strictMode","scope","WaitUntil","templateOnly","Image","Avatar","ReactiveImage","hash"],"mappings":";;;;;;;AAQA,MAAMA,QAcD,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,6JAAA,EAQL;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;AAEV,MAAMC,KAgBD,GAAAN,oBAAA,CAAAC,kBAAA,CAAA,sFAAA,EAIL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAG,YAAA,EAAA,CAAA;MAEGE,MAiCR,GAAAP,oBAAA,CAAAC,kBAAA,CAAA,oXAAA,EAkBL;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAK,aAAA;IAAAC,IAAA;IAAAH,KAAA;AAAAP,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAM,YAAA,EAAA;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { tracked } from '@glimmer/tracking';
|
|
4
3
|
import { assert } from '@ember/debug';
|
|
@@ -11,7 +10,7 @@ import { setComponentTemplate } from '@ember/component';
|
|
|
11
10
|
import templateOnly from '@ember/component/template-only';
|
|
12
11
|
import { g, i } from 'decorator-transforms/runtime';
|
|
13
12
|
|
|
14
|
-
const DialogElement = setComponentTemplate(precompileTemplate("
|
|
13
|
+
const DialogElement = setComponentTemplate(precompileTemplate("<dialog ...attributes open={{@open}} {{on \"close\" @onClose}} {{@register}}>\n {{yield}}\n</dialog>", {
|
|
15
14
|
strictMode: true,
|
|
16
15
|
scope: () => ({
|
|
17
16
|
on
|
|
@@ -19,7 +18,7 @@ const DialogElement = setComponentTemplate(precompileTemplate("\n <dialog ...at
|
|
|
19
18
|
}), templateOnly());
|
|
20
19
|
class ModalDialog extends Component {
|
|
21
20
|
static {
|
|
22
|
-
setComponentTemplate(precompileTemplate("
|
|
21
|
+
setComponentTemplate(precompileTemplate("{{yield (hash isOpen=this.isOpen open=this.open close=this.close focusOnClose=this.refocus Dialog=(component DialogElement open=@open onClose=this.handleClose register=this.register))}}", {
|
|
23
22
|
strictMode: true,
|
|
24
23
|
scope: () => ({
|
|
25
24
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"dialog.js","sources":["../../src/components/dialog.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { assert } from \"@ember/debug\";\nimport { hash } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\n\nimport { modifier as eModifier } from \"ember-modifier\";\n// temp\n// https://github.com/tracked-tools/tracked-toolbox/issues/38\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport { localCopy } from \"tracked-toolbox\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type { ModifierLike, WithBoundArgs } from \"@glint/template\";\n\nconst DialogElement: TOC<{\n Element: HTMLDialogElement;\n Args: {\n /**\n * @internal\n */\n open: boolean | undefined;\n /**\n * @internal\n */\n onClose: () => void;\n\n /**\n * @internal\n */\n register: ModifierLike<{ Element: HTMLDialogElement }>;\n };\n Blocks: { default: [] };\n}> = <template>\n <dialog ...attributes open={{@open}} {{on \"close\" @onClose}} {{@register}}>\n {{yield}}\n </dialog>\n</template>;\n\nexport interface Signature {\n Args: {\n /**\n * Optionally set the open state of the `<dialog>`\n * The state will still be managed internally,\n * so this does not need to be a maintained value, but whenever it changes,\n * the dialog element will reflect that change accordingly.\n */\n open?: boolean;\n /**\n * When the `<dialog>` is closed, this function will be called\n * and the `<dialog>`'s `returnValue` will be passed.\n *\n * This can be used to determine which button was clicked to close the modal\n *\n * Note though that this value is only populated when using\n * `<form method='dialog'>`\n */\n onClose?: (returnValue: string) => void;\n };\n Blocks: {\n default: [\n {\n /**\n * Represents the open state of the `<dialog>` element.\n */\n isOpen: boolean;\n\n /**\n * Closes the `<dialog>` element\n * Will throw an error if `Dialog` is not rendered.\n */\n close: () => void;\n\n /**\n * Opens the `<dialog>` element.\n * Will throw an error if `Dialog` is not rendered.\n */\n open: () => void;\n\n /**\n * This modifier should be applied to the button that opens the Dialog so that it can be re-focused when the dialog closes.\n *\n * Example:\n *\n * ```gjs\n * <template>\n * <Modal as |m|>\n * <button {{m.focusOnClose}} {{on \"click\" m.open}}>Open</button>\n *\n * <m.Dialog>...</m.Dialog>\n * </Modal>\n * </template>\n * ```\n */\n focusOnClose: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * This is the `<dialog>` element (with some defaults pre-wired).\n * This is required to be rendered.\n */\n Dialog: WithBoundArgs<typeof DialogElement, \"onClose\" | \"register\" | \"open\">;\n },\n ];\n };\n}\n\nclass ModalDialog extends Component<Signature> {\n <template>\n {{yield\n (hash\n isOpen=this.isOpen\n open=this.open\n close=this.close\n focusOnClose=this.refocus\n Dialog=(component DialogElement open=@open onClose=this.handleClose register=this.register)\n )\n }}\n </template>\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n @localCopy(\"args.open\") declare _isOpen: boolean;\n\n get isOpen() {\n /**\n * Always fallback to false (closed)\n */\n return this._isOpen ?? false;\n }\n set isOpen(val: boolean) {\n this._isOpen = val;\n }\n\n #lastIsOpen = false;\n refocus = eModifier((element) => {\n assert(`focusOnClose is only valid on a HTMLElement`, element instanceof HTMLElement);\n\n if (!this.isOpen && this.#lastIsOpen) {\n element.focus();\n }\n\n this.#lastIsOpen = this.isOpen;\n });\n\n @tracked declare dialogElement: HTMLDialogElement | undefined;\n\n register = eModifier((element: HTMLDialogElement) => {\n /**\n * This is very sad.\n *\n * But we need the element to be 'root state'\n * so that when we read things like \"isOpen\",\n * when the dialog is finally rendered, all the\n * downstream properties render.\n *\n * This has to be an async / delayed a bit, so that\n * the tracking frame can exit, and we don't infinite loop\n */\n void (async () => {\n await Promise.resolve();\n\n this.dialogElement = element;\n })();\n });\n\n /**\n * Closes the dialog -- this will throw an error in development if the dialog element was not rendered\n */\n close = () => {\n assert(\n \"Cannot call `close` on <Dialog> without rendering the dialog element.\",\n this.dialogElement,\n );\n\n /**\n * If the element is already closed, don't run all this again\n */\n if (!this.dialogElement.hasAttribute(\"open\")) {\n return;\n }\n\n /**\n * removes the `open` attribute\n * handleClose will be called because the dialog has bound the `close` event.\n */\n this.dialogElement.close();\n };\n\n /**\n * @internal\n *\n * handles the <dialog> element's native close behavior.\n * listened to via addEventListener('close', ...);\n */\n handleClose = () => {\n assert(\n \"Cannot call `handleDialogClose` on <Dialog> without rendering the dialog element. This is likely a bug in ember-primitives. Please open an issue <3\",\n this.dialogElement,\n );\n\n this.isOpen = false;\n this.args.onClose?.(this.dialogElement.returnValue);\n // the return value ends up staying... which is annoying\n this.dialogElement.returnValue = \"\";\n };\n\n /**\n * Opens the dialog -- this will throw an error in development if the dialog element was not rendered\n */\n open = () => {\n assert(\n \"Cannot call `open` on <Dialog> without rendering the dialog element.\",\n this.dialogElement,\n );\n\n /**\n * If the element is already open, don't run all this again\n */\n if (this.dialogElement.hasAttribute(\"open\")) {\n return;\n }\n\n /**\n * adds the `open` attribute\n */\n this.dialogElement.showModal();\n this.isOpen = true;\n };\n}\n\nexport const Modal = ModalDialog;\nexport const Dialog = ModalDialog;\n\nexport default ModalDialog;\n"],"names":["DialogElement","setComponentTemplate","precompileTemplate","strictMode","scope","on","templateOnly","ModalDialog","Component","hash","g","prototype","localCopy","i","isOpen","_isOpen","val","refocus","eModifier","element","assert","HTMLElement","focus","tracked","register","Promise","resolve","dialogElement","close","hasAttribute","handleClose","args","onClose","returnValue","open","showModal","Modal","Dialog"],"mappings":";;;;;;;;;;;;AAgBA,MAAMA,aAkBD,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,uGAAA,EAIL;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;AAqEV,MAAMC,oBAAoBC,SAAA,CAAU;AAClC,EAAA;IAAAP,oBAAA,CAAAC,kBAAA,CAAA,2LAAA,EAUA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAK,IAAA;AAAAT,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AAEV;AAAA,EAAA;AAAAU,IAAAA,CAAA,MAAAC,SAAA,EAAA,SAAA,EAAA,CACCC,SAAA,CAAU,WAAA,CAAA,CAAA,CAAA;AAAA;EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAA,MAAA;EAEX,IAAIC,MAAAA,GAAS;AACX;;AAEC;AACD,IAAA,OAAO,IAAI,CAACC,OAAO,IAAI,KAAA;AACzB,EAAA;EACA,IAAID,MAAAA,CAAOE,GAAY,EAAE;IACvB,IAAI,CAACD,OAAO,GAAGC,GAAA;AACjB,EAAA;EAEA,WAAW,GAAG,KAAA;AAC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N,aAAa,CAACM,WAAW,GAAG,EAAA;EACnC,CAAA;AAEA;;AAEC;EACDC,IAAA,GAAOA,MAAA;AACLd,IAAAA,MAAA,CACE,sEAAA,EACA,IAAI,CAACO,aAAa,CAAA;AAGpB;;AAEC;IACD,IAAI,IAAI,CAACA,aAAa,CAACE,YAAY,CAAC,MAAA,CAAA,EAAS;AAC3C,MAAA;AACF,IAAA;AAEA;;AAEC;AACD,IAAA,IAAI,CAACF,aAAa,CAACQ,SAAS,EAAA;IAC5B,IAAI,CAACrB,MAAM,GAAG,IAAA;EAChB,CAAA;AACF;AAEO,MAAMsB,QAAQ7B;AACd,MAAM8B,SAAS9B;;;;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
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';
|
|
5
4
|
|
|
6
|
-
const ExternalLink = setComponentTemplate(precompileTemplate("
|
|
5
|
+
const ExternalLink = setComponentTemplate(precompileTemplate("<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"##missing##\" ...attributes>\n {{yield}}\n</a>", {
|
|
7
6
|
strictMode: true
|
|
8
7
|
}), templateOnly());
|
|
9
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-link.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"external-link.js","sources":["../../src/components/external-link.gts"],"sourcesContent":["import type { TOC } from \"@ember/component/template-only\";\n\nexport const ExternalLink: TOC<{\n Element: HTMLAnchorElement;\n Blocks: {\n default: [];\n };\n}> = <template>\n <a target=\"_blank\" rel=\"noreferrer noopener\" href=\"##missing##\" ...attributes>\n {{yield}}\n </a>\n</template>;\n\nexport default ExternalLink;\n"],"names":["ExternalLink","setComponentTemplate","precompileTemplate","strictMode","templateOnly"],"mappings":";;;;MAEaA,YAKR,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,yGAAA,EAIL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;;;"}
|
package/dist/components/form.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { fn } from '@ember/helper';
|
|
3
2
|
import { on } from '@ember/modifier';
|
|
4
3
|
import { dataFrom } from 'form-data-utils';
|
|
@@ -15,7 +14,7 @@ const handleSubmit = (onChange, event) => {
|
|
|
15
14
|
event.preventDefault();
|
|
16
15
|
handleInput(onChange, event, "submit");
|
|
17
16
|
};
|
|
18
|
-
const Form = setComponentTemplate(precompileTemplate("
|
|
17
|
+
const Form = setComponentTemplate(precompileTemplate("<form {{on \"input\" (fn handleInput @onChange)}} {{on \"submit\" (fn handleSubmit @onChange)}} ...attributes>\n {{yield}}\n</form>", {
|
|
19
18
|
strictMode: true,
|
|
20
19
|
scope: () => ({
|
|
21
20
|
on,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"form.js","sources":["../../src/components/form.gts"],"sourcesContent":["import { fn } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\n\nimport { dataFrom } from \"form-data-utils\";\n\nimport type { TOC } from \"@ember/component/template-only\";\n\ntype Data = ReturnType<typeof dataFrom>;\n\nexport const dataFromEvent = dataFrom;\n\nconst handleInput = (\n onChange: (data: Data, eventType: \"input\" | \"submit\", event: Event) => void,\n event: Event | SubmitEvent,\n eventType: \"input\" | \"submit\" = \"input\",\n) => {\n const data = dataFrom(event);\n\n onChange(data, eventType, event);\n};\n\nconst handleSubmit = (\n onChange: (data: Data, eventType: \"input\" | \"submit\", event: Event | SubmitEvent) => void,\n event: SubmitEvent,\n) => {\n event.preventDefault();\n handleInput(onChange, event, \"submit\");\n};\n\nexport interface Signature {\n Element: HTMLFormElement;\n Args: {\n /**\n * Any time the value of any field is changed this function will be called.\n */\n onChange: (\n /**\n * The data from the form as an Object of `{ [field name] => value }` pairs.\n * This is generated from the native [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)\n *\n * Additional fields/inputs/controls can be added to this data by specifying a\n * \"name\" attribute.\n */\n data: Data,\n /**\n * Indicates whether the `onChange` function was called from the `input` or `submit` event handlers.\n */\n eventType: \"input\" | \"submit\",\n /**\n * The raw event, if needed.\n */\n event: Event | SubmitEvent,\n ) => void;\n };\n Blocks: {\n /**\n * The main content for the form. This is where inputs / fields / controls would go.\n * Within the `<form>` content, `<button type=\"submit\">` will submit the form, which\n * triggers the `@onChange` event.\n */\n default: [];\n };\n}\n\nexport const Form: TOC<Signature> = <template>\n <form\n {{on \"input\" (fn handleInput @onChange)}}\n {{on \"submit\" (fn handleSubmit @onChange)}}\n ...attributes\n >\n {{yield}}\n </form>\n</template>;\n\nexport default Form;\n"],"names":["dataFromEvent","dataFrom","handleInput","onChange","event","eventType","data","handleSubmit","preventDefault","Form","setComponentTemplate","precompileTemplate","strictMode","scope","on","fn","templateOnly"],"mappings":";;;;;;;AASO,MAAMA,gBAAgBC;AAE7B,MAAMC,cAAcA,CAClBC,QAA2E,EAC3EC,OACAC,YAAgC,OAAO,KAAA;AAEvC,EAAA,MAAMC,OAAOL,QAAA,CAASG,KAAA,CAAA;AAEtBD,EAAAA,QAAA,CAASG,MAAMD,SAAA,EAAWD,KAAA,CAAA;AAC5B,CAAA;AAEA,MAAMG,YAAA,GAAeA,CACnBJ,QAAyF,EACzFC,KAAO,KAAA;EAEPA,KAAA,CAAMI,cAAc,EAAA;AACpBN,EAAAA,WAAA,CAAYC,UAAUC,KAAA,EAAO,QAAA,CAAA;AAC/B,CAAA;MAqCaK,IAAU,GAAAC,oBAAA,CAAaC,kBAAA,CAAA,sIAAA,EAQpC;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,EAAA;IAAAC,EAAA;IAAAb,WAAA;AAAAK,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAS,YAAA,EAAA;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { element } from 'ember-element-helper';
|
|
4
3
|
import { getSectionHeadingLevel } from 'which-heading-do-i-need';
|
|
@@ -18,7 +17,7 @@ class Heading extends Component {
|
|
|
18
17
|
return `h${this.level}`;
|
|
19
18
|
}
|
|
20
19
|
static {
|
|
21
|
-
setComponentTemplate(precompileTemplate("
|
|
20
|
+
setComponentTemplate(precompileTemplate("{{this.headingScopeAnchor}}\n\n{{#let (element this.hLevel) as |El|}}\n <El ...attributes>\n {{yield}}\n </El>\n{{/let}}", {
|
|
22
21
|
strictMode: true,
|
|
23
22
|
scope: () => ({
|
|
24
23
|
element
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"heading.js","sources":["../../src/components/heading.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\n\nimport { element } from \"ember-element-helper\";\nimport { getSectionHeadingLevel } from \"which-heading-do-i-need\";\n\nimport type Owner from \"@ember/owner\";\n\nexport class Heading extends Component<{\n Element: HTMLElement;\n Blocks: { default: [] };\n}> {\n headingScopeAnchor: Text;\n constructor(owner: Owner, args: object) {\n super(owner, args);\n\n this.headingScopeAnchor = document.createTextNode(\"\");\n }\n\n get level() {\n return getSectionHeadingLevel(this.headingScopeAnchor);\n }\n\n get hLevel() {\n return `h${this.level}`;\n }\n\n <template>\n {{this.headingScopeAnchor}}\n\n {{#let (element this.hLevel) as |El|}}\n <El ...attributes>\n {{yield}}\n </El>\n {{/let}}\n </template>\n}\n"],"names":["Heading","Component","headingScopeAnchor","constructor","owner","args","document","createTextNode","level","getSectionHeadingLevel","hLevel","setComponentTemplate","precompileTemplate","strictMode","scope","element"],"mappings":";;;;;;AAOO,MAAMA,OAAA,SAAgBC,SAAA;EAI3BC,kBAAA;AACAC,EAAAA,WAAAA,CAAYC,KAAY,EAAEC,IAAY,EAAE;AACtC,IAAA,KAAK,CAACD,KAAA,EAAOC,IAAA,CAAA;IAEb,IAAI,CAACH,kBAAkB,GAAGI,QAAA,CAASC,cAAc,CAAC,EAAA,CAAA;AACpD,EAAA;EAEA,IAAIC,KAAAA,GAAQ;AACV,IAAA,OAAOC,sBAAA,CAAuB,IAAI,CAACP,kBAAkB,CAAA;AACvD,EAAA;EAEA,IAAIQ,MAAAA,GAAS;AACX,IAAA,OAAO,CAAA,CAAA,EAAI,IAAI,CAACF,KAAK,CAAA,CAAE;AACzB,EAAA;AAEA,EAAA;IAAAG,oBAAA,CAAAC,kBAAA,CAAA,+HAAA,EAQA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
package/dist/components/keys.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';
|
|
@@ -18,7 +17,7 @@ function getKeys(keys, mac) {
|
|
|
18
17
|
const normalMac = Array.isArray(mac) ? mac : split(mac);
|
|
19
18
|
return isMac ? normalMac : normalKeys;
|
|
20
19
|
}
|
|
21
|
-
const KeyCombo = setComponentTemplate(precompileTemplate("
|
|
20
|
+
const KeyCombo = setComponentTemplate(precompileTemplate("<span class=\"ember-primitives__key-combination\" ...attributes>\n {{#let (getKeys @keys @mac) as |keys|}}\n {{#each keys as |key i|}}\n <Key>{{key}}</Key>\n {{#if (isNotLast keys i)}}\n <span class=\"ember-primitives__key-combination__separator\">+</span>\n {{/if}}\n {{/each}}\n {{/let}}\n</span>", {
|
|
22
21
|
strictMode: true,
|
|
23
22
|
scope: () => ({
|
|
24
23
|
getKeys,
|
|
@@ -26,7 +25,7 @@ const KeyCombo = setComponentTemplate(precompileTemplate("\n <span class=\"embe
|
|
|
26
25
|
isNotLast
|
|
27
26
|
})
|
|
28
27
|
}), templateOnly());
|
|
29
|
-
const Key = setComponentTemplate(precompileTemplate("
|
|
28
|
+
const Key = setComponentTemplate(precompileTemplate("<kbd class=\"ember-primitives__key\" ...attributes>{{yield}}</kbd>", {
|
|
30
29
|
strictMode: true
|
|
31
30
|
}), templateOnly());
|
|
32
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"keys.js","sources":["../../src/components/keys.gts"],"sourcesContent":["import type { TOC } from \"@ember/component/template-only\";\n\nconst isLast = (collection: unknown[], index: number) => index === collection.length - 1;\nconst isNotLast = (collection: unknown[], index: number) => !isLast(collection, index);\nconst isMac = navigator.userAgent.indexOf(\"Mac OS\") >= 0;\n\nfunction split(str: string) {\n const keys = str.split(\"+\").map((x) => x.trim());\n\n return keys;\n}\n\nfunction getKeys(keys: string[] | string, mac?: string[] | string) {\n const normalKeys = Array.isArray(keys) ? keys : split(keys);\n\n if (!mac) {\n return normalKeys;\n }\n\n const normalMac = Array.isArray(mac) ? mac : split(mac);\n\n return isMac ? normalMac : normalKeys;\n}\n\nexport interface KeyComboSignature {\n Element: HTMLElement;\n Args: {\n keys: string[] | string;\n mac?: string[] | string;\n };\n}\n\nexport const KeyCombo: TOC<KeyComboSignature> = <template>\n <span class=\"ember-primitives__key-combination\" ...attributes>\n {{#let (getKeys @keys @mac) as |keys|}}\n {{#each keys as |key i|}}\n <Key>{{key}}</Key>\n {{#if (isNotLast keys i)}}\n <span class=\"ember-primitives__key-combination__separator\">+</span>\n {{/if}}\n {{/each}}\n {{/let}}\n </span>\n</template>;\n\nexport interface KeySignature {\n Element: HTMLElement;\n Blocks: { default?: [] };\n}\n\nexport const Key: TOC<KeySignature> = <template>\n <kbd class=\"ember-primitives__key\" ...attributes>{{yield}}</kbd>\n</template>;\n"],"names":["isLast","collection","index","length","isNotLast","isMac","navigator","userAgent","indexOf","split","str","keys","map","x","trim","getKeys","mac","normalKeys","Array","isArray","normalMac","KeyCombo","setComponentTemplate","precompileTemplate","strictMode","scope","Key","templateOnly"],"mappings":";;;;AAEA,MAAMA,MAAA,GAASA,CAACC,UAAmB,EAAIC,KAAa,KAAKA,KAAA,KAAUD,UAAA,CAAWE,MAAM,GAAG,CAAA;AACvF,MAAMC,SAAA,GAAYA,CAACH,UAAmB,EAAIC,KAAa,KAAK,CAACF,MAAA,CAAOC,UAAA,EAAYC,KAAA,CAAA;AAChF,MAAMG,QAAQC,SAAA,CAAUC,SAAS,CAACC,OAAO,CAAC,QAAA,CAAA,IAAa,CAAA;AAEvD,SAASC,KAAAA,CAAMC,GAAW,EAAA;AACxB,EAAA,MAAMC,IAAA,GAAOD,GAAA,CAAID,KAAK,CAAC,GAAA,CAAA,CAAKG,GAAG,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,EAAA,CAAA;AAE7C,EAAA,OAAOH,IAAA;AACT;AAEA,SAASI,OAAAA,CAAQJ,IAAuB,EAAEK,GAAuB,EAAA;AAC/D,EAAA,MAAMC,aAAaC,KAAA,CAAMC,OAAO,CAACR,IAAA,CAAA,GAAQA,OAAOF,KAAA,CAAME,IAAA,CAAA;EAEtD,IAAI,CAACK,GAAA,EAAK;AACR,IAAA,OAAOC,UAAA;AACT,EAAA;AAEA,EAAA,MAAMG,YAAYF,KAAA,CAAMC,OAAO,CAACH,GAAA,CAAA,GAAOA,MAAMP,KAAA,CAAMO,GAAA,CAAA;AAEnD,EAAA,OAAOX,QAAQe,SAAA,GAAYH,UAAA;AAC7B;MAUaI,QAAc,GAAAC,oBAAA,CAAqBC,kBAAA,CAAA,0UAAA,EAWhD;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAV,OAAA;IAAAW,GAAA;AAAAtB,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAuB,YAAA,EAAA;MAOGD,GAAS,GAAAJ,oBAAA,CAAgBC,kBAAA,CAAA,oEAAA,EAEtC;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAG,YAAA,EAAA;;;;"}
|
|
@@ -5,7 +5,7 @@ import templateOnly from '@ember/component/template-only';
|
|
|
5
5
|
|
|
6
6
|
;
|
|
7
7
|
|
|
8
|
-
const Hero = setComponentTemplate(precompileTemplate("
|
|
8
|
+
const Hero = setComponentTemplate(precompileTemplate("<div class=\"ember-primitives__hero__wrapper\" ...attributes>\n {{yield}}\n</div>", {
|
|
9
9
|
strictMode: true
|
|
10
10
|
}), templateOnly());
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ import templateOnly from '@ember/component/template-only';
|
|
|
5
5
|
|
|
6
6
|
;
|
|
7
7
|
|
|
8
|
-
const StickyFooter = setComponentTemplate(precompileTemplate("
|
|
8
|
+
const StickyFooter = setComponentTemplate(precompileTemplate("<div class=\"ember-primitives__sticky-footer__wrapper\" ...attributes>\n <div class=\"ember-primitives__sticky-footer__container\">\n <div class=\"ember-primitives__sticky-footer__content\">\n {{yield to=\"content\"}}\n </div>\n <div class=\"ember-primitives__sticky-footer__footer\">\n {{yield to=\"footer\"}}\n </div>\n </div>\n</div>", {
|
|
9
9
|
strictMode: true
|
|
10
10
|
}), templateOnly());
|
|
11
11
|
|
package/dist/components/link.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { hash } from '@ember/helper';
|
|
3
2
|
import { on } from '@ember/modifier';
|
|
4
3
|
import { link } from '../helpers/link.js';
|
|
@@ -19,7 +18,7 @@ import templateOnly from '@ember/component/template-only';
|
|
|
19
18
|
*
|
|
20
19
|
* [mdn-a]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
|
|
21
20
|
*/
|
|
22
|
-
const Link = setComponentTemplate(precompileTemplate("
|
|
21
|
+
const Link = setComponentTemplate(precompileTemplate("{{#let (link @href includeActiveQueryParams=@includeActiveQueryParams activeOnSubPaths=@activeOnSubPaths) as |l|}}\n {{#if l.isExternal}}\n <ExternalLink href={{@href}} ...attributes>\n {{yield (hash isExternal=true isActive=false)}}\n </ExternalLink>\n {{else}}\n <a data-active={{l.isActive}} href={{if @href @href \"##missing##\"}} {{on \"click\" l.handleClick}} ...attributes>\n {{yield (hash isExternal=false isActive=l.isActive)}}\n </a>\n {{/if}}\n{{/let}}", {
|
|
23
22
|
strictMode: true,
|
|
24
23
|
scope: () => ({
|
|
25
24
|
link,
|