ember-primitives 0.26.2 → 0.27.1
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/-private.d.ts +5 -0
- package/declarations/-private.d.ts.map +1 -0
- package/declarations/index.d.ts +0 -1
- package/declarations/index.d.ts.map +1 -1
- package/declarations/tabster.d.ts +24 -0
- package/declarations/tabster.d.ts.map +1 -0
- package/declarations/test-support/a11y.d.ts +3 -6
- package/declarations/test-support/a11y.d.ts.map +1 -1
- package/declarations/test-support/index.d.ts +1 -0
- package/declarations/test-support/index.d.ts.map +1 -1
- package/dist/-private.js +7 -0
- package/dist/-private.js.map +1 -0
- package/dist/color-scheme.js.map +1 -1
- package/dist/components/-private/utils.js.map +1 -1
- package/dist/components/one-time-password/utils.js.map +1 -1
- package/dist/components/zoetrope/styles.css +0 -5
- package/dist/floating-ui/middleware.js.map +1 -1
- package/dist/floating-ui/modifier.js.map +1 -1
- package/dist/helpers/link.js.map +1 -1
- package/dist/helpers/service.js.map +1 -1
- package/dist/iframe.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/proper-links.js.map +1 -1
- package/dist/tabster.js +38 -0
- package/dist/tabster.js.map +1 -0
- package/dist/test-support/a11y.js +11 -5
- package/dist/test-support/a11y.js.map +1 -1
- package/dist/test-support/index.js +1 -0
- package/dist/test-support/index.js.map +1 -1
- package/dist/test-support/otp.js.map +1 -1
- package/dist/test-support/routing.js.map +1 -1
- package/dist/test-support/zoetrope.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +20 -22
- package/declarations/services/ember-primitives/setup.d.ts +0 -27
- package/declarations/services/ember-primitives/setup.d.ts.map +0 -1
- package/dist/_app_/services/ember-primitives/setup.js +0 -1
- package/dist/services/ember-primitives/setup.js +0 -36
- package/dist/services/ember-primitives/setup.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"-private.d.ts","sourceRoot":"","sources":["../src/-private.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,eAAyC,CAAC"}
|
package/declarations/index.d.ts
CHANGED
|
@@ -20,5 +20,4 @@ export { Toggle } from "./components/toggle";
|
|
|
20
20
|
export { ToggleGroup } from "./components/toggle-group";
|
|
21
21
|
export { Zoetrope } from './components/zoetrope.ts';
|
|
22
22
|
export * from './helpers.ts';
|
|
23
|
-
export type { default as SetupService } from './services/ember-primitives/setup.ts';
|
|
24
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,YAAY,EACV,iCAAiC,EACjC,gCAAgC,EAChC,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,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MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function setupTabster(
|
|
2
|
+
/**
|
|
3
|
+
* A destroyable object.
|
|
4
|
+
* This is needed so that when the app (or tests) or unmounted or ending,
|
|
5
|
+
* the tabster instance can be disposed of.
|
|
6
|
+
*/
|
|
7
|
+
context: object, { tabster, setTabsterRoot, }?: {
|
|
8
|
+
/**
|
|
9
|
+
* Let this setup function initalize tabster.
|
|
10
|
+
* https://tabster.io/docs/core
|
|
11
|
+
*
|
|
12
|
+
* This should be done only once per application as we don't want
|
|
13
|
+
* focus managers fighting with each other.
|
|
14
|
+
*
|
|
15
|
+
* Defaults to `true`,
|
|
16
|
+
*
|
|
17
|
+
* Will fallback to an existing tabster instance automatically if `getTabster` returns a value.
|
|
18
|
+
*
|
|
19
|
+
* If `false` is explicitly passed here, you'll also be in charge of teardown.
|
|
20
|
+
*/
|
|
21
|
+
tabster?: boolean;
|
|
22
|
+
setTabsterRoot?: boolean;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=tabster.d.ts.map
|
|
@@ -0,0 +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,iBA0BP"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Including the tabster root.
|
|
5
|
-
*/
|
|
6
|
-
export declare function setup(owner: Owner): void;
|
|
1
|
+
export declare function setupTabster(hooks: {
|
|
2
|
+
beforeEach: (callback: () => void | Promise<void>) => unknown;
|
|
3
|
+
}): void;
|
|
7
4
|
//# sourceMappingURL=a11y.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../src/test-support/a11y.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../src/test-support/a11y.ts"],"names":[],"mappings":"AAgBA,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC;CAC/D,QAWA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-support/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-support/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/-private.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 (let 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 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 if (localPreference.isSet()) {\n let pref = localPreference.read();\n\n if (pref === 'dark') {\n setColorScheme('dark');\n\n _colorScheme.current = 'dark';\n\n return;\n }\n\n setColorScheme('light');\n _colorScheme.current = 'light';\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 */\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 let 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 let 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","isSet","pref","read","prefers","dark","light","window","matchMedia","matches","custom","name","none","LOCAL_PREF_KEY","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
|
|
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 (let 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 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 if (localPreference.isSet()) {\n let pref = localPreference.read();\n\n if (pref === 'dark') {\n setColorScheme('dark');\n\n _colorScheme.current = 'dark';\n\n return;\n }\n\n setColorScheme('light');\n _colorScheme.current = 'light';\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 */\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 let 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 let 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","isSet","pref","read","prefers","dark","light","window","matchMedia","matches","custom","name","none","LOCAL_PREF_KEY","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,IAAIC,QAAQ,IAAIN,SAAS,CAACO,MAAM,EAAE,EAAE;IACvCD,QAAQ,CAACH,KAAK,CAAC;AACjB;AACF;;AAEA;AACA;AACA;AACO,MAAMK,WAAW,GAAG;AACzB;AACF;AACA;EACEC,MAAM,EAAGC,KAAa,IAAK;IACzBF,WAAW,CAACG,OAAO,GAAGD,KAAK;AAE3BE,IAAAA,cAAc,CAACV,YAAY,CAACQ,KAAK,CAAC,CAAC;GACpC;AAEDG,EAAAA,EAAE,EAAE;AACF;AACJ;AACA;IACIJ,MAAM,EAAGH,QAAuC,IAAK;AACnDN,MAAAA,SAAS,CAACc,GAAG,CAACR,QAAQ,CAAC;AACzB;GACD;AACDS,EAAAA,GAAG,EAAE;AACH;AACJ;AACA;IACIN,MAAM,EAAGH,QAAuC,IAAK;AACnDN,MAAAA,SAAS,CAACgB,MAAM,CAACV,QAAQ,CAAC;AAC5B;GACD;AAED;AACF;AACA;EACE,IAAIK,OAAOA,GAAuB;IAChC,OAAOb,YAAY,CAACa,OAAO;GAC5B;EACD,IAAIA,OAAOA,CAACD,KAAyB,EAAE;IACrCZ,YAAY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O,CAACF,OAAO,CAAC;AAE5BC,EAAAA,KAAK,CAACQ,cAAc,CAAC,cAAc,CAAC;AACtC;AAEA,SAASP,OAAOA,CAACF,OAAqB,EAAE;AACtC,EAAA,IAAIA,OAAO,EAAE;IACX,OAAOA,OAAO,CAACC,KAAK;AACtB;AAEA,EAAA,OAAOS,QAAQ,CAACC,eAAe,CAACV,KAAK;AACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/components/-private/utils.ts"],"sourcesContent":["/**\n * If the user provides an onChange or similar function, use that,\n * otherwise fallback to the uncontrolled toggle\n */\nexport function toggleWithFallback(\n uncontrolledToggle: (...args: unknown[]) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n controlledToggle?: (...args: any[]) => void,\n ...args: unknown[]\n) {\n if (controlledToggle) {\n return controlledToggle(...args);\n }\n\n uncontrolledToggle(...args);\n}\n"],"names":["toggleWithFallback","uncontrolledToggle","controlledToggle","args"],"mappings":"AAAA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,kBAAgD;AAChD;AACAC,gBAA2C,EAC3C,GAAGC,IAAe,EAClB;AACA,EAAA,IAAID,gBAAgB,EAAE;AACpB,IAAA,OAAOA,gBAAgB,CAAC,GAAGC,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/components/-private/utils.ts"],"sourcesContent":["/**\n * If the user provides an onChange or similar function, use that,\n * otherwise fallback to the uncontrolled toggle\n */\nexport function toggleWithFallback(\n uncontrolledToggle: (...args: unknown[]) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n controlledToggle?: (...args: any[]) => void,\n ...args: unknown[]\n) {\n if (controlledToggle) {\n return controlledToggle(...args);\n }\n\n uncontrolledToggle(...args);\n}\n"],"names":["toggleWithFallback","uncontrolledToggle","controlledToggle","args"],"mappings":"AAAA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,kBAAgD;AAChD;AACAC,gBAA2C,EAC3C,GAAGC,IAAe,EAClB;AACA,EAAA,IAAID,gBAAgB,EAAE;AACpB,IAAA,OAAOA,gBAAgB,CAAC,GAAGC,IAAI,CAAC;AAClC;EAEAF,kBAAkB,CAAC,GAAGE,IAAI,CAAC;AAC7B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/components/one-time-password/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nfunction getInputs(current: HTMLInputElement) {\n let fieldset = current.closest('fieldset');\n\n assert('[BUG]: fieldset went missing', fieldset);\n\n return [...fieldset.querySelectorAll('input')];\n}\n\nfunction nextInput(current: HTMLInputElement) {\n let inputs = getInputs(current);\n let currentIndex = inputs.indexOf(current);\n\n return inputs[currentIndex + 1];\n}\n\nexport function selectAll(event: Event) {\n let target = event.target;\n\n assert(`selectAll is only meant for use with input elements`, target instanceof HTMLInputElement);\n\n target.select();\n}\n\nexport function handlePaste(event: Event) {\n let target = event.target;\n\n assert(\n `handlePaste is only meant for use with input elements`,\n target instanceof HTMLInputElement\n );\n\n let clipboardData = (event as ClipboardEvent).clipboardData;\n\n assert(\n `Could not get clipboardData while handling the paste event on OTP. Please report this issue on the ember-primitives repo with a reproduction. Thanks!`,\n clipboardData\n );\n\n // This is typically not good to prevent paste.\n // But because of the UX we're implementing,\n // we want to split the pasted value across\n // multiple text fields\n event.preventDefault();\n\n let value = clipboardData.getData('Text');\n const digits = value;\n let i = 0;\n let currElement: HTMLInputElement | null = target;\n\n while (currElement) {\n currElement.value = digits[i++] || '';\n\n let next = nextInput(currElement);\n\n if (next instanceof HTMLInputElement) {\n currElement = next;\n } else {\n break;\n }\n }\n\n // We want to select the first field again\n // so that if someone holds paste, or\n // pastes again, they get the same result.\n target.select();\n}\n\nexport function handleNavigation(event: KeyboardEvent) {\n switch (event.key) {\n case 'Backspace':\n return handleBackspace(event);\n case 'ArrowLeft':\n return focusLeft(event);\n case 'ArrowRight':\n return focusRight(event);\n }\n}\n\nfunction focusLeft(event: Pick<Event, 'target'>) {\n let target = event.target;\n\n assert(`only allowed on input elements`, target instanceof HTMLInputElement);\n\n let input = previousInput(target);\n\n input?.focus();\n requestAnimationFrame(() => {\n input?.select();\n });\n}\n\nfunction focusRight(event: Pick<Event, 'target'>) {\n let target = event.target;\n\n assert(`only allowed on input elements`, target instanceof HTMLInputElement);\n\n let input = nextInput(target);\n\n input?.focus();\n requestAnimationFrame(() => {\n input?.select();\n });\n}\n\nconst syntheticEvent = new InputEvent('input');\n\nfunction handleBackspace(event: KeyboardEvent) {\n if (event.key !== 'Backspace') return;\n\n /**\n * We have to prevent default because we\n * - want to clear the whole field\n * - have the focus behavior keep up with the key-repeat\n * speed of the user's computer\n */\n event.preventDefault();\n\n let target = event.target;\n\n if (target && 'value' in target) {\n if (target.value === '') {\n focusLeft({ target });\n } else {\n target.value = '';\n }\n }\n\n target?.dispatchEvent(syntheticEvent);\n}\n\nfunction previousInput(current: HTMLInputElement) {\n let inputs = getInputs(current);\n let currentIndex = inputs.indexOf(current);\n\n return inputs[currentIndex - 1];\n}\n\nexport const autoAdvance = (event: Event) => {\n assert(\n '[BUG]: autoAdvance called on non-input element',\n event.target instanceof HTMLInputElement\n );\n\n let value = event.target.value;\n\n if (value.length === 0) return;\n\n if (value.length > 0) {\n if ('data' in event && event.data && typeof event.data === 'string') {\n event.target.value = event.data;\n }\n\n return focusRight(event);\n }\n};\n\nexport function getCollectiveValue(elementTarget: EventTarget | null, length: number) {\n if (!elementTarget) return;\n\n assert(\n `[BUG]: somehow the element target is not HTMLElement`,\n elementTarget instanceof HTMLElement\n );\n\n let parent: null | HTMLElement | ShadowRoot;\n\n // TODO: should this logic be extracted?\n // why is getting the target element within a shadow root hard?\n if (!(elementTarget instanceof HTMLInputElement)) {\n if (elementTarget.shadowRoot) {\n parent = elementTarget.shadowRoot;\n } else {\n parent = elementTarget.closest('fieldset');\n }\n } else {\n parent = elementTarget.closest('fieldset');\n }\n\n assert(`[BUG]: somehow the input fields were rendered without a parent element`, parent);\n\n let elements = parent.querySelectorAll('input');\n\n let value = '';\n\n assert(\n `found elements (${elements.length}) do not match length (${length}). Was the same OTP input rendered more than once?`,\n elements.length === length\n );\n\n for (let element of elements) {\n assert(\n '[BUG]: how did the queried elements become a non-input element?',\n element instanceof HTMLInputElement\n );\n value += element.value;\n }\n\n return value;\n}\n"],"names":["getInputs","current","fieldset","closest","assert","querySelectorAll","nextInput","inputs","currentIndex","indexOf","selectAll","event","target","HTMLInputElement","select","handlePaste","clipboardData","preventDefault","value","getData","digits","i","currElement","next","handleNavigation","key","handleBackspace","focusLeft","focusRight","input","previousInput","focus","requestAnimationFrame","syntheticEvent","InputEvent","dispatchEvent","autoAdvance","length","data","getCollectiveValue","elementTarget","HTMLElement","parent","shadowRoot","elements","element"],"mappings":";;AAEA,SAASA,SAASA,CAACC,OAAyB,EAAE;AAC5C,EAAA,IAAIC,QAAQ,GAAGD,OAAO,CAACE,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1CC,EAAAA,MAAM,CAAC,8BAA8B,EAAEF,QAAQ,CAAC,CAAA;EAEhD,OAAO,CAAC,GAAGA,QAAQ,CAACG,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;AAChD,CAAA;AAEA,SAASC,SAASA,CAACL,OAAyB,EAAE;AAC5C,EAAA,IAAIM,MAAM,GAAGP,SAAS,CAACC,OAAO,CAAC,CAAA;AAC/B,EAAA,IAAIO,YAAY,GAAGD,MAAM,CAACE,OAAO,CAACR,OAAO,CAAC,CAAA;AAE1C,EAAA,OAAOM,MAAM,CAACC,YAAY,GAAG,CAAC,CAAC,CAAA;AACjC,CAAA;AAEO,SAASE,SAASA,CAACC,KAAY,EAAE;AACtC,EAAA,IAAIC,MAAM,GAAGD,KAAK,CAACC,MAAM,CAAA;AAEzBR,EAAAA,MAAM,CAAC,CAAqD,mDAAA,CAAA,EAAEQ,MAAM,YAAYC,gBAAgB,CAAC,CAAA;EAEjGD,MAA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D,oDAAA,CAAA,EACtDoC,aAAa,YAAYC,WAC3B,CAAC,CAAA;AAED,EAAA,IAAIC,MAAuC,CAAA;;AAE3C;AACA;AACA,EAAA,IAAI,EAAEF,aAAa,YAAY3B,gBAAgB,CAAC,EAAE;IAChD,IAAI2B,aAAa,CAACG,UAAU,EAAE;MAC5BD,MAAM,GAAGF,aAAa,CAACG,UAAU,CAAA;AACnC,KAAC,MAAM;AACLD,MAAAA,MAAM,GAAGF,aAAa,CAACrC,OAAO,CAAC,UAAU,CAAC,CAAA;AAC5C,KAAA;AACF,GAAC,MAAM;AACLuC,IAAAA,MAAM,GAAGF,aAAa,CAACrC,OAAO,CAAC,UAAU,CAAC,CAAA;AAC5C,GAAA;AAEAC,EAAAA,MAAM,CAAC,CAAA,sEAAA,CAAwE,EAAEsC,MAAM,CAAC,CAAA;AAExF,EAAA,IAAIE,QAAQ,GAAGF,MAAM,CAACrC,gBAAgB,CAAC,OAAO,CAAC,CAAA;EAE/C,IAAIa,KAAK,GAAG,EAAE,CAAA;AAEdd,EAAAA,MAAM,CACJ,CAAA,gBAAA,EAAmBwC,QAAQ,CAACP,MAAM,CAA0BA,uBAAAA,EAAAA,MAAM,CAAoD,kDAAA,CAAA,EACtHO,QAAQ,CAACP,MAAM,KAAKA,MACtB,CAAC,CAAA;AAED,EAAA,KAAK,IAAIQ,OAAO,IAAID,QAAQ,EAAE;AAC5BxC,IAAAA,MAAM,CACJ,iEAAiE,EACjEyC,OAAO,YAAYhC,gBACrB,CAAC,CAAA;IACDK,KAAK,IAAI2B,OAAO,CAAC3B,KAAK,CAAA;AACxB,GAAA;AAEA,EAAA,OAAOA,KAAK,CAAA;AACd;;;;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/components/one-time-password/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nfunction getInputs(current: HTMLInputElement) {\n let fieldset = current.closest('fieldset');\n\n assert('[BUG]: fieldset went missing', fieldset);\n\n return [...fieldset.querySelectorAll('input')];\n}\n\nfunction nextInput(current: HTMLInputElement) {\n let inputs = getInputs(current);\n let currentIndex = inputs.indexOf(current);\n\n return inputs[currentIndex + 1];\n}\n\nexport function selectAll(event: Event) {\n let target = event.target;\n\n assert(`selectAll is only meant for use with input elements`, target instanceof HTMLInputElement);\n\n target.select();\n}\n\nexport function handlePaste(event: Event) {\n let target = event.target;\n\n assert(\n `handlePaste is only meant for use with input elements`,\n target instanceof HTMLInputElement\n );\n\n let clipboardData = (event as ClipboardEvent).clipboardData;\n\n assert(\n `Could not get clipboardData while handling the paste event on OTP. Please report this issue on the ember-primitives repo with a reproduction. Thanks!`,\n clipboardData\n );\n\n // This is typically not good to prevent paste.\n // But because of the UX we're implementing,\n // we want to split the pasted value across\n // multiple text fields\n event.preventDefault();\n\n let value = clipboardData.getData('Text');\n const digits = value;\n let i = 0;\n let currElement: HTMLInputElement | null = target;\n\n while (currElement) {\n currElement.value = digits[i++] || '';\n\n let next = nextInput(currElement);\n\n if (next instanceof HTMLInputElement) {\n currElement = next;\n } else {\n break;\n }\n }\n\n // We want to select the first field again\n // so that if someone holds paste, or\n // pastes again, they get the same result.\n target.select();\n}\n\nexport function handleNavigation(event: KeyboardEvent) {\n switch (event.key) {\n case 'Backspace':\n return handleBackspace(event);\n case 'ArrowLeft':\n return focusLeft(event);\n case 'ArrowRight':\n return focusRight(event);\n }\n}\n\nfunction focusLeft(event: Pick<Event, 'target'>) {\n let target = event.target;\n\n assert(`only allowed on input elements`, target instanceof HTMLInputElement);\n\n let input = previousInput(target);\n\n input?.focus();\n requestAnimationFrame(() => {\n input?.select();\n });\n}\n\nfunction focusRight(event: Pick<Event, 'target'>) {\n let target = event.target;\n\n assert(`only allowed on input elements`, target instanceof HTMLInputElement);\n\n let input = nextInput(target);\n\n input?.focus();\n requestAnimationFrame(() => {\n input?.select();\n });\n}\n\nconst syntheticEvent = new InputEvent('input');\n\nfunction handleBackspace(event: KeyboardEvent) {\n if (event.key !== 'Backspace') return;\n\n /**\n * We have to prevent default because we\n * - want to clear the whole field\n * - have the focus behavior keep up with the key-repeat\n * speed of the user's computer\n */\n event.preventDefault();\n\n let target = event.target;\n\n if (target && 'value' in target) {\n if (target.value === '') {\n focusLeft({ target });\n } else {\n target.value = '';\n }\n }\n\n target?.dispatchEvent(syntheticEvent);\n}\n\nfunction previousInput(current: HTMLInputElement) {\n let inputs = getInputs(current);\n let currentIndex = inputs.indexOf(current);\n\n return inputs[currentIndex - 1];\n}\n\nexport const autoAdvance = (event: Event) => {\n assert(\n '[BUG]: autoAdvance called on non-input element',\n event.target instanceof HTMLInputElement\n );\n\n let value = event.target.value;\n\n if (value.length === 0) return;\n\n if (value.length > 0) {\n if ('data' in event && event.data && typeof event.data === 'string') {\n event.target.value = event.data;\n }\n\n return focusRight(event);\n }\n};\n\nexport function getCollectiveValue(elementTarget: EventTarget | null, length: number) {\n if (!elementTarget) return;\n\n assert(\n `[BUG]: somehow the element target is not HTMLElement`,\n elementTarget instanceof HTMLElement\n );\n\n let parent: null | HTMLElement | ShadowRoot;\n\n // TODO: should this logic be extracted?\n // why is getting the target element within a shadow root hard?\n if (!(elementTarget instanceof HTMLInputElement)) {\n if (elementTarget.shadowRoot) {\n parent = elementTarget.shadowRoot;\n } else {\n parent = elementTarget.closest('fieldset');\n }\n } else {\n parent = elementTarget.closest('fieldset');\n }\n\n assert(`[BUG]: somehow the input fields were rendered without a parent element`, parent);\n\n let elements = parent.querySelectorAll('input');\n\n let value = '';\n\n assert(\n `found elements (${elements.length}) do not match length (${length}). Was the same OTP input rendered more than once?`,\n elements.length === length\n );\n\n for (let element of elements) {\n assert(\n '[BUG]: how did the queried elements become a non-input element?',\n element instanceof HTMLInputElement\n );\n value += element.value;\n }\n\n return value;\n}\n"],"names":["getInputs","current","fieldset","closest","assert","querySelectorAll","nextInput","inputs","currentIndex","indexOf","selectAll","event","target","HTMLInputElement","select","handlePaste","clipboardData","preventDefault","value","getData","digits","i","currElement","next","handleNavigation","key","handleBackspace","focusLeft","focusRight","input","previousInput","focus","requestAnimationFrame","syntheticEvent","InputEvent","dispatchEvent","autoAdvance","length","data","getCollectiveValue","elementTarget","HTMLElement","parent","shadowRoot","elements","element"],"mappings":";;AAEA,SAASA,SAASA,CAACC,OAAyB,EAAE;AAC5C,EAAA,IAAIC,QAAQ,GAAGD,OAAO,CAACE,OAAO,CAAC,UAAU,CAAC;AAE1CC,EAAAA,MAAM,CAAC,8BAA8B,EAAEF,QAAQ,CAAC;EAEhD,OAAO,CAAC,GAAGA,QAAQ,CAACG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAChD;AAEA,SAASC,SAASA,CAACL,OAAyB,EAAE;AAC5C,EAAA,IAAIM,MAAM,GAAGP,SAAS,CAACC,OAAO,CAAC;AAC/B,EAAA,IAAIO,YAAY,GAAGD,MAAM,CAACE,OAAO,CAACR,OAAO,CAAC;AAE1C,EAAA,OAAOM,MAAM,CAACC,YAAY,GAAG,CAAC,CAAC;AACjC;AAEO,SAASE,SAASA,CAACC,KAAY,EAAE;AACtC,EAAA,IAAIC,MAAM,GAAGD,KAAK,CAACC,MAAM;AAEzBR,EAAAA,MAAM,CAAC,CAAqD,mDAAA,CAAA,EAAEQ,MAAM,YAAYC,gBAAgB,CAAC;EAEjGD,MAAM,CAACE,MAAM,EAAE;AACjB;AAEO,SAASC,WAAWA,CAACJ,KAAY,EAAE;AACxC,EAAA,IAAIC,MAAM,GAAGD,KAAK,CAACC,MAAM;AAEzBR,EAAAA,MAAM,CACJ,CAAuD,qDAAA,CAAA,EACvDQ,MAAM,YAAYC,gBACpB,CAAC;AAED,EAAA,IAAIG,aAAa,GAAIL,KAAK,CAAoBK,aAAa;AAE3DZ,EAAAA,MAAM,CACJ,CAAA,qJAAA,CAAuJ,EACvJY,aACF,CAAC;;AAED;AACA;AACA;AACA;EACAL,KAAK,CAACM,cAAc,EAAE;AAEtB,EAAA,IAAIC,KAAK,GAAGF,aAAa,CAACG,OAAO,CAAC,MAAM,CAAC;EACzC,MAAMC,MAAM,GA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yC,OAAO,YAAYhC,gBACrB,CAAC;IACDK,KAAK,IAAI2B,OAAO,CAAC3B,KAAK;AACxB;AAEA,EAAA,OAAOA,KAAK;AACd;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sources":["../../src/floating-ui/middleware.ts"],"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"],"names":["exposeMetadata","name","fn","data"],"mappings":"AAEO,SAASA,cAAcA,GAAe;EAC3C,OAAO;AACLC,IAAAA,IAAI,EAAE,UAAU;IAChBC,EAAE,EAAGC,IAAI,IAAK;AACZ;MACA,OAAO;AACLA,QAAAA
|
|
1
|
+
{"version":3,"file":"middleware.js","sources":["../../src/floating-ui/middleware.ts"],"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"],"names":["exposeMetadata","name","fn","data"],"mappings":"AAEO,SAASA,cAAcA,GAAe;EAC3C,OAAO;AACLC,IAAAA,IAAI,EAAE,UAAU;IAChBC,EAAE,EAAGC,IAAI,IAAK;AACZ;MACA,OAAO;AACLA,QAAAA;OACD;AACH;GACD;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifier.js","sources":["../../src/floating-ui/modifier.ts"],"sourcesContent":["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 let update = async () => {\n let { 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 let 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 setData?.(middlewareData['metadata']);\n };\n\n update();\n\n let 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"],"names":["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","exposeMetadata","referenceHidden","margin","visibility","cleanup","autoUpdate"],"mappings":";;;;;AAsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,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
|
|
1
|
+
{"version":3,"file":"modifier.js","sources":["../../src/floating-ui/modifier.ts"],"sourcesContent":["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 let update = async () => {\n let { 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 let 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 setData?.(middlewareData['metadata']);\n };\n\n update();\n\n let 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"],"names":["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","exposeMetadata","referenceHidden","margin","visibility","cleanup","autoUpdate"],"mappings":";;;;;AAsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,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,CAACV,iBAAiB,CAAC,GACzCA,iBAAiB;EAEvBW,MAAM,CACJ,8BAA8B,EAC9BH,gBAAgB,YAAYI,WAAW,IAAIJ,gBAAgB,YAAYK,UACzE,CAAC;EAEDF,MAAM,CACJ,6BAA6B,EAC7BZ,eAAe,YAAYa,WAAW,IAAIZ,iBAAiB,YAAYa,UACzE,CAAC;AAEDF,EAAAA,MAAM,CACJ,4DAA4D,EAC5DZ,eAAe,KAAKC,iBACtB,CAAC;EAEDW,MAAM,CAAC,qDAAqD,EAAEG,KAAK,CAACC,OAAO,CAACT,UAAU,CAAC,CAAC;AAExFU,EAAAA,MAAM,CAACC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;;"}
|
package/dist/helpers/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../src/helpers/link.ts"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { assert } from '@ember/debug';\nimport { service } from '@ember/service';\n\nimport { handle } from '../proper-links.ts';\n\nimport type RouterService from '@ember/routing/router-service';\n\nexport interface Signature {\n Args: {\n Positional: [href: string];\n Named: {\n includeActiveQueryParams?: boolean | string[];\n activeOnSubPaths?: boolean;\n };\n };\n Return: {\n isExternal: boolean;\n isActive: boolean;\n handleClick: (event: MouseEvent) => void;\n };\n}\n\nexport default class Link extends Helper<Signature> {\n @service declare router: RouterService;\n\n compute(\n [href]: [href: string],\n {\n includeActiveQueryParams = false,\n activeOnSubPaths = false,\n }: { includeActiveQueryParams?: boolean | string[]; activeOnSubPaths?: boolean }\n ) {\n assert('href was not passed in', href);\n\n const router = this.router;\n const handleClick = (event: MouseEvent) => {\n assert('[BUG]', event.target instanceof HTMLAnchorElement);\n\n handle(router, event.target, [], event);\n };\n\n return {\n isExternal: isExternal(href),\n get isActive() {\n return isActive(router, href, includeActiveQueryParams, activeOnSubPaths);\n },\n handleClick,\n };\n }\n}\n\nexport const link = Link;\n\nexport function isExternal(href: string) {\n if (!href) return false;\n if (href.startsWith('#')) return false;\n if (href.startsWith('/')) return false;\n\n return location.origin !== new URL(href).origin;\n}\n\nexport function isActive(\n router: RouterService,\n href: string,\n includeQueryParams?: boolean | string[],\n activeOnSubPaths?: boolean\n) {\n if (!includeQueryParams) {\n /**\n * is Active doesn't understand `href`, so we have to convert to RouteInfo-esque\n */\n let info = router.recognize(href);\n\n if (info) {\n let dynamicSegments = getParams(info);\n let routeName = activeOnSubPaths ? info.name.replace(/\\.index$/, '') : info.name;\n\n return router.isActive(routeName, ...dynamicSegments);\n }\n\n return false;\n }\n\n let url = new URL(href, location.origin);\n let hrefQueryParams = new URLSearchParams(url.searchParams);\n let hrefPath = url.pathname;\n\n const currentPath = router.currentURL?.split('?')[0];\n\n if (!currentPath) return false;\n\n if (activeOnSubPaths ? !currentPath.startsWith(hrefPath) : hrefPath !== currentPath) return false;\n\n const currentQueryParams = router.currentRoute?.queryParams;\n\n if (!currentQueryParams) return false;\n\n if (includeQueryParams === true) {\n return Object.entries(currentQueryParams).every(([key, value]) => {\n return hrefQueryParams.get(key) === value;\n });\n }\n\n return includeQueryParams.every((key) => {\n return hrefQueryParams.get(key) === currentQueryParams[key];\n });\n}\n\ntype RouteInfo = ReturnType<RouterService['recognize']>;\n\nexport function getParams(currentRouteInfo: RouteInfo) {\n let params: Record<string, string | unknown | undefined>[] = [];\n\n while (currentRouteInfo?.parent) {\n let currentParams = currentRouteInfo.params;\n\n params = currentParams ? [currentParams, ...params] : params;\n currentRouteInfo = currentRouteInfo.parent;\n }\n\n return params.map(Object.values).flat();\n}\n"],"names":["Link","Helper","g","prototype","service","i","void 0","compute","href","includeActiveQueryParams","activeOnSubPaths","assert","router","handleClick","event","target","HTMLAnchorElement","handle","isExternal","isActive","link","startsWith","location","origin","URL","includeQueryParams","info","recognize","dynamicSegments","getParams","routeName","name","replace","url","hrefQueryParams","URLSearchParams","searchParams","hrefPath","pathname","currentPath","currentURL","split","currentQueryParams","currentRoute","queryParams","Object","entries","every","key","value","get","currentRouteInfo","params","parent","currentParams","map","values","flat"],"mappings":";;;;;;AAuBe,MAAMA,IAAI,SAASC,MAAM,CAAY;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CACjDC,OAAO,CAAA,CAAA
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../src/helpers/link.ts"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { assert } from '@ember/debug';\nimport { service } from '@ember/service';\n\nimport { handle } from '../proper-links.ts';\n\nimport type RouterService from '@ember/routing/router-service';\n\nexport interface Signature {\n Args: {\n Positional: [href: string];\n Named: {\n includeActiveQueryParams?: boolean | string[];\n activeOnSubPaths?: boolean;\n };\n };\n Return: {\n isExternal: boolean;\n isActive: boolean;\n handleClick: (event: MouseEvent) => void;\n };\n}\n\nexport default class Link extends Helper<Signature> {\n @service declare router: RouterService;\n\n compute(\n [href]: [href: string],\n {\n includeActiveQueryParams = false,\n activeOnSubPaths = false,\n }: { includeActiveQueryParams?: boolean | string[]; activeOnSubPaths?: boolean }\n ) {\n assert('href was not passed in', href);\n\n const router = this.router;\n const handleClick = (event: MouseEvent) => {\n assert('[BUG]', event.target instanceof HTMLAnchorElement);\n\n handle(router, event.target, [], event);\n };\n\n return {\n isExternal: isExternal(href),\n get isActive() {\n return isActive(router, href, includeActiveQueryParams, activeOnSubPaths);\n },\n handleClick,\n };\n }\n}\n\nexport const link = Link;\n\nexport function isExternal(href: string) {\n if (!href) return false;\n if (href.startsWith('#')) return false;\n if (href.startsWith('/')) return false;\n\n return location.origin !== new URL(href).origin;\n}\n\nexport function isActive(\n router: RouterService,\n href: string,\n includeQueryParams?: boolean | string[],\n activeOnSubPaths?: boolean\n) {\n if (!includeQueryParams) {\n /**\n * is Active doesn't understand `href`, so we have to convert to RouteInfo-esque\n */\n let info = router.recognize(href);\n\n if (info) {\n let dynamicSegments = getParams(info);\n let routeName = activeOnSubPaths ? info.name.replace(/\\.index$/, '') : info.name;\n\n return router.isActive(routeName, ...dynamicSegments);\n }\n\n return false;\n }\n\n let url = new URL(href, location.origin);\n let hrefQueryParams = new URLSearchParams(url.searchParams);\n let hrefPath = url.pathname;\n\n const currentPath = router.currentURL?.split('?')[0];\n\n if (!currentPath) return false;\n\n if (activeOnSubPaths ? !currentPath.startsWith(hrefPath) : hrefPath !== currentPath) return false;\n\n const currentQueryParams = router.currentRoute?.queryParams;\n\n if (!currentQueryParams) return false;\n\n if (includeQueryParams === true) {\n return Object.entries(currentQueryParams).every(([key, value]) => {\n return hrefQueryParams.get(key) === value;\n });\n }\n\n return includeQueryParams.every((key) => {\n return hrefQueryParams.get(key) === currentQueryParams[key];\n });\n}\n\ntype RouteInfo = ReturnType<RouterService['recognize']>;\n\nexport function getParams(currentRouteInfo: RouteInfo) {\n let params: Record<string, string | unknown | undefined>[] = [];\n\n while (currentRouteInfo?.parent) {\n let currentParams = currentRouteInfo.params;\n\n params = currentParams ? [currentParams, ...params] : params;\n currentRouteInfo = currentRouteInfo.parent;\n }\n\n return params.map(Object.values).flat();\n}\n"],"names":["Link","Helper","g","prototype","service","i","void 0","compute","href","includeActiveQueryParams","activeOnSubPaths","assert","router","handleClick","event","target","HTMLAnchorElement","handle","isExternal","isActive","link","startsWith","location","origin","URL","includeQueryParams","info","recognize","dynamicSegments","getParams","routeName","name","replace","url","hrefQueryParams","URLSearchParams","searchParams","hrefPath","pathname","currentPath","currentURL","split","currentQueryParams","currentRoute","queryParams","Object","entries","every","key","value","get","currentRouteInfo","params","parent","currentParams","map","values","flat"],"mappings":";;;;;;AAuBe,MAAMA,IAAI,SAASC,MAAM,CAAY;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CACjDC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAAC,KAAA,CAAA;AAERC,EAAAA,OAAOA,CACL,CAACC,IAAI,CAAiB,EACtB;AACEC,IAAAA,wBAAwB,GAAG,KAAK;AAChCC,IAAAA,gBAAgB,GAAG;AAC0D,GAAC,EAChF;AACAC,IAAAA,MAAM,CAAC,wBAAwB,EAAEH,IAAI,CAAC;AAEtC,IAAA,MAAMI,MAAM,GAAG,IAAI,CAACA,MAAM;IAC1B,MAAMC,WAAW,GAAIC,KAAiB,IAAK;MACzCH,MAAM,CAAC,OAAO,EAAEG,KAAK,CAACC,MAAM,YAAYC,iBAAiB,CAAC;MAE1DC,MAAM,CAACL,MAAM,EAAEE,KAAK,CAACC,MAAM,EAAE,EAAE,EAAED,KAAK,CAAC;KACxC;IAED,OAAO;AACLI,MAAAA,UAAU,EAAEA,UAAU,CAACV,IAAI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;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sources":["../../src/helpers/service.ts"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { assert } from '@ember/debug';\nimport { getOwner } from '@ember/owner';\n\nimport type { Registry } from '@ember/service';\nimport type Service from '@ember/service';\n\nexport interface Signature<Key extends keyof Registry> {\n Args: {\n Positional: [Key];\n };\n Return: Registry[Key] & Service;\n}\n\nexport default class GetService<Key extends keyof Registry> extends Helper<Signature<Key>> {\n compute(positional: [Key]): Registry[Key] & Service {\n let owner = getOwner(this);\n\n assert(`Could not get owner.`, owner);\n\n return owner.lookup(`service:${positional[0]}`) as Registry[Key] & Service;\n }\n}\n\nexport const service = GetService;\n"],"names":["GetService","Helper","compute","positional","owner","getOwner","assert","lookup","service"],"mappings":";;;;AAce,MAAMA,UAAU,SAAqCC,MAAM,CAAiB;EACzFC,OAAOA,CAACC,UAAiB,EAA2B;AAClD,IAAA,IAAIC,KAAK,GAAGC,QAAQ,CAAC,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"service.js","sources":["../../src/helpers/service.ts"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { assert } from '@ember/debug';\nimport { getOwner } from '@ember/owner';\n\nimport type { Registry } from '@ember/service';\nimport type Service from '@ember/service';\n\nexport interface Signature<Key extends keyof Registry> {\n Args: {\n Positional: [Key];\n };\n Return: Registry[Key] & Service;\n}\n\nexport default class GetService<Key extends keyof Registry> extends Helper<Signature<Key>> {\n compute(positional: [Key]): Registry[Key] & Service {\n let owner = getOwner(this);\n\n assert(`Could not get owner.`, owner);\n\n return owner.lookup(`service:${positional[0]}`) as Registry[Key] & Service;\n }\n}\n\nexport const service = GetService;\n"],"names":["GetService","Helper","compute","positional","owner","getOwner","assert","lookup","service"],"mappings":";;;;AAce,MAAMA,UAAU,SAAqCC,MAAM,CAAiB;EACzFC,OAAOA,CAACC,UAAiB,EAA2B;AAClD,IAAA,IAAIC,KAAK,GAAGC,QAAQ,CAAC,IAAI,CAAC;AAE1BC,IAAAA,MAAM,CAAC,CAAA,oBAAA,CAAsB,EAAEF,KAAK,CAAC;IAErC,OAAOA,KAAK,CAACG,MAAM,CAAC,CAAA,QAAA,EAAWJ,UAAU,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACjD;AACF;AAEO,MAAMK,OAAO,GAAGR;;;;"}
|
package/dist/iframe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.js","sources":["../src/iframe.ts"],"sourcesContent":["/**\n * Returns true if the current frame is within an iframe.\n *\n * ```gjs\n * import { inIframe } from 'ember-primitives/iframe';\n *\n * <template>\n * {{#if (inFrame)}}\n * only show content in an iframe\n * {{/if}}\n * </template>\n * ```\n */\nexport const inIframe = () => window.self !== window.top;\n\n/**\n * Returns true if the current frame is not within an iframe.\n *\n * ```gjs\n * import { notInIframe } from 'ember-primitives/iframe';\n *\n * <template>\n * {{#if (notInIframe)}}\n * only show content when not in an iframe\n * This is also the default if your site/app\n * does not use iframes\n * {{/if}}\n * </template>\n * ```\n */\nexport const notInIframe = () => !inIframe();\n"],"names":["inIframe","window","self","top","notInIframe"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAGA,MAAMC,MAAM,CAACC,IAAI,KAAKD,MAAM,CAACE
|
|
1
|
+
{"version":3,"file":"iframe.js","sources":["../src/iframe.ts"],"sourcesContent":["/**\n * Returns true if the current frame is within an iframe.\n *\n * ```gjs\n * import { inIframe } from 'ember-primitives/iframe';\n *\n * <template>\n * {{#if (inFrame)}}\n * only show content in an iframe\n * {{/if}}\n * </template>\n * ```\n */\nexport const inIframe = () => window.self !== window.top;\n\n/**\n * Returns true if the current frame is not within an iframe.\n *\n * ```gjs\n * import { notInIframe } from 'ember-primitives/iframe';\n *\n * <template>\n * {{#if (notInIframe)}}\n * only show content when not in an iframe\n * This is also the default if your site/app\n * does not use iframes\n * {{/if}}\n * </template>\n * ```\n */\nexport const notInIframe = () => !inIframe();\n"],"names":["inIframe","window","self","top","notInIframe"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAGA,MAAMC,MAAM,CAACC,IAAI,KAAKD,MAAM,CAACE;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAGA,MAAM,CAACJ,QAAQ;;;;"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * DANGER: this is a *barrel file*\n *\n * It forces the whole library to be loaded and all dependencies.\n *\n * If you have a small app, you probably don't want to import from here -- instead import from each sub-path.\n */\nimport { importSync, isDevelopingApp, macroCondition } from '@embroider/macros';\n\nif (macroCondition(isDevelopingApp())) {\n importSync('./components/violations.css');\n}\n\nexport { Accordion } from './components/accordion.gts';\nexport type {\n AccordionContentExternalSignature,\n AccordionHeaderExternalSignature,\n AccordionItemExternalSignature,\n AccordionTriggerExternalSignature,\n} from './components/accordion/public.ts';\nexport { Avatar } from './components/avatar.gts';\nexport { Dialog, Dialog as Modal } from './components/dialog.gts';\nexport { ExternalLink } from './components/external-link.gts';\nexport { Form } from './components/form.gts';\nexport { StickyFooter } from './components/layout/sticky-footer.gts';\nexport { Link } from './components/link.gts';\nexport { Menu } from './components/menu.gts';\nexport { OTP, OTPInput } from './components/one-time-password/index.gts';\nexport { Popover } from './components/popover.gts';\nexport { Portal } from './components/portal.gts';\nexport { PortalTargets } from './components/portal-targets.gts';\nexport { TARGETS as PORTALS } from './components/portal-targets.gts';\nexport { Progress } from './components/progress.gts';\nexport { Scroller } from './components/scroller.gts';\nexport { Shadowed } from './components/shadowed.gts';\nexport { Switch } from './components/switch.gts';\nexport { Toggle } from './components/toggle.gts';\nexport { ToggleGroup } from './components/toggle-group.gts';\nexport { Zoetrope } from './components/zoetrope.ts';\nexport * from './helpers.ts';\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * DANGER: this is a *barrel file*\n *\n * It forces the whole library to be loaded and all dependencies.\n *\n * If you have a small app, you probably don't want to import from here -- instead import from each sub-path.\n */\nimport { importSync, isDevelopingApp, macroCondition } from '@embroider/macros';\n\nif (macroCondition(isDevelopingApp())) {\n importSync('./components/violations.css');\n}\n\nexport { Accordion } from './components/accordion.gts';\nexport type {\n AccordionContentExternalSignature,\n AccordionHeaderExternalSignature,\n AccordionItemExternalSignature,\n AccordionTriggerExternalSignature,\n} from './components/accordion/public.ts';\nexport { Avatar } from './components/avatar.gts';\nexport { Dialog, Dialog as Modal } from './components/dialog.gts';\nexport { ExternalLink } from './components/external-link.gts';\nexport { Form } from './components/form.gts';\nexport { StickyFooter } from './components/layout/sticky-footer.gts';\nexport { Link } from './components/link.gts';\nexport { Menu } from './components/menu.gts';\nexport { OTP, OTPInput } from './components/one-time-password/index.gts';\nexport { Popover } from './components/popover.gts';\nexport { Portal } from './components/portal.gts';\nexport { PortalTargets } from './components/portal-targets.gts';\nexport { TARGETS as PORTALS } from './components/portal-targets.gts';\nexport { Progress } from './components/progress.gts';\nexport { Scroller } from './components/scroller.gts';\nexport { Shadowed } from './components/shadowed.gts';\nexport { Switch } from './components/switch.gts';\nexport { Toggle } from './components/toggle.gts';\nexport { ToggleGroup } from './components/toggle-group.gts';\nexport { Zoetrope } from './components/zoetrope.ts';\nexport * from './helpers.ts';\n"],"names":["macroCondition","isDevelopingApp","importSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,IAAIA,cAAc,CAACC,eAAe,EAAE,CAAC,EAAE;EACrCC,UAAU,CAAC,6BAA6B,CAAC;AAC3C"}
|
package/dist/proper-links.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-links.js","sources":["../src/proper-links.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\nimport { getOwner } from '@ember/owner';\n\nimport { getAnchor, shouldHandle } from 'should-handle-link';\n\nimport type EmberRouter from '@ember/routing/router';\nimport type RouterService from '@ember/routing/router-service';\n\nexport { shouldHandle } from 'should-handle-link';\n\ntype Constructor<T extends object = object> = { new (...args: any[]): T };\n\nexport interface Options {\n ignore?: string[];\n}\n\nexport function properLinks(\n options: Options\n): <Instance extends object, Klass = { new (...args: any[]): Instance }>(klass: Klass) => Klass;\n\nexport function properLinks<Instance extends object, Klass = { new (...args: any[]): Instance }>(\n klass: Klass\n): Klass;\n/**\n * @internal\n */\nexport function properLinks<Instance extends object, Klass = { new (...args: any[]): Instance }>(\n options: Options,\n klass: Klass\n): Klass;\n\nexport function properLinks<Instance extends object, Klass = { new (...args: any[]): Instance }>(\n ...args: [Options] | [Klass] | [Options, Klass]\n): Klass | ((klass: Klass) => Klass) {\n let options: Options = {};\n\n let klass: undefined | Klass = undefined;\n\n if (args.length === 2) {\n options = args[0] as Options;\n klass = args[1] as Klass;\n } else if (args.length === 1) {\n if (typeof args[0] === 'object') {\n // TODO: how to get first arg type correct?\n return (klass: Klass) => properLinks(args[0] as any, klass);\n } else {\n klass = args[0];\n }\n }\n\n let ignore = options.ignore || [];\n\n assert(`klass was not defined. possibile incorrect arity given to properLinks`, klass);\n\n return class RouterWithProperLinks extends (klass as unknown as Constructor<EmberRouter>) {\n // SAFETY: we literally do not care about the args' type here,\n // because we just call super\n constructor(...args: any[]) {\n super(...args);\n\n setup(this, ignore);\n }\n } as unknown as Klass;\n}\n\n/**\n * Setup proper links without a decorator.\n * This function only requires that a framework object with an owner is passed.\n */\nexport function setup(parent: object, ignore?: string[]) {\n const handler = (event: MouseEvent) => {\n /**\n * event.target may not be an anchor,\n * it may be a span, svg, img, or any number of elements nested in <a>...</a>\n */\n let interactive = getAnchor(event);\n\n if (!interactive) return;\n\n let owner = getOwner(parent);\n\n assert('owner is not present', owner);\n\n let routerService = owner.lookup('service:router');\n\n handle(routerService, interactive, ignore ?? [], event);\n };\n\n document.body.addEventListener('click', handler, false);\n\n registerDestructor(parent, () => document.body.removeEventListener('click', handler));\n}\n\nexport function handle(\n router: RouterService,\n element: HTMLAnchorElement,\n ignore: string[],\n event: MouseEvent\n) {\n if (!shouldHandle(location.href, element, event, ignore)) {\n return;\n }\n\n let url = new URL(element.href);\n\n let fullHref = `${url.pathname}${url.search}${url.hash}`;\n\n let rootURL = router.rootURL;\n\n let withoutRootURL = fullHref.slice(rootURL.length);\n\n // re-add the \"root\" sigil\n // we removed it when we chopped off the rootURL,\n // because the rootURL often has this attached to it as well\n if (!withoutRootURL.startsWith('/')) {\n withoutRootURL = `/${withoutRootURL}`;\n }\n\n try {\n let routeInfo = router.recognize(fullHref);\n\n if (routeInfo) {\n event.preventDefault();\n event.stopImmediatePropagation();\n event.stopPropagation();\n\n router.transitionTo(withoutRootURL);\n\n return false;\n }\n } catch (e) {\n if (e instanceof Error && e.name === 'UnrecognizedURLError') {\n return;\n }\n\n throw e;\n }\n}\n"],"names":["properLinks","args","options","klass","undefined","length","ignore","assert","RouterWithProperLinks","constructor","setup","parent","handler","event","interactive","getAnchor","owner","getOwner","routerService","lookup","handle","document","body","addEventListener","registerDestructor","removeEventListener","router","element","shouldHandle","location","href","url","URL","fullHref","pathname","search","hash","rootURL","withoutRootURL","slice","startsWith","routeInfo","recognize","preventDefault","stopImmediatePropagation","stopPropagation","transitionTo","e","Error","name"],"mappings":";;;;;;AAAA;;AAyBA;AACA;AACA;;AAMO,SAASA,WAAWA,CACzB,GAAGC,IAA4C,EACZ;EACnC,IAAIC,OAAgB,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"proper-links.js","sources":["../src/proper-links.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\nimport { getOwner } from '@ember/owner';\n\nimport { getAnchor, shouldHandle } from 'should-handle-link';\n\nimport type EmberRouter from '@ember/routing/router';\nimport type RouterService from '@ember/routing/router-service';\n\nexport { shouldHandle } from 'should-handle-link';\n\ntype Constructor<T extends object = object> = { new (...args: any[]): T };\n\nexport interface Options {\n ignore?: string[];\n}\n\nexport function properLinks(\n options: Options\n): <Instance extends object, Klass = { new (...args: any[]): Instance }>(klass: Klass) => Klass;\n\nexport function properLinks<Instance extends object, Klass = { new (...args: any[]): Instance }>(\n klass: Klass\n): Klass;\n/**\n * @internal\n */\nexport function properLinks<Instance extends object, Klass = { new (...args: any[]): Instance }>(\n options: Options,\n klass: Klass\n): Klass;\n\nexport function properLinks<Instance extends object, Klass = { new (...args: any[]): Instance }>(\n ...args: [Options] | [Klass] | [Options, Klass]\n): Klass | ((klass: Klass) => Klass) {\n let options: Options = {};\n\n let klass: undefined | Klass = undefined;\n\n if (args.length === 2) {\n options = args[0] as Options;\n klass = args[1] as Klass;\n } else if (args.length === 1) {\n if (typeof args[0] === 'object') {\n // TODO: how to get first arg type correct?\n return (klass: Klass) => properLinks(args[0] as any, klass);\n } else {\n klass = args[0];\n }\n }\n\n let ignore = options.ignore || [];\n\n assert(`klass was not defined. possibile incorrect arity given to properLinks`, klass);\n\n return class RouterWithProperLinks extends (klass as unknown as Constructor<EmberRouter>) {\n // SAFETY: we literally do not care about the args' type here,\n // because we just call super\n constructor(...args: any[]) {\n super(...args);\n\n setup(this, ignore);\n }\n } as unknown as Klass;\n}\n\n/**\n * Setup proper links without a decorator.\n * This function only requires that a framework object with an owner is passed.\n */\nexport function setup(parent: object, ignore?: string[]) {\n const handler = (event: MouseEvent) => {\n /**\n * event.target may not be an anchor,\n * it may be a span, svg, img, or any number of elements nested in <a>...</a>\n */\n let interactive = getAnchor(event);\n\n if (!interactive) return;\n\n let owner = getOwner(parent);\n\n assert('owner is not present', owner);\n\n let routerService = owner.lookup('service:router');\n\n handle(routerService, interactive, ignore ?? [], event);\n };\n\n document.body.addEventListener('click', handler, false);\n\n registerDestructor(parent, () => document.body.removeEventListener('click', handler));\n}\n\nexport function handle(\n router: RouterService,\n element: HTMLAnchorElement,\n ignore: string[],\n event: MouseEvent\n) {\n if (!shouldHandle(location.href, element, event, ignore)) {\n return;\n }\n\n let url = new URL(element.href);\n\n let fullHref = `${url.pathname}${url.search}${url.hash}`;\n\n let rootURL = router.rootURL;\n\n let withoutRootURL = fullHref.slice(rootURL.length);\n\n // re-add the \"root\" sigil\n // we removed it when we chopped off the rootURL,\n // because the rootURL often has this attached to it as well\n if (!withoutRootURL.startsWith('/')) {\n withoutRootURL = `/${withoutRootURL}`;\n }\n\n try {\n let routeInfo = router.recognize(fullHref);\n\n if (routeInfo) {\n event.preventDefault();\n event.stopImmediatePropagation();\n event.stopPropagation();\n\n router.transitionTo(withoutRootURL);\n\n return false;\n }\n } catch (e) {\n if (e instanceof Error && e.name === 'UnrecognizedURLError') {\n return;\n }\n\n throw e;\n }\n}\n"],"names":["properLinks","args","options","klass","undefined","length","ignore","assert","RouterWithProperLinks","constructor","setup","parent","handler","event","interactive","getAnchor","owner","getOwner","routerService","lookup","handle","document","body","addEventListener","registerDestructor","removeEventListener","router","element","shouldHandle","location","href","url","URL","fullHref","pathname","search","hash","rootURL","withoutRootURL","slice","startsWith","routeInfo","recognize","preventDefault","stopImmediatePropagation","stopPropagation","transitionTo","e","Error","name"],"mappings":";;;;;;AAAA;;AAyBA;AACA;AACA;;AAMO,SAASA,WAAWA,CACzB,GAAGC,IAA4C,EACZ;EACnC,IAAIC,OAAgB,GAAG,EAAE;EAEzB,IAAIC,KAAwB,GAAGC,SAAS;AAExC,EAAA,IAAIH,IAAI,CAACI,MAAM,KAAK,CAAC,EAAE;AACrBH,IAAAA,OAAO,GAAGD,IAAI,CAAC,CAAC,CAAY;AAC5BE,IAAAA,KAAK,GAAGF,IAAI,CAAC,CAAC,CAAU;AAC1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AA;AACF;AAEA,IAAA,MAAMF,CAAC;AACT;AACF;;;;"}
|
package/dist/tabster.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
2
|
+
|
|
3
|
+
async function setupTabster(
|
|
4
|
+
/**
|
|
5
|
+
* A destroyable object.
|
|
6
|
+
* This is needed so that when the app (or tests) or unmounted or ending,
|
|
7
|
+
* the tabster instance can be disposed of.
|
|
8
|
+
*/
|
|
9
|
+
context, {
|
|
10
|
+
tabster,
|
|
11
|
+
setTabsterRoot
|
|
12
|
+
} = {}) {
|
|
13
|
+
const {
|
|
14
|
+
createTabster,
|
|
15
|
+
getDeloser,
|
|
16
|
+
getMover,
|
|
17
|
+
getTabster,
|
|
18
|
+
disposeTabster
|
|
19
|
+
} = await import('tabster');
|
|
20
|
+
tabster ??= true;
|
|
21
|
+
setTabsterRoot ??= true;
|
|
22
|
+
if (!tabster) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let existing = getTabster(window);
|
|
26
|
+
let primitivesTabster = existing ?? createTabster(window);
|
|
27
|
+
getMover(primitivesTabster);
|
|
28
|
+
getDeloser(primitivesTabster);
|
|
29
|
+
if (setTabsterRoot) {
|
|
30
|
+
document.body.setAttribute('data-tabster', '{ "root": {} }');
|
|
31
|
+
}
|
|
32
|
+
registerDestructor(context, () => {
|
|
33
|
+
disposeTabster(primitivesTabster);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { setupTabster };
|
|
38
|
+
//# sourceMappingURL=tabster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabster.js","sources":["../src/tabster.ts"],"sourcesContent":["import { registerDestructor } from '@ember/destroyable';\n\nexport async function setupTabster(\n /**\n * A destroyable object.\n * This is needed so that when the app (or tests) or unmounted or ending,\n * the tabster instance can be disposed of.\n */\n context: object,\n {\n tabster,\n setTabsterRoot,\n }: {\n /**\n * Let this setup function initalize tabster.\n * https://tabster.io/docs/core\n *\n * This should be done only once per application as we don't want\n * focus managers fighting with each other.\n *\n * Defaults to `true`,\n *\n * Will fallback to an existing tabster instance automatically if `getTabster` returns a value.\n *\n * If `false` is explicitly passed here, you'll also be in charge of teardown.\n */\n tabster?: boolean;\n setTabsterRoot?: boolean;\n } = {}\n) {\n const { createTabster, getDeloser, getMover, getTabster, disposeTabster } = await import(\n 'tabster'\n );\n\n tabster ??= true;\n setTabsterRoot ??= true;\n\n if (!tabster) {\n return;\n }\n\n let existing = getTabster(window);\n let primitivesTabster = existing ?? createTabster(window);\n\n getMover(primitivesTabster);\n getDeloser(primitivesTabster);\n\n if (setTabsterRoot) {\n document.body.setAttribute('data-tabster', '{ \"root\": {} }');\n }\n\n registerDestructor(context, () => {\n disposeTabster(primitivesTabster);\n });\n}\n"],"names":["setupTabster","context","tabster","setTabsterRoot","createTabster","getDeloser","getMover","getTabster","disposeTabster","existing","window","primitivesTabster","document","body","setAttribute","registerDestructor"],"mappings":";;AAEO,eAAeA,YAAYA;AAChC;AACF;AACA;AACA;AACA;AACEC,OAAe,EACf;EACEC,OAAO;AACPC,EAAAA;AAiBF,CAAC,GAAG,EAAE,EACN;EACA,MAAM;IAAEC,aAAa;IAAEC,UAAU;IAAEC,QAAQ;IAAEC,UAAU;AAAEC,IAAAA;AAAe,GAAC,GAAG,MAAM,OAChF,SACF,CAAC;AAEDN,EAAAA,OAAO,KAAK,IAAI;AAChBC,EAAAA,cAAc,KAAK,IAAI;EAEvB,IAAI,CAACD,OAAO,EAAE;AACZ,IAAA;AACF;AAEA,EAAA,IAAIO,QAAQ,GAAGF,UAAU,CAACG,MAAM,CAAC;AACjC,EAAA,IAAIC,iBAAiB,GAAGF,QAAQ,IAAIL,aAAa,CAACM,MAAM,CAAC;EAEzDJ,QAAQ,CAACK,iBAAiB,CAAC;EAC3BN,UAAU,CAACM,iBAAiB,CAAC;AAE7B,EAAA,IAAIR,cAAc,EAAE;IAClBS,QAAQ,CAACC,IAAI,CAACC,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC;AAC9D;EAEAC,kBAAkB,CAACd,OAAO,EAAE,MAAM;IAChCO,cAAc,CAACG,iBAAiB,CAAC;AACnC,GAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { assert } from '@ember/debug';
|
|
2
|
+
import { setupTabster as setupTabster$1 } from '../tabster.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Sets up all support utilities for primitive components.
|
|
5
6
|
* Including the tabster root.
|
|
6
7
|
*/
|
|
7
|
-
function setup(owner) {
|
|
8
|
-
|
|
9
|
-
assert('Could not find the ember-primitives service', service);
|
|
10
|
-
service.setup({
|
|
8
|
+
async function setup(owner) {
|
|
9
|
+
setupTabster$1(owner, {
|
|
11
10
|
setTabsterRoot: false
|
|
12
11
|
});
|
|
13
12
|
document.querySelector('#ember-testing')?.setAttribute('data-tabster', '{ "root": {} }');
|
|
14
13
|
}
|
|
14
|
+
function setupTabster(hooks) {
|
|
15
|
+
hooks.beforeEach(function () {
|
|
16
|
+
let owner = this.owner;
|
|
17
|
+
assert(`Test does not have an owner, be sure to use setupRenderingTest, setupTest, or setupApplicationTest (from ember-qunit (or similar))`, owner);
|
|
18
|
+
setup(this.owner);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
15
21
|
|
|
16
|
-
export {
|
|
22
|
+
export { setupTabster };
|
|
17
23
|
//# sourceMappingURL=a11y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.js","sources":["../../src/test-support/a11y.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport
|
|
1
|
+
{"version":3,"file":"a11y.js","sources":["../../src/test-support/a11y.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { setupTabster as _setupTabster } from '../tabster.ts';\n\nimport type Owner from '@ember/owner';\n\n/**\n * Sets up all support utilities for primitive components.\n * Including the tabster root.\n */\nasync function setup(owner: Owner) {\n _setupTabster(owner, { setTabsterRoot: false });\n\n document.querySelector('#ember-testing')?.setAttribute('data-tabster', '{ \"root\": {} }');\n}\n\nexport function setupTabster(hooks: {\n beforeEach: (callback: () => void | Promise<void>) => unknown;\n}) {\n hooks.beforeEach(function (this: { owner: object }) {\n let owner = this.owner;\n\n assert(\n `Test does not have an owner, be sure to use setupRenderingTest, setupTest, or setupApplicationTest (from ember-qunit (or similar))`,\n owner\n );\n\n setup(this.owner as Owner);\n });\n}\n"],"names":["setup","owner","_setupTabster","setTabsterRoot","document","querySelector","setAttribute","setupTabster","hooks","beforeEach","assert"],"mappings":";;;AAMA;AACA;AACA;AACA;AACA,eAAeA,KAAKA,CAACC,KAAY,EAAE;EACjCC,cAAa,CAACD,KAAK,EAAE;AAAEE,IAAAA,cAAc,EAAE;AAAM,GAAC,CAAC;EAE/CC,QAAQ,CAACC,aAAa,CAAC,gBAAgB,CAAC,EAAEC,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC;AAC1F;AAEO,SAASC,YAAYA,CAACC,KAE5B,EAAE;EACDA,KAAK,CAACC,UAAU,CAAC,YAAmC;AAClD,IAAA,IAAIR,KAAK,GAAG,IAAI,CAACA,KAAK;AAEtBS,IAAAA,MAAM,CACJ,CAAA,kIAAA,CAAoI,EACpIT,KACF,CAAC;AAEDD,IAAAA,KAAK,CAAC,IAAI,CAACC,KAAc,CAAC;AAC5B,GAAC,CAAC;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp.js","sources":["../../src/test-support/otp.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { fillIn, find, settled } from '@ember/test-helpers';\n\n/**\n * @param {string} code the code to fill the input(s) with.\n * @param {string} [ selector ] if there are multiple OTP components on a page, this can be used to select one of them.\n */\nexport async function fillOTP(code: string, selector?: string) {\n let ancestor = selector ? find(selector) : document;\n\n assert(\n `Could not find ancestor element, does your selector match an existing element?`,\n ancestor\n );\n\n let fieldset =\n ancestor instanceof HTMLFieldSetElement ? ancestor : ancestor.querySelector('fieldset');\n\n assert(\n `Could not find containing fieldset element (this holds the OTP Input fields). Was the OTP component rendered?`,\n fieldset\n );\n\n let inputs = fieldset.querySelectorAll('input');\n\n assert(\n `code cannot be longer than the available inputs. code is of length ${code.length} but there are ${inputs.length}`,\n code.length <= inputs.length\n );\n\n let chars = code.split('');\n\n assert(`OTP Input for index 0 is missing!`, inputs[0]);\n assert(`Character at index 0 is missing`, chars[0]);\n\n for (let i = 0; i < chars.length; i++) {\n let input = inputs[i];\n let char = chars[i];\n\n assert(`Input at index ${i} is missing`, input);\n assert(`Character at index ${i} is missing`, char);\n\n input.value = char;\n }\n\n await fillIn(inputs[0], chars[0]);\n\n // Account for out-of-settled-system delay due to RAF debounce.\n await new Promise((resolve) => requestAnimationFrame(resolve));\n await settled();\n}\n"],"names":["fillOTP","code","selector","ancestor","find","document","assert","fieldset","HTMLFieldSetElement","querySelector","inputs","querySelectorAll","length","chars","split","i","input","char","value","fillIn","Promise","resolve","requestAnimationFrame","settled"],"mappings":";;;AAGA;AACA;AACA;AACA;AACO,eAAeA,OAAOA,CAACC,IAAY,EAAEC,QAAiB,EAAE;EAC7D,IAAIC,QAAQ,GAAGD,QAAQ,GAAGE,IAAI,CAACF,QAAQ,CAAC,GAAGG,QAAQ
|
|
1
|
+
{"version":3,"file":"otp.js","sources":["../../src/test-support/otp.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { fillIn, find, settled } from '@ember/test-helpers';\n\n/**\n * @param {string} code the code to fill the input(s) with.\n * @param {string} [ selector ] if there are multiple OTP components on a page, this can be used to select one of them.\n */\nexport async function fillOTP(code: string, selector?: string) {\n let ancestor = selector ? find(selector) : document;\n\n assert(\n `Could not find ancestor element, does your selector match an existing element?`,\n ancestor\n );\n\n let fieldset =\n ancestor instanceof HTMLFieldSetElement ? ancestor : ancestor.querySelector('fieldset');\n\n assert(\n `Could not find containing fieldset element (this holds the OTP Input fields). Was the OTP component rendered?`,\n fieldset\n );\n\n let inputs = fieldset.querySelectorAll('input');\n\n assert(\n `code cannot be longer than the available inputs. code is of length ${code.length} but there are ${inputs.length}`,\n code.length <= inputs.length\n );\n\n let chars = code.split('');\n\n assert(`OTP Input for index 0 is missing!`, inputs[0]);\n assert(`Character at index 0 is missing`, chars[0]);\n\n for (let i = 0; i < chars.length; i++) {\n let input = inputs[i];\n let char = chars[i];\n\n assert(`Input at index ${i} is missing`, input);\n assert(`Character at index ${i} is missing`, char);\n\n input.value = char;\n }\n\n await fillIn(inputs[0], chars[0]);\n\n // Account for out-of-settled-system delay due to RAF debounce.\n await new Promise((resolve) => requestAnimationFrame(resolve));\n await settled();\n}\n"],"names":["fillOTP","code","selector","ancestor","find","document","assert","fieldset","HTMLFieldSetElement","querySelector","inputs","querySelectorAll","length","chars","split","i","input","char","value","fillIn","Promise","resolve","requestAnimationFrame","settled"],"mappings":";;;AAGA;AACA;AACA;AACA;AACO,eAAeA,OAAOA,CAACC,IAAY,EAAEC,QAAiB,EAAE;EAC7D,IAAIC,QAAQ,GAAGD,QAAQ,GAAGE,IAAI,CAACF,QAAQ,CAAC,GAAGG,QAAQ;AAEnDC,EAAAA,MAAM,CACJ,CAAA,8EAAA,CAAgF,EAChFH,QACF,CAAC;AAED,EAAA,IAAII,QAAQ,GACVJ,QAAQ,YAAYK,mBAAmB,GAAGL,QAAQ,GAAGA,QAAQ,CAACM,aAAa,CAAC,UAAU,CAAC;AAEzFH,EAAAA,MAAM,CACJ,CAAA,6GAAA,CAA+G,EAC/GC,QACF,CAAC;AAED,EAAA,IAAIG,MAAM,GAAGH,QAAQ,CAACI,gBAAgB,CAAC,OAAO,CAAC;AAE/CL,EAAAA,MAAM,CACJ,CAAsEL,mEAAAA,EAAAA,IAAI,CAACW,MAAM,CAAA,eAAA,EAAkBF,MAAM,CAACE,MAAM,CAAE,CAAA,EAClHX,IAAI,CAACW,MAAM,IAAIF,MAAM,CAACE,MACxB,CAAC;AAED,EAAA,IAAIC,KAAK,GAAGZ,IAAI,CAACa,KAAK,CAAC,EAAE,CAAC;AAE1BR,EAAAA,MAAM,CAAC,CAAmC,iCAAA,CAAA,EAAEI,MAAM,CAAC,CAAC,CAAC,CAAC;AACtDJ,EAAAA,MAAM,CAAC,CAAiC,+BAAA,CAAA,EAAEO,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnD,EAAA,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,KAAK,CAACD,MAAM,EAAEG,CAAC,EAAE,EAAE;AACrC,IAAA,IAAIC,KAAK,GAAGN,MAAM,CAACK,CAAC,CAAC;AACrB,IAAA,IAAIE,IAAI,GAAGJ,KAAK,CAACE,CAAC,CAAC;AAEnBT,IAAAA,MAAM,CAAC,CAAkBS,eAAAA,EAAAA,CAAC,CAAa,WAAA,CAAA,EAAEC,KAAK,CAAC;AAC/CV,IAAAA,MAAM,CAAC,CAAsBS,mBAAAA,EAAAA,CAAC,CAAa,WAAA,CAAA,EAAEE,IAAI,CAAC;IAElDD,KAAK,CAACE,KAAK,GAAGD,IAAI;AACpB;EAEA,MAAME,MAAM,CAACT,MAAM,CAAC,CAAC,CAAC,EAAEG,KAAK,CAAC,CAAC,CAAC,CAAC;;AAEjC;EACA,MAAM,IAAIO,OAAO,CAAEC,OAAO,IAAKC,qBAAqB,CAACD,OAAO,CAAC,CAAC;EAC9D,MAAME,OAAO,EAAE;AACjB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sources":["../../src/test-support/routing.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport Router from '@ember/routing/router';\n\nimport { properLinks } from '../proper-links.ts';\n\nimport type Owner from '@ember/owner';\nimport type { DSLCallback } from '@ember/routing/lib/dsl';\nimport type RouterService from '@ember/routing/router-service';\n\n/**\n * Allows setting up routes in tests without the need to scaffold routes in the actual app,\n * allowing for iterating on many different routing scenario / configurations rapidly.\n *\n * Example:\n * ```js\n * import { setupRouting } from 'ember-primitives/test-support';\n *\n * ...\n *\n * test('my test', async function (assert) {\n * setupRouting(this.owner, function () {\n * this.route('foo');\n * this.route('bar', function () {\n * this.route('a');\n * this.route('b');\n * })\n * });\n *\n * await visit('/bar/b');\n * });\n * ```\n *\n */\nexport function setupRouting(owner: Owner, map: DSLCallback, options?: { rootURL: string }) {\n if (options?.rootURL) {\n assert('rootURL must begin with a forward slash (\"/\")', options?.rootURL?.startsWith('/'));\n }\n\n @properLinks\n class TestRouter extends Router {\n rootURL = options?.rootURL ?? '/';\n }\n\n TestRouter.map(map);\n\n owner.register('router:main', TestRouter);\n\n // eslint-disable-next-line ember/no-private-routing-service\n let iKnowWhatIMDoing = owner.lookup('router:main');\n\n // We need a public testing API for this sort of stuff\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (iKnowWhatIMDoing as any).setupRouter();\n}\n\nexport function getRouter(owner: Owner) {\n return owner.lookup('service:router') as RouterService;\n}\n"],"names":["setupRouting","owner","map","options","rootURL","assert","startsWith","TestRouter","c","Router","properLinks","register","iKnowWhatIMDoing","lookup","setupRouter","getRouter"],"mappings":";;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAACC,KAAY,EAAEC,GAAgB,EAAEC,OAA6B,EAAE;EAC1F,IAAIA,OAAO,EAAEC,OAAO,EAAE;IACpBC,MAAM,CAAC,+CAA+C,EAAEF,OAAO,EAAEC,OAAO,EAAEE,UAAU,CAAC,GAAG,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"routing.js","sources":["../../src/test-support/routing.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport Router from '@ember/routing/router';\n\nimport { properLinks } from '../proper-links.ts';\n\nimport type Owner from '@ember/owner';\nimport type { DSLCallback } from '@ember/routing/lib/dsl';\nimport type RouterService from '@ember/routing/router-service';\n\n/**\n * Allows setting up routes in tests without the need to scaffold routes in the actual app,\n * allowing for iterating on many different routing scenario / configurations rapidly.\n *\n * Example:\n * ```js\n * import { setupRouting } from 'ember-primitives/test-support';\n *\n * ...\n *\n * test('my test', async function (assert) {\n * setupRouting(this.owner, function () {\n * this.route('foo');\n * this.route('bar', function () {\n * this.route('a');\n * this.route('b');\n * })\n * });\n *\n * await visit('/bar/b');\n * });\n * ```\n *\n */\nexport function setupRouting(owner: Owner, map: DSLCallback, options?: { rootURL: string }) {\n if (options?.rootURL) {\n assert('rootURL must begin with a forward slash (\"/\")', options?.rootURL?.startsWith('/'));\n }\n\n @properLinks\n class TestRouter extends Router {\n rootURL = options?.rootURL ?? '/';\n }\n\n TestRouter.map(map);\n\n owner.register('router:main', TestRouter);\n\n // eslint-disable-next-line ember/no-private-routing-service\n let iKnowWhatIMDoing = owner.lookup('router:main');\n\n // We need a public testing API for this sort of stuff\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (iKnowWhatIMDoing as any).setupRouter();\n}\n\nexport function getRouter(owner: Owner) {\n return owner.lookup('service:router') as RouterService;\n}\n"],"names":["setupRouting","owner","map","options","rootURL","assert","startsWith","TestRouter","c","Router","properLinks","register","iKnowWhatIMDoing","lookup","setupRouter","getRouter"],"mappings":";;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAACC,KAAY,EAAEC,GAAgB,EAAEC,OAA6B,EAAE;EAC1F,IAAIA,OAAO,EAAEC,OAAO,EAAE;IACpBC,MAAM,CAAC,+CAA+C,EAAEF,OAAO,EAAEC,OAAO,EAAEE,UAAU,CAAC,GAAG,CAAC,CAAC;AAC5F;AAAC,EAAA,MAGKC,UAAU,GAAAC,CAAA,OAAVD,UAAU,SAASE,MAAM,CAAC;AAC9BL,IAAAA,OAAO,GAAGD,OAAO,EAAEC,OAAO,IAAI,GAAG;AACnC,GAAC,GAHAM,WAAW,CAAA,CAAA;AAKZH,EAAAA,UAAU,CAACL,GAAG,CAACA,GAAG,CAAC;AAEnBD,EAAAA,KAAK,CAACU,QAAQ,CAAC,aAAa,EAAEJ,UAAU,CAAC;;AAEzC;AACA,EAAA,IAAIK,gBAAgB,GAAGX,KAAK,CAACY,MAAM,CAAC,aAAa,CAAC;;AAElD;AACA;EACCD,gBAAgB,CAASE,WAAW,EAAE;AACzC;AAEO,SAASC,SAASA,CAACd,KAAY,EAAE;AACtC,EAAA,OAAOA,KAAK,CAACY,MAAM,CAAC,gBAAgB,CAAC;AACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoetrope.js","sources":["../../src/test-support/zoetrope.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { click } from '@ember/test-helpers';\n\nexport class ZoetropeHelper {\n parentSelector = '.ember-primitives__zoetrope';\n\n constructor(parentSelector?: string) {\n if (parentSelector) {\n this.parentSelector = parentSelector;\n }\n }\n\n async scrollLeft() {\n await click(`${this.parentSelector} .ember-primitives__zoetrope__controls button:first-child`);\n }\n\n async scrollRight() {\n await click(`${this.parentSelector} .ember-primitives__zoetrope__controls button:last-child`);\n }\n\n visibleItems() {\n const zoetropeContent = document.querySelectorAll(\n `${this.parentSelector} .ember-primitives__zoetrope__scroller > *`\n );\n\n let firstVisibleItemIndex = -1;\n let lastVisibleItemIndex = -1;\n\n for (let i = 0; i < zoetropeContent.length; i++) {\n const item = zoetropeContent[i]!;\n const rect = item.getBoundingClientRect();\n const parentRect = item.parentElement!.getBoundingClientRect();\n\n if (rect.right >= parentRect?.left && rect.left <= parentRect?.right) {\n if (firstVisibleItemIndex === -1) {\n firstVisibleItemIndex = i;\n }\n\n lastVisibleItemIndex = i;\n } else if (firstVisibleItemIndex !== -1) {\n break;\n }\n }\n\n return Array.from(zoetropeContent).slice(firstVisibleItemIndex, lastVisibleItemIndex + 1);\n }\n\n visibleItemCount() {\n return this.visibleItems().length;\n }\n}\n"],"names":["ZoetropeHelper","parentSelector","constructor","scrollLeft","click","scrollRight","visibleItems","zoetropeContent","document","querySelectorAll","firstVisibleItemIndex","lastVisibleItemIndex","i","length","item","rect","getBoundingClientRect","parentRect","parentElement","right","left","Array","from","slice","visibleItemCount"],"mappings":";;AAAA;AAGO,MAAMA,cAAc,CAAC;AAC1BC,EAAAA,cAAc,GAAG,6BAA6B
|
|
1
|
+
{"version":3,"file":"zoetrope.js","sources":["../../src/test-support/zoetrope.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { click } from '@ember/test-helpers';\n\nexport class ZoetropeHelper {\n parentSelector = '.ember-primitives__zoetrope';\n\n constructor(parentSelector?: string) {\n if (parentSelector) {\n this.parentSelector = parentSelector;\n }\n }\n\n async scrollLeft() {\n await click(`${this.parentSelector} .ember-primitives__zoetrope__controls button:first-child`);\n }\n\n async scrollRight() {\n await click(`${this.parentSelector} .ember-primitives__zoetrope__controls button:last-child`);\n }\n\n visibleItems() {\n const zoetropeContent = document.querySelectorAll(\n `${this.parentSelector} .ember-primitives__zoetrope__scroller > *`\n );\n\n let firstVisibleItemIndex = -1;\n let lastVisibleItemIndex = -1;\n\n for (let i = 0; i < zoetropeContent.length; i++) {\n const item = zoetropeContent[i]!;\n const rect = item.getBoundingClientRect();\n const parentRect = item.parentElement!.getBoundingClientRect();\n\n if (rect.right >= parentRect?.left && rect.left <= parentRect?.right) {\n if (firstVisibleItemIndex === -1) {\n firstVisibleItemIndex = i;\n }\n\n lastVisibleItemIndex = i;\n } else if (firstVisibleItemIndex !== -1) {\n break;\n }\n }\n\n return Array.from(zoetropeContent).slice(firstVisibleItemIndex, lastVisibleItemIndex + 1);\n }\n\n visibleItemCount() {\n return this.visibleItems().length;\n }\n}\n"],"names":["ZoetropeHelper","parentSelector","constructor","scrollLeft","click","scrollRight","visibleItems","zoetropeContent","document","querySelectorAll","firstVisibleItemIndex","lastVisibleItemIndex","i","length","item","rect","getBoundingClientRect","parentRect","parentElement","right","left","Array","from","slice","visibleItemCount"],"mappings":";;AAAA;AAGO,MAAMA,cAAc,CAAC;AAC1BC,EAAAA,cAAc,GAAG,6BAA6B;EAE9CC,WAAWA,CAACD,cAAuB,EAAE;AACnC,IAAA,IAAIA,cAAc,EAAE;MAClB,IAAI,CAACA,cAAc,GAAGA,cAAc;AACtC;AACF;EAEA,MAAME,UAAUA,GAAG;AACjB,IAAA,MAAMC,KAAK,CAAC,CAAA,EAAG,IAAI,CAACH,cAAc,2DAA2D,CAAC;AAChG;EAEA,MAAMI,WAAWA,GAAG;AAClB,IAAA,MAAMD,KAAK,CAAC,CAAA,EAAG,IAAI,CAACH,cAAc,0DAA0D,CAAC;AAC/F;AAEAK,EAAAA,YAAYA,GAAG;IACb,MAAMC,eAAe,GAAGC,QAAQ,CAACC,gBAAgB,CAC/C,CAAA,EAAG,IAAI,CAACR,cAAc,CAAA,0CAAA,CACxB,CAAC;IAED,IAAIS,qBAAqB,GAAG,CAAC,CAAC;IAC9B,IAAIC,oBAAoB,GAAG,CAAC,CAAC;AAE7B,IAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,eAAe,CAACM,MAAM,EAAED,CAAC,EAAE,EAAE;AAC/C,MAAA,MAAME,IAAI,GAAGP,eAAe,CAACK,CAAC,CAAE;AAChC,MAAA,MAAMG,IAAI,GAAGD,IAAI,CAACE,qBAAqB,EAAE;MACzC,MAAMC,UAAU,GAAGH,IAAI,CAACI,aAAa,CAAEF,qBAAqB,EAAE;AAE9D,MAAA,IAAID,IAAI,CAACI,KAAK,IAAIF,UAAU,EAAEG,IAAI,IAAIL,IAAI,CAACK,IAAI,IAAIH,UAAU,EAAEE,KAAK,EAAE;AACpE,QAAA,IAAIT,qBAAqB,KAAK,CAAC,CAAC,EAAE;AAChCA,UAAAA,qBAAqB,GAAGE,CAAC;AAC3B;AAEAD,QAAAA,oBAAoB,GAAGC,CAAC;AAC1B,OAAC,MAAM,IAAIF,qBAAqB,KAAK,CAAC,CAAC,EAAE;AACvC,QAAA;AACF;AACF;AAEA,IAAA,OAAOW,KAAK,CAACC,IAAI,CAACf,eAAe,CAAC,CAACgB,KAAK,CAACb,qBAAqB,EAAEC,oBAAoB,GAAG,CAAC,CAAC;AAC3F;AAEAa,EAAAA,gBAAgBA,GAAG;AACjB,IAAA,OAAO,IAAI,CAAClB,YAAY,EAAE,CAACO,MAAM;AACnC;AACF;;;;"}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["// this is copy pasted from https://github.com/emberjs/ember.js/blob/60d2e0cddb353aea0d6e36a72fda971010d92355/packages/%40ember/-internals/glimmer/lib/helpers/unique-id.ts\n// Unfortunately due to https://github.com/emberjs/ember.js/issues/20165 we cannot use the built-in version in template tags\nexport function uniqueId() {\n // @ts-expect-error this one-liner abuses weird JavaScript semantics that\n // TypeScript (legitimately) doesn't like, but they're nonetheless valid and\n // specced.\n return ([3e7] + -1e3 + -4e3 + -2e3 + -1e11).replace(/[0-3]/g, (a) =>\n ((a * 4) ^ ((Math.random() * 16) >> (a & 2))).toString(16)\n );\n}\n"],"names":["uniqueId","replace","a","Math","random","toString"],"mappings":"AAAA;AACA;AACO,SAASA,QAAQA,GAAG;AACzB;AACA;AACA;EACA,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,EAAEC,OAAO,CAAC,QAAQ,EAAGC,CAAC,IAC9D,CAAEA,CAAC,GAAG,CAAC,GAAMC,IAAI,CAACC,MAAM,EAAE,GAAG,EAAE,KAAMF,CAAC,GAAG,CAAC,CAAE,EAAEG,QAAQ,CAAC,EAAE,CAC3D,CAAC
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["// this is copy pasted from https://github.com/emberjs/ember.js/blob/60d2e0cddb353aea0d6e36a72fda971010d92355/packages/%40ember/-internals/glimmer/lib/helpers/unique-id.ts\n// Unfortunately due to https://github.com/emberjs/ember.js/issues/20165 we cannot use the built-in version in template tags\nexport function uniqueId() {\n // @ts-expect-error this one-liner abuses weird JavaScript semantics that\n // TypeScript (legitimately) doesn't like, but they're nonetheless valid and\n // specced.\n return ([3e7] + -1e3 + -4e3 + -2e3 + -1e11).replace(/[0-3]/g, (a) =>\n ((a * 4) ^ ((Math.random() * 16) >> (a & 2))).toString(16)\n );\n}\n"],"names":["uniqueId","replace","a","Math","random","toString"],"mappings":"AAAA;AACA;AACO,SAASA,QAAQA,GAAG;AACzB;AACA;AACA;EACA,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,EAAEC,OAAO,CAAC,QAAQ,EAAGC,CAAC,IAC9D,CAAEA,CAAC,GAAG,CAAC,GAAMC,IAAI,CAACC,MAAM,EAAE,GAAG,EAAE,KAAMF,CAAC,GAAG,CAAC,CAAE,EAAEG,QAAQ,CAAC,EAAE,CAC3D,CAAC;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "Making apps easier to build",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css"
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.24.1",
|
|
21
|
-
"@embroider/addon-shim": "^1.
|
|
21
|
+
"@embroider/addon-shim": "^1.9.0",
|
|
22
22
|
"@embroider/macros": "1.16.9",
|
|
23
23
|
"@floating-ui/dom": "^1.5.3",
|
|
24
|
-
"decorator-transforms": "^2.
|
|
24
|
+
"decorator-transforms": "^2.3.0",
|
|
25
25
|
"ember-element-helper": ">= 0.8.6",
|
|
26
26
|
"form-data-utils": "^0.6.0",
|
|
27
27
|
"reactiveweb": "^1.2.2",
|
|
@@ -31,32 +31,32 @@
|
|
|
31
31
|
"tracked-toolbox": "^2.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@arethetypeswrong/cli": "^0.
|
|
34
|
+
"@arethetypeswrong/cli": "^0.17.0",
|
|
35
35
|
"@babel/core": "^7.25.8",
|
|
36
36
|
"@babel/eslint-parser": "^7.25.8",
|
|
37
37
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
38
38
|
"@babel/plugin-proposal-decorators": "^7.25.7",
|
|
39
39
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
40
|
-
"@babel/plugin-syntax-decorators": "^7.25.
|
|
41
|
-
"@babel/plugin-transform-class-static-block": "^7.
|
|
42
|
-
"@babel/plugin-transform-private-methods": "^7.25.
|
|
43
|
-
"@babel/preset-typescript": "^7.
|
|
40
|
+
"@babel/plugin-syntax-decorators": "^7.25.9",
|
|
41
|
+
"@babel/plugin-transform-class-static-block": "^7.26.0",
|
|
42
|
+
"@babel/plugin-transform-private-methods": "^7.25.9",
|
|
43
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
44
44
|
"@ember/test-helpers": "^4.0.4",
|
|
45
45
|
"@ember/test-waiters": "^3.1.0",
|
|
46
46
|
"@embroider/addon-dev": "6.0.1",
|
|
47
|
-
"@glimmer/component": "^
|
|
47
|
+
"@glimmer/component": "^2.0.0",
|
|
48
48
|
"@glimmer/tracking": "^1.1.2",
|
|
49
49
|
"@glint/core": "^1.5.0",
|
|
50
50
|
"@glint/environment-ember-loose": "^1.5.0",
|
|
51
51
|
"@glint/environment-ember-template-imports": "^1.5.0",
|
|
52
52
|
"@glint/template": "^1.5.0",
|
|
53
|
-
"@nullvoxpopuli/eslint-configs": "^4.
|
|
53
|
+
"@nullvoxpopuli/eslint-configs": "^4.3.0",
|
|
54
54
|
"@rollup/plugin-babel": "^6.0.4",
|
|
55
55
|
"@tsconfig/ember": "^3.0.5",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
57
|
-
"@typescript-eslint/parser": "^8.
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
57
|
+
"@typescript-eslint/parser": "^8.13.0",
|
|
58
58
|
"babel-plugin-ember-template-compilation": "^2.2.2",
|
|
59
|
-
"concurrently": "^9.0
|
|
59
|
+
"concurrently": "^9.1.0",
|
|
60
60
|
"ember-modifier": "^4.1.0",
|
|
61
61
|
"ember-resources": "^7.0.0",
|
|
62
62
|
"ember-source": "^5.12.0",
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"ember-template-lint": "^6.0.0",
|
|
65
65
|
"eslint": "^8.56.0",
|
|
66
66
|
"eslint-config-prettier": "^9.1.0",
|
|
67
|
-
"eslint-plugin-ember": "^12.
|
|
67
|
+
"eslint-plugin-ember": "^12.3.1",
|
|
68
68
|
"eslint-plugin-node": "^11.1.0",
|
|
69
69
|
"eslint-plugin-prettier": "^5.1.3",
|
|
70
|
-
"execa": "^9.
|
|
70
|
+
"execa": "^9.5.1",
|
|
71
71
|
"fix-bad-declaration-output": "^1.1.4",
|
|
72
72
|
"prettier": "^3.2.5",
|
|
73
|
-
"prettier-plugin-ember-template-tag": "^2.0.
|
|
74
|
-
"publint": "^0.2.
|
|
75
|
-
"rollup": "~4.
|
|
73
|
+
"prettier-plugin-ember-template-tag": "^2.0.4",
|
|
74
|
+
"publint": "^0.2.12",
|
|
75
|
+
"rollup": "~4.25.0",
|
|
76
76
|
"rollup-plugin-copy": "^3.5.0",
|
|
77
77
|
"typescript": "^5.3.3"
|
|
78
78
|
},
|
|
@@ -86,9 +86,7 @@
|
|
|
86
86
|
"version": 2,
|
|
87
87
|
"type": "addon",
|
|
88
88
|
"main": "addon-main.cjs",
|
|
89
|
-
"app-js": {
|
|
90
|
-
"./services/ember-primitives/setup.js": "./dist/_app_/services/ember-primitives/setup.js"
|
|
91
|
-
}
|
|
89
|
+
"app-js": {}
|
|
92
90
|
},
|
|
93
91
|
"exports": {
|
|
94
92
|
".": {
|
|
@@ -131,7 +129,7 @@
|
|
|
131
129
|
"@ember/test-waiters": ">= 3.0.2",
|
|
132
130
|
"@glimmer/component": ">= 1.1.2",
|
|
133
131
|
"@glimmer/tracking": ">= 1.1.2",
|
|
134
|
-
"@glint/template": "
|
|
132
|
+
"@glint/template": "^1.5.0",
|
|
135
133
|
"ember-modifier": ">= 4.1.0",
|
|
136
134
|
"ember-resources": ">= 6.1.0",
|
|
137
135
|
"ember-source": ">= 4.12.0"
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Service from '@ember/service';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare const PRIMITIVES: unique symbol;
|
|
6
|
-
export default class EmberPrimitivesSetup extends Service {
|
|
7
|
-
#private;
|
|
8
|
-
/**
|
|
9
|
-
* Sets up required features for accessibility.
|
|
10
|
-
*/
|
|
11
|
-
setup: ({ tabster, setTabsterRoot, }?: {
|
|
12
|
-
/**
|
|
13
|
-
* Let this setup function initalize tabster.
|
|
14
|
-
* https://tabster.io/docs/core
|
|
15
|
-
*
|
|
16
|
-
* This should be done only once per application as we don't want
|
|
17
|
-
* focus managers fighting with each other.
|
|
18
|
-
*
|
|
19
|
-
* Defaults to `true`,
|
|
20
|
-
*
|
|
21
|
-
* Will fallback to an existing tabster instance automatically if `getTabster` returns a value.
|
|
22
|
-
*/
|
|
23
|
-
tabster?: boolean;
|
|
24
|
-
setTabsterRoot?: boolean;
|
|
25
|
-
}) => void;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/services/ember-primitives/setup.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAIrC;;GAEG;AACH,eAAO,MAAM,UAAU,eAAyC,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,OAAO;;IACvD;;OAEG;IACH,KAAK,kCAGF;QACD;;;;;;;;;;WAUG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,UAeC;CAMH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "ember-primitives/services/ember-primitives/setup";
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Service from '@ember/service';
|
|
2
|
-
import { getTabster, createTabster, getMover, getDeloser } from 'tabster';
|
|
3
|
-
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
const PRIMITIVES = Symbol.for('ember-primitives-globals');
|
|
10
|
-
class EmberPrimitivesSetup extends Service {
|
|
11
|
-
/**
|
|
12
|
-
* Sets up required features for accessibility.
|
|
13
|
-
*/
|
|
14
|
-
setup = ({
|
|
15
|
-
tabster,
|
|
16
|
-
setTabsterRoot
|
|
17
|
-
} = {}) => {
|
|
18
|
-
tabster ??= true;
|
|
19
|
-
setTabsterRoot ??= true;
|
|
20
|
-
if (!tabster) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
let existing = getTabster(window);
|
|
24
|
-
this.#setupTabster(existing ?? createTabster(window));
|
|
25
|
-
if (setTabsterRoot) {
|
|
26
|
-
document.body.setAttribute('data-tabster', '{ "root": {} }');
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
#setupTabster = tabster => {
|
|
30
|
-
getMover(tabster);
|
|
31
|
-
getDeloser(tabster);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { PRIMITIVES, EmberPrimitivesSetup as default };
|
|
36
|
-
//# sourceMappingURL=setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sources":["../../../src/services/ember-primitives/setup.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport Service from '@ember/service';\n\nimport { createTabster, getDeloser, getMover, getTabster } from 'tabster';\n\n/**\n * @internal\n */\nexport const PRIMITIVES = Symbol.for('ember-primitives-globals');\n\nexport default class EmberPrimitivesSetup extends Service {\n /**\n * Sets up required features for accessibility.\n */\n setup = ({\n tabster,\n setTabsterRoot,\n }: {\n /**\n * Let this setup function initalize tabster.\n * https://tabster.io/docs/core\n *\n * This should be done only once per application as we don't want\n * focus managers fighting with each other.\n *\n * Defaults to `true`,\n *\n * Will fallback to an existing tabster instance automatically if `getTabster` returns a value.\n */\n tabster?: boolean;\n setTabsterRoot?: boolean;\n } = {}) => {\n tabster ??= true;\n setTabsterRoot ??= true;\n\n if (!tabster) {\n return;\n }\n\n let existing = getTabster(window);\n\n this.#setupTabster(existing ?? createTabster(window));\n\n if (setTabsterRoot) {\n document.body.setAttribute('data-tabster', '{ \"root\": {} }');\n }\n };\n\n #setupTabster = (tabster: ReturnType<typeof createTabster>) => {\n getMover(tabster);\n getDeloser(tabster);\n };\n}\n"],"names":["PRIMITIVES","Symbol","for","EmberPrimitivesSetup","Service","setup","tabster","setTabsterRoot","existing","getTabster","window","createTabster","document","body","setAttribute","getMover","getDeloser"],"mappings":";;;AAAA;;AAKA;AACA;AACA;AACO,MAAMA,UAAU,GAAGC,MAAM,CAACC,GAAG,CAAC,0BAA0B,EAAC;AAEjD,MAAMC,oBAAoB,SAASC,OAAO,CAAC;AACxD;AACF;AACA;AACEC,EAAAA,KAAK,GAAGA,CAAC;IACPC,OAAO;AACPC,IAAAA,cAAAA;GAeD,GAAG,EAAE,KAAK;AACTD,IAAAA,OAAO,KAAK,IAAI,CAAA;AAChBC,IAAAA,cAAc,KAAK,IAAI,CAAA;IAEvB,IAAI,CAACD,OAAO,EAAE;AACZ,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,IAAIE,QAAQ,GAAGC,UAAU,CAACC,MAAM,CAAC,CAAA;IAEjC,IAAI,CAAC,aAAa,CAACF,QAAQ,IAAIG,aAAa,CAACD,MAAM,CAAC,CAAC,CAAA;AAErD,IAAA,IAAIH,cAAc,EAAE;MAClBK,QAAQ,CAACC,IAAI,CAACC,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAA;AAC9D,KAAA;GACD,CAAA;EAED,aAAa,GAAIR,OAAyC,IAAK;IAC7DS,QAAQ,CAACT,OAAO,CAAC,CAAA;IACjBU,UAAU,CAACV,OAAO,CAAC,CAAA;GACpB,CAAA;AACH;;;;"}
|