ember-primitives 0.27.2 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/color-scheme.d.ts.map +1 -1
- package/declarations/components/-private/typed-elements.d.ts +1 -1
- package/declarations/components/accordion/content.d.ts +2 -2
- package/declarations/components/accordion/header.d.ts +2 -2
- package/declarations/components/accordion/item.d.ts +3 -3
- package/declarations/components/accordion/public.d.ts +3 -3
- package/declarations/components/accordion/trigger.d.ts +2 -2
- package/declarations/components/accordion.d.ts +7 -7
- package/declarations/components/accordion.d.ts.map +1 -1
- package/declarations/components/avatar.d.ts +4 -4
- package/declarations/components/dialog.d.ts +4 -4
- package/declarations/components/dialog.d.ts.map +1 -1
- package/declarations/components/external-link.d.ts +1 -1
- package/declarations/components/form.d.ts +3 -3
- package/declarations/components/keys.d.ts +17 -0
- package/declarations/components/keys.d.ts.map +1 -0
- package/declarations/components/layout/hero.d.ts +2 -2
- package/declarations/components/layout/sticky-footer.d.ts +2 -2
- package/declarations/components/menu.d.ts +19 -19
- package/declarations/components/menu.d.ts.map +1 -1
- package/declarations/components/one-time-password/buttons.d.ts +1 -1
- package/declarations/components/one-time-password/index.d.ts +2 -2
- package/declarations/components/one-time-password/input.d.ts +5 -5
- package/declarations/components/one-time-password/input.d.ts.map +1 -1
- package/declarations/components/one-time-password/otp.d.ts +5 -5
- package/declarations/components/one-time-password/otp.d.ts.map +1 -1
- package/declarations/components/one-time-password/utils.d.ts.map +1 -1
- package/declarations/components/popover.d.ts +17 -26
- package/declarations/components/popover.d.ts.map +1 -1
- package/declarations/components/portal-targets.d.ts +1 -1
- package/declarations/components/portal.d.ts +4 -3
- package/declarations/components/portal.d.ts.map +1 -1
- package/declarations/components/progress.d.ts +4 -4
- package/declarations/components/scroller.d.ts +1 -1
- package/declarations/components/shadowed.d.ts +1 -1
- package/declarations/components/switch.d.ts +5 -5
- package/declarations/components/toggle-group.d.ts +4 -4
- package/declarations/components/toggle.d.ts +2 -2
- package/declarations/components/toggle.d.ts.map +1 -1
- package/declarations/components/zoetrope/index.d.ts +3 -3
- package/declarations/components/zoetrope.d.ts +2 -2
- package/declarations/floating-ui/component.d.ts +19 -16
- package/declarations/floating-ui/component.d.ts.map +1 -1
- package/declarations/floating-ui/modifier.d.ts.map +1 -1
- package/declarations/floating-ui.d.ts +1 -1
- package/declarations/helpers/link.d.ts.map +1 -1
- package/declarations/index.d.ts +20 -19
- package/declarations/index.d.ts.map +1 -1
- package/declarations/proper-links.d.ts.map +1 -1
- package/declarations/test-support/routing.d.ts.map +1 -1
- package/declarations/utils.d.ts.map +1 -1
- package/dist/color-scheme.js +5 -5
- package/dist/color-scheme.js.map +1 -1
- package/dist/components/-private/typed-elements.js.map +1 -1
- package/dist/components/-private/utils.js +1 -3
- package/dist/components/-private/utils.js.map +1 -1
- package/dist/components/accordion/content.js +1 -1
- package/dist/components/accordion/header.js +1 -1
- package/dist/components/accordion/item.js +1 -1
- package/dist/components/accordion/trigger.js +1 -1
- package/dist/components/accordion.js +26 -25
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/dialog.js +15 -14
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/external-link.js.map +1 -1
- package/dist/components/form.js +6 -6
- package/dist/components/form.js.map +1 -1
- package/dist/components/keys.js +33 -0
- package/dist/components/keys.js.map +1 -0
- package/dist/components/layout/hero.js.map +1 -1
- package/dist/components/layout/sticky-footer.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/menu.js +47 -46
- package/dist/components/menu.js.map +1 -1
- package/dist/components/one-time-password/buttons.js +5 -5
- package/dist/components/one-time-password/buttons.js.map +1 -1
- package/dist/components/one-time-password/input.js +14 -14
- package/dist/components/one-time-password/input.js.map +1 -1
- package/dist/components/one-time-password/otp.js +26 -25
- package/dist/components/one-time-password/otp.js.map +1 -1
- package/dist/components/one-time-password/utils.js +18 -18
- package/dist/components/one-time-password/utils.js.map +1 -1
- package/dist/components/popover.js +44 -44
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal-targets.js +16 -16
- package/dist/components/portal-targets.js.map +1 -1
- package/dist/components/portal.js +5 -3
- package/dist/components/portal.js.map +1 -1
- package/dist/components/progress.js +16 -16
- package/dist/components/progress.js.map +1 -1
- package/dist/components/scroller.js +6 -6
- package/dist/components/scroller.js.map +1 -1
- package/dist/components/shadowed.js +9 -9
- package/dist/components/shadowed.js.map +1 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/toggle-group.js +24 -24
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.js +4 -4
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/violations.css +8 -8
- package/dist/components/zoetrope/index.js +102 -102
- package/dist/components/zoetrope/index.js.map +1 -1
- package/dist/floating-ui/component.js +6 -6
- package/dist/floating-ui/component.js.map +1 -1
- package/dist/floating-ui/modifier.js +10 -6
- package/dist/floating-ui/modifier.js.map +1 -1
- package/dist/helpers/link.js +11 -7
- package/dist/helpers/link.js.map +1 -1
- package/dist/helpers/service.js +1 -1
- package/dist/helpers/service.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/{item-DmpElnSZ.js → item-D6pwWzMs.js} +3 -3
- package/dist/item-D6pwWzMs.js.map +1 -0
- package/dist/proper-links.js +10 -10
- package/dist/proper-links.js.map +1 -1
- package/dist/tabster.js +2 -2
- package/dist/tabster.js.map +1 -1
- package/dist/test-support/a11y.js +4 -4
- package/dist/test-support/a11y.js.map +1 -1
- package/dist/test-support/otp.js +6 -6
- package/dist/test-support/otp.js.map +1 -1
- package/dist/test-support/routing.js +3 -2
- package/dist/test-support/routing.js.map +1 -1
- package/dist/test-support/zoetrope.js.map +1 -1
- package/dist/utils.js +1 -0
- package/dist/utils.js.map +1 -1
- package/package.json +20 -30
- package/dist/item-DmpElnSZ.js.map +0 -1
|
@@ -36,8 +36,8 @@ const anchorTo = modifier((floatingElement, [_referenceElement], {
|
|
|
36
36
|
top: '0',
|
|
37
37
|
left: '0'
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const update = async () => {
|
|
40
|
+
const {
|
|
41
41
|
middlewareData,
|
|
42
42
|
x,
|
|
43
43
|
y
|
|
@@ -50,17 +50,21 @@ const anchorTo = modifier((floatingElement, [_referenceElement], {
|
|
|
50
50
|
placement,
|
|
51
51
|
strategy
|
|
52
52
|
});
|
|
53
|
-
|
|
53
|
+
const referenceHidden = middlewareData.hide?.referenceHidden;
|
|
54
54
|
Object.assign(floatingElement.style, {
|
|
55
55
|
top: `${y}px`,
|
|
56
56
|
left: `${x}px`,
|
|
57
57
|
margin: 0,
|
|
58
58
|
visibility: referenceHidden ? 'hidden' : 'visible'
|
|
59
59
|
});
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
62
|
+
void setData?.(middlewareData['metadata']);
|
|
61
63
|
};
|
|
62
|
-
update();
|
|
63
|
-
|
|
64
|
+
void update();
|
|
65
|
+
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
67
|
+
const cleanup = autoUpdate(referenceElement, floatingElement, update);
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* in the function-modifier manager, teardown of the previous modifier
|
|
@@ -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
|
|
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 const update = async () => {\n const { middlewareData, x, y } = await computePosition(referenceElement, floatingElement, {\n middleware: [\n offset(offsetOptions),\n flip(flipOptions),\n shift(shiftOptions),\n ...middleware,\n hide({ strategy: 'referenceHidden' }),\n hide({ strategy: 'escaped' }),\n exposeMetadata(),\n ],\n placement,\n strategy,\n });\n\n const referenceHidden = middlewareData.hide?.referenceHidden;\n\n Object.assign(floatingElement.style, {\n top: `${y}px`,\n left: `${x}px`,\n margin: 0,\n visibility: referenceHidden ? 'hidden' : 'visible',\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n void setData?.(middlewareData['metadata']);\n };\n\n void update();\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const cleanup = autoUpdate(referenceElement, floatingElement, update);\n\n /**\n * in the function-modifier manager, teardown of the previous modifier\n * occurs before setup of the next\n * https://github.com/ember-modifier/ember-modifier/blob/main/ember-modifier/src/-private/function-based/modifier-manager.ts#L58\n */\n return cleanup;\n }\n);\n"],"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,4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AM,EAAE;;AAEb;EACA,MAAMa,OAAO,GAAGC,UAAU,CAAC5B,gBAAgB,EAAET,eAAe,EAAEuB,MAAM,CAAC;;AAErE;AACJ;AACA;AACA;AACA;AACI,EAAA,OAAOa,OAAO;AAChB,CACF;;;;"}
|
package/dist/helpers/link.js
CHANGED
|
@@ -40,17 +40,19 @@ function isActive(router, href, includeQueryParams, activeOnSubPaths) {
|
|
|
40
40
|
/**
|
|
41
41
|
* is Active doesn't understand `href`, so we have to convert to RouteInfo-esque
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
const info = router.recognize(href);
|
|
44
44
|
if (info) {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const dynamicSegments = getParams(info);
|
|
46
|
+
const routeName = activeOnSubPaths ? info.name.replace(/\.index$/, '') : info.name;
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
47
49
|
return router.isActive(routeName, ...dynamicSegments);
|
|
48
50
|
}
|
|
49
51
|
return false;
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
const url = new URL(href, location.origin);
|
|
54
|
+
const hrefQueryParams = new URLSearchParams(url.searchParams);
|
|
55
|
+
const hrefPath = url.pathname;
|
|
54
56
|
const currentPath = router.currentURL?.split('?')[0];
|
|
55
57
|
if (!currentPath) return false;
|
|
56
58
|
if (activeOnSubPaths ? !currentPath.startsWith(hrefPath) : hrefPath !== currentPath) return false;
|
|
@@ -68,10 +70,12 @@ function isActive(router, href, includeQueryParams, activeOnSubPaths) {
|
|
|
68
70
|
function getParams(currentRouteInfo) {
|
|
69
71
|
let params = [];
|
|
70
72
|
while (currentRouteInfo?.parent) {
|
|
71
|
-
|
|
73
|
+
const currentParams = currentRouteInfo.params;
|
|
72
74
|
params = currentParams ? [currentParams, ...params] : params;
|
|
73
75
|
currentRouteInfo = currentRouteInfo.parent;
|
|
74
76
|
}
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
75
79
|
return params.map(Object.values).flat();
|
|
76
80
|
}
|
|
77
81
|
|
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
|
|
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 const info = router.recognize(href);\n\n if (info) {\n const dynamicSegments = getParams(info);\n const routeName = activeOnSubPaths ? info.name.replace(/\\.index$/, '') : info.name;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return router.isActive(routeName, ...dynamicSegments);\n }\n\n return false;\n }\n\n const url = new URL(href, location.origin);\n const hrefQueryParams = new URLSearchParams(url.searchParams);\n const hrefPath = url.pathname;\n\n const currentPath = router.currentURL?.split('?')[0];\n\n if (!currentPath) return false;\n\n if (activeOnSubPaths ? !currentPath.startsWith(hrefPath) : hrefPath !== currentPath) return false;\n\n const currentQueryParams = router.currentRoute?.queryParams;\n\n if (!currentQueryParams) return false;\n\n if (includeQueryParams === true) {\n return Object.entries(currentQueryParams).every(([key, value]) => {\n return hrefQueryParams.get(key) === value;\n });\n }\n\n return includeQueryParams.every((key) => {\n return hrefQueryParams.get(key) === currentQueryParams[key];\n });\n}\n\ntype RouteInfo = ReturnType<RouterService['recognize']>;\n\nexport function getParams(currentRouteInfo: RouteInfo) {\n let params: Record<string, unknown>[] = [];\n\n while (currentRouteInfo?.parent) {\n const currentParams = currentRouteInfo.params;\n\n params = currentParams ? [currentParams, ...params] : params;\n currentRouteInfo = currentRouteInfo.parent;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return params.map(Object.values).flat();\n}\n"],"names":["Link","Helper","g","prototype","service","i","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,MAAA;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,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AAa,EAAE,GAAGF,MAAM,CAAC,GAAGA,MAAM;IAC5DD,gBAAgB,GAAGA,gBAAgB,CAACE,MAAM;AAC5C;;AAEA;EACA,OAAOD,MAAM,CAACG,GAAG,CAACV,MAAM,CAACW,MAAM,CAAC,CAACC,IAAI,EAAE;AACzC;;;;"}
|
package/dist/helpers/service.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sources":["../../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
|
|
1
|
+
{"version":3,"file":"service.js","sources":["../../src/helpers/service.ts"],"sourcesContent":["import Helper from '@ember/component/helper';\nimport { assert } from '@ember/debug';\nimport { getOwner } from '@ember/owner';\n\nimport type { Registry } from '@ember/service';\nimport type Service from '@ember/service';\n\nexport interface Signature<Key extends keyof Registry> {\n Args: {\n Positional: [Key];\n };\n Return: Registry[Key] & Service;\n}\n\nexport default class GetService<Key extends keyof Registry> extends Helper<Signature<Key>> {\n compute(positional: [Key]): Registry[Key] & Service {\n const owner = getOwner(this);\n\n assert(`Could not get owner.`, owner);\n\n return owner.lookup(`service:${positional[0]}`) as Registry[Key] & Service;\n }\n}\n\nexport const service = GetService;\n"],"names":["GetService","Helper","compute","positional","owner","getOwner","assert","lookup","service"],"mappings":";;;;AAce,MAAMA,UAAU,SAAqCC,MAAM,CAAiB;EACzFC,OAAOA,CAACC,UAAiB,EAA2B;AAClD,IAAA,MAAMC,KAAK,GAAGC,QAAQ,CAAC,IAAI,CAAC;AAE5BC,IAAAA,MAAM,CAAC,CAAA,oBAAA,CAAsB,EAAEF,KAAK,CAAC;IAErC,OAAOA,KAAK,CAACG,MAAM,CAAC,CAAA,QAAA,EAAWJ,UAAU,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AACjD;AACF;AAEO,MAAMK,OAAO,GAAGR;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { Avatar } from './components/avatar.js';
|
|
|
4
4
|
export { Dialog, Dialog as Modal } from './components/dialog.js';
|
|
5
5
|
export { ExternalLink } from './components/external-link.js';
|
|
6
6
|
export { Form } from './components/form.js';
|
|
7
|
+
export { Key, KeyCombo } from './components/keys.js';
|
|
7
8
|
export { StickyFooter } from './components/layout/sticky-footer.js';
|
|
8
9
|
export { Link } from './components/link.js';
|
|
9
10
|
export { Menu } from './components/menu.js';
|
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';\n"],"names":["macroCondition","isDevelopingApp","importSync"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * DANGER: this is a *barrel file*\n *\n * It forces the whole library to be loaded and all dependencies.\n *\n * If you have a small app, you probably don't want to import from here -- instead import from each sub-path.\n */\nimport { importSync, isDevelopingApp, macroCondition } from '@embroider/macros';\n\nif (macroCondition(isDevelopingApp())) {\n importSync('./components/violations.css');\n}\n\nexport { Accordion } from './components/accordion.gts';\nexport type {\n AccordionContentExternalSignature,\n AccordionHeaderExternalSignature,\n AccordionItemExternalSignature,\n AccordionTriggerExternalSignature,\n} from './components/accordion/public.ts';\nexport { Avatar } from './components/avatar.gts';\nexport { Dialog, Dialog as Modal } from './components/dialog.gts';\nexport { ExternalLink } from './components/external-link.gts';\nexport { Form } from './components/form.gts';\nexport { Key, KeyCombo } from './components/keys.gts';\nexport { StickyFooter } from './components/layout/sticky-footer.gts';\nexport { Link } from './components/link.gts';\nexport { Menu } from './components/menu.gts';\nexport { OTP, OTPInput } from './components/one-time-password/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"}
|
|
@@ -36,8 +36,8 @@ const AccordionHeader = setComponentTemplate(precompileTemplate("\n <div role=\
|
|
|
36
36
|
})
|
|
37
37
|
}), templateOnly());
|
|
38
38
|
|
|
39
|
-
function getDataState(
|
|
40
|
-
return
|
|
39
|
+
function getDataState(isExpanded) {
|
|
40
|
+
return isExpanded ? "open" : "closed";
|
|
41
41
|
}
|
|
42
42
|
class AccordionItem extends Component {
|
|
43
43
|
static {
|
|
@@ -64,4 +64,4 @@ class AccordionItem extends Component {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export { AccordionItem as A, AccordionContent as a, AccordionTrigger as b, AccordionHeader as c, getDataState as g };
|
|
67
|
-
//# sourceMappingURL=item-
|
|
67
|
+
//# sourceMappingURL=item-D6pwWzMs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-D6pwWzMs.js","sources":["../src/components/accordion/content.gts","../src/components/accordion/trigger.gts","../src/components/accordion/header.gts","../src/components/accordion/item.gts"],"sourcesContent":["import Component from \"@glimmer/component\";\n\nimport { getDataState } from \"./item.gts\";\n\nimport type { AccordionContentExternalSignature } from \"./public.ts\";\n\ninterface Signature extends AccordionContentExternalSignature {\n Args: {\n isExpanded: boolean;\n value: string;\n disabled?: boolean;\n };\n}\n\nexport class AccordionContent extends Component<Signature> {\n <template>\n <div\n role=\"region\"\n id={{@value}}\n data-state={{getDataState @isExpanded}}\n hidden={{this.isHidden}}\n data-disabled={{@disabled}}\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n\n get isHidden() {\n return !this.args.isExpanded;\n }\n}\n\nexport default AccordionContent;\n","import { on } from \"@ember/modifier\";\n\nimport { getDataState } from \"./item.gts\";\n\nimport type { AccordionTriggerExternalSignature } from \"./public.ts\";\nimport type { TOC } from \"@ember/component/template-only\";\n\ninterface Signature extends AccordionTriggerExternalSignature {\n Args: {\n isExpanded: boolean;\n value: string;\n disabled?: boolean;\n toggleItem: () => void;\n };\n}\n\nexport const AccordionTrigger: TOC<Signature> = <template>\n <button\n type=\"button\"\n aria-controls={{@value}}\n aria-expanded={{@isExpanded}}\n data-state={{getDataState @isExpanded}}\n data-disabled={{@disabled}}\n aria-disabled={{if @disabled \"true\" \"false\"}}\n {{on \"click\" @toggleItem}}\n ...attributes\n >\n {{yield}}\n </button>\n</template>;\n\nexport default AccordionTrigger;\n","import { hash } from \"@ember/helper\";\n\nimport { getDataState } from \"./item.gts\";\nimport Trigger from \"./trigger.gts\";\n\nimport type { AccordionHeaderExternalSignature } from \"./public.ts\";\nimport type { TOC } from \"@ember/component/template-only\";\n\ninterface Signature extends AccordionHeaderExternalSignature {\n Args: {\n value: string;\n isExpanded: boolean;\n disabled?: boolean;\n toggleItem: () => void;\n };\n}\n\nexport const AccordionHeader: TOC<Signature> = <template>\n <div\n role=\"heading\"\n aria-level=\"3\"\n data-state={{getDataState @isExpanded}}\n data-disabled={{@disabled}}\n ...attributes\n >\n {{yield\n (hash\n Trigger=(component\n Trigger value=@value isExpanded=@isExpanded disabled=@disabled toggleItem=@toggleItem\n )\n )\n }}\n </div>\n</template>;\n\nexport default AccordionHeader;\n","import Component from \"@glimmer/component\";\nimport { hash } from \"@ember/helper\";\n\nimport Content from \"./content.gts\";\nimport Header from \"./header.gts\";\n\nimport type { AccordionItemExternalSignature } from \"./public.ts\";\n\nexport function getDataState(isExpanded: boolean): string {\n return isExpanded ? \"open\" : \"closed\";\n}\n\ninterface Signature extends AccordionItemExternalSignature {\n Args: AccordionItemExternalSignature[\"Args\"] & {\n selectedValue?: string | string[];\n disabled?: boolean;\n toggleItem: (value: string) => void;\n };\n}\n\nexport class AccordionItem extends Component<Signature> {\n <template>\n <div data-state={{getDataState this.isExpanded}} data-disabled={{@disabled}} ...attributes>\n {{yield\n (hash\n isExpanded=this.isExpanded\n Header=(component\n Header\n value=@value\n isExpanded=this.isExpanded\n disabled=@disabled\n toggleItem=this.toggleItem\n )\n Content=(component Content value=@value isExpanded=this.isExpanded disabled=@disabled)\n )\n }}\n </div>\n </template>\n\n get isExpanded(): boolean {\n if (Array.isArray(this.args.selectedValue)) {\n return this.args.selectedValue.includes(this.args.value);\n }\n\n return this.args.selectedValue === this.args.value;\n }\n\n toggleItem = (): void => {\n if (this.args.disabled) return;\n\n this.args.toggleItem(this.args.value);\n };\n}\n\nexport default AccordionItem;\n"],"names":["AccordionContent","Component","setComponentTemplate","precompileTemplate","strictMode","scope","getDataState","isHidden","args","isExpanded","AccordionTrigger","on","templateOnly","AccordionHeader","hash","Trigger","AccordionItem","Header","Content","Array","isArray","selectedValue","includes","value","toggleItem","disabled"],"mappings":";;;;;;;AAcO,MAAMA,yBAAyBC,SAAU,CAAA;AAC9C,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAWA,uLAAA,EAAA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;EAEV,IAAIC,QAAWA,GAAA;AACb,IAAA,OAAO,CAAC,IAAI,CAACC,IAAI,CAACC,UAAU;AAC9B;AACF;;MCfaC,gBAAsB,GAAAR,oBAAA,CAAaC,kBAAA,CAahD,oRAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,YAAA;AAAAK,IAAAA;AAAA,GAAA;AAAU,CAAE,CAAA,EAAAC,YAAA,EAAA;;MCZCC,eAAqB,GAAAX,oBAAA,CAAaC,kBAAA,CAgB/C,2QAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,YAAA;IAAAQ,IAAA;AAAAC,aAAAA;AAAA,GAAA;AAAU,CAAE,CAAA,EAAAH,YAAA,EAAA;;ACzBL,SAASN,YAAAA,CAAaG,UAAmB,EAAS;AACvD,EAAA,OAAOA,aAAa,MAAS,GAAA,QAAA;AAC/B;AAUO,MAAMO,sBAAsBf,SAAU,CAAA;AAC3C,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAgBA,6WAAA,EAAA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAQ,IAAA;gBAAAG,eAAA;AAAAC,iBAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;EAEV,IAAIT,UAAAA,GAAsB;IACxB,IAAIU,KAAA,CAAMC,OAAO,CAAC,IAAI,CAACZ,IAAI,CAACa,aAAa,CAAG,EAAA;AAC1C,MAAA,OAAO,IAAI,CAACb,IAAI,CAACa,aAAa,CAACC,QAAQ,CAAC,IAAI,CAACd,IAAI,CAACe,KAAK,CAAA;AACzD;IAEA,OAAO,IAAI,CAACf,IAAI,CAACa,aAAa,KAAK,IAAI,CAACb,IAAI,CAACe,KAAK;AACpD;EAEAC,UAAA,GAAaA,MAAQ;AACnB,IAAA,IAAI,IAAI,CAAChB,IAAI,CAACiB,QAAQ,EAAE;IAExB,IAAI,CAACjB,IAAI,CAACgB,UAAU,CAAC,IAAI,CAAChB,IAAI,CAACe,KAAK,CAAA;GACpC;AACJ;;;;"}
|
package/dist/proper-links.js
CHANGED
|
@@ -4,8 +4,6 @@ import { getOwner } from '@ember/owner';
|
|
|
4
4
|
import { shouldHandle, getAnchor } from 'should-handle-link';
|
|
5
5
|
export { shouldHandle } from 'should-handle-link';
|
|
6
6
|
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* @internal
|
|
11
9
|
*/
|
|
@@ -19,17 +17,19 @@ function properLinks(...args) {
|
|
|
19
17
|
} else if (args.length === 1) {
|
|
20
18
|
if (typeof args[0] === 'object') {
|
|
21
19
|
// TODO: how to get first arg type correct?
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
22
21
|
return klass => properLinks(args[0], klass);
|
|
23
22
|
} else {
|
|
24
23
|
klass = args[0];
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
const ignore = options.ignore || [];
|
|
28
27
|
assert(`klass was not defined. possibile incorrect arity given to properLinks`, klass);
|
|
29
28
|
return class RouterWithProperLinks extends klass {
|
|
30
29
|
// SAFETY: we literally do not care about the args' type here,
|
|
31
30
|
// because we just call super
|
|
32
31
|
constructor(...args) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
33
33
|
super(...args);
|
|
34
34
|
setup(this, ignore);
|
|
35
35
|
}
|
|
@@ -46,11 +46,11 @@ function setup(parent, ignore) {
|
|
|
46
46
|
* event.target may not be an anchor,
|
|
47
47
|
* it may be a span, svg, img, or any number of elements nested in <a>...</a>
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
const interactive = getAnchor(event);
|
|
50
50
|
if (!interactive) return;
|
|
51
|
-
|
|
51
|
+
const owner = getOwner(parent);
|
|
52
52
|
assert('owner is not present', owner);
|
|
53
|
-
|
|
53
|
+
const routerService = owner.lookup('service:router');
|
|
54
54
|
handle(routerService, interactive, ignore ?? [], event);
|
|
55
55
|
};
|
|
56
56
|
document.body.addEventListener('click', handler, false);
|
|
@@ -60,9 +60,9 @@ function handle(router, element, ignore, event) {
|
|
|
60
60
|
if (!shouldHandle(location.href, element, event, ignore)) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const url = new URL(element.href);
|
|
64
|
+
const fullHref = `${url.pathname}${url.search}${url.hash}`;
|
|
65
|
+
const rootURL = router.rootURL;
|
|
66
66
|
let withoutRootURL = fullHref.slice(rootURL.length);
|
|
67
67
|
|
|
68
68
|
// re-add the "root" sigil
|
|
@@ -72,7 +72,7 @@ function handle(router, element, ignore, event) {
|
|
|
72
72
|
withoutRootURL = `/${withoutRootURL}`;
|
|
73
73
|
}
|
|
74
74
|
try {
|
|
75
|
-
|
|
75
|
+
const routeInfo = router.recognize(fullHref);
|
|
76
76
|
if (routeInfo) {
|
|
77
77
|
event.preventDefault();
|
|
78
78
|
event.stopImmediatePropagation();
|
package/dist/proper-links.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-links.js","sources":["../src/proper-links.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"proper-links.js","sources":["../src/proper-links.ts"],"sourcesContent":["import { 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];\n klass = args[1];\n } else if (args.length === 1) {\n if (typeof args[0] === 'object') {\n // TODO: how to get first arg type correct?\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return (klass: Klass) => properLinks(args[0] as any, klass);\n } else {\n klass = args[0];\n }\n }\n\n const 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 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\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 const interactive = getAnchor(event);\n\n if (!interactive) return;\n\n const owner = getOwner(parent);\n\n assert('owner is not present', owner);\n\n const 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 const url = new URL(element.href);\n\n const fullHref = `${url.pathname}${url.search}${url.hash}`;\n\n const 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 const 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":";;;;;;AAwBA;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,CAAC;AACjBE,IAAAA,KAAK,GAAGF,IAAI,CAAC,CAAC,CAAC;AACjB,GAAC,MAAM,IAAIA,IAAI,CAACI,MAAM,KAAK,CAAC,EAAE;AAC5B,IAAA,IAAI,OAAOJ,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;AAC/B;AACA;MACA,OAAQE,KAAY,IAAKH,WAAW,CAACC,IAAI,CAAC,CAAC,CAAC,EAASE,KAAK,CAAC;AAC7D,KAAC,MAAM;AACLA,MAAAA,KAAK,GAAGF,IAAI,CAAC,CAAC,CAAC;AACjB;AACF;AAEA,EAAA,MAAMK,MAAM,GAAGJ,OAAO,CAACI,MAAM,IAAI,EAAE;AAEnCC,EAAAA,MAAM,CAAC,CAAA,qEAAA,CAAuE,EAAEJ,KAAK,CAAC;AAEtF,EAAA,OAAO,MAAMK,qBAAqB,SAAUL,KAAK,CAAyC;AACxF;AACA;IACAM,WAAWA,CAAC,GAAGR,IAAW,EAAE;AAC1B;MACA,KAAK,CAAC,GAAGA,IAAI,CAAC;AAEdS,MAAAA,KAAK,CAAC,IAAI,EAAEJ,MAAM,CAAC;AACrB;GACD;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASI,KAAKA,CAACC,MAAc,EAAEL,MAAiB,EAAE;EACvD,MAAMM,OAAO,GAAIC,KAAiB,IAAK;AACrC;AACJ;AACA;AACA;AACI,IAA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EAAAA,cAAc,CAAE,CAAA;AACvC;EAEA,IAAI;AACF,IAAA,MAAMG,SAAS,GAAGf,MAAM,CAACgB,SAAS,CAACT,QAAQ,CAAC;AAE5C,IAAA,IAAIQ,SAAS,EAAE;MACb5B,KAAK,CAAC8B,cAAc,EAAE;MACtB9B,KAAK,CAAC+B,wBAAwB,EAAE;MAChC/B,KAAK,CAACgC,eAAe,EAAE;AAEvBnB,MAAAA,MAAM,CAACoB,YAAY,CAACR,cAAc,CAAC;AAEnC,MAAA,OAAO,KAAK;AACd;GACD,CAAC,OAAOS,CAAC,EAAE;IACV,IAAIA,CAAC,YAAYC,KAAK,IAAID,CAAC,CAACE,IAAI,KAAK,sBAAsB,EAAE;AAC3D,MAAA;AACF;AAEA,IAAA,MAAMF,CAAC;AACT;AACF;;;;"}
|
package/dist/tabster.js
CHANGED
|
@@ -22,8 +22,8 @@ context, {
|
|
|
22
22
|
if (!tabster) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const existing = getTabster(window);
|
|
26
|
+
const primitivesTabster = existing ?? createTabster(window);
|
|
27
27
|
getMover(primitivesTabster);
|
|
28
28
|
getDeloser(primitivesTabster);
|
|
29
29
|
if (setTabsterRoot) {
|
package/dist/tabster.js.map
CHANGED
|
@@ -1 +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
|
|
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 const existing = getTabster(window);\n const 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,MAAMO,QAAQ,GAAGF,UAAU,CAACG,MAAM,CAAC;AACnC,EAAA,MAAMC,iBAAiB,GAAGF,QAAQ,IAAIL,aAAa,CAACM,MAAM,CAAC;EAE3DJ,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;;;;"}
|
|
@@ -6,16 +6,16 @@ import { setupTabster as setupTabster$1 } from '../tabster.js';
|
|
|
6
6
|
* Including the tabster root.
|
|
7
7
|
*/
|
|
8
8
|
async function setup(owner) {
|
|
9
|
-
setupTabster$1(owner, {
|
|
9
|
+
await setupTabster$1(owner, {
|
|
10
10
|
setTabsterRoot: false
|
|
11
11
|
});
|
|
12
12
|
document.querySelector('#ember-testing')?.setAttribute('data-tabster', '{ "root": {} }');
|
|
13
13
|
}
|
|
14
14
|
function setupTabster(hooks) {
|
|
15
|
-
hooks.beforeEach(function () {
|
|
16
|
-
|
|
15
|
+
hooks.beforeEach(async function () {
|
|
16
|
+
const owner = this.owner;
|
|
17
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);
|
|
18
|
+
await setup(this.owner);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 await _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(async function (this: { owner: object }) {\n const 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 await 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;EACjC,MAAMC,cAAa,CAACD,KAAK,EAAE;AAAEE,IAAAA,cAAc,EAAE;AAAM,GAAC,CAAC;EAErDC,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,kBAAyC;AACxD,IAAA,MAAMR,KAAK,GAAG,IAAI,CAACA,KAAK;AAExBS,IAAAA,MAAM,CACJ,CAAA,kIAAA,CAAoI,EACpIT,KACF,CAAC;AAED,IAAA,MAAMD,KAAK,CAAC,IAAI,CAACC,KAAc,CAAC;AAClC,GAAC,CAAC;AACJ;;;;"}
|
package/dist/test-support/otp.js
CHANGED
|
@@ -6,18 +6,18 @@ import { find, fillIn, settled } from '@ember/test-helpers';
|
|
|
6
6
|
* @param {string} [ selector ] if there are multiple OTP components on a page, this can be used to select one of them.
|
|
7
7
|
*/
|
|
8
8
|
async function fillOTP(code, selector) {
|
|
9
|
-
|
|
9
|
+
const ancestor = selector ? find(selector) : document;
|
|
10
10
|
assert(`Could not find ancestor element, does your selector match an existing element?`, ancestor);
|
|
11
|
-
|
|
11
|
+
const fieldset = ancestor instanceof HTMLFieldSetElement ? ancestor : ancestor.querySelector('fieldset');
|
|
12
12
|
assert(`Could not find containing fieldset element (this holds the OTP Input fields). Was the OTP component rendered?`, fieldset);
|
|
13
|
-
|
|
13
|
+
const inputs = fieldset.querySelectorAll('input');
|
|
14
14
|
assert(`code cannot be longer than the available inputs. code is of length ${code.length} but there are ${inputs.length}`, code.length <= inputs.length);
|
|
15
|
-
|
|
15
|
+
const chars = code.split('');
|
|
16
16
|
assert(`OTP Input for index 0 is missing!`, inputs[0]);
|
|
17
17
|
assert(`Character at index 0 is missing`, chars[0]);
|
|
18
18
|
for (let i = 0; i < chars.length; i++) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const input = inputs[i];
|
|
20
|
+
const char = chars[i];
|
|
21
21
|
assert(`Input at index ${i} is missing`, input);
|
|
22
22
|
assert(`Character at index ${i} is missing`, char);
|
|
23
23
|
input.value = char;
|
|
@@ -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
|
|
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 const 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 const 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 const 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 const 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 const input = inputs[i];\n const 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,MAAMC,QAAQ,GAAGD,QAAQ,GAAGE,IAAI,CAACF,QAAQ,CAAC,GAAGG,QAAQ;AAErDC,EAAAA,MAAM,CACJ,CAA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AAC,CAAC;;AAEjC;EACA,MAAM,IAAIO,OAAO,CAAEC,OAAO,IAAKC,qBAAqB,CAACD,OAAO,CAAC,CAAC;EAC9D,MAAME,OAAO,EAAE;AACjB;;;;"}
|
|
@@ -38,10 +38,11 @@ function setupRouting(owner, map, options) {
|
|
|
38
38
|
owner.register('router:main', TestRouter);
|
|
39
39
|
|
|
40
40
|
// eslint-disable-next-line ember/no-private-routing-service
|
|
41
|
-
|
|
41
|
+
const iKnowWhatIMDoing = owner.lookup('router:main');
|
|
42
42
|
|
|
43
43
|
// We need a public testing API for this sort of stuff
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
45
46
|
iKnowWhatIMDoing.setupRouter();
|
|
46
47
|
}
|
|
47
48
|
function getRouter(owner) {
|
|
@@ -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
|
|
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 const iKnowWhatIMDoing = owner.lookup('router:main');\n\n // We need a public testing API for this sort of stuff\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n (iKnowWhatIMDoing as any).setupRouter();\n}\n\nexport function getRouter(owner: Owner): RouterService {\n return owner.lookup('service:router');\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,MAAMK,gBAAgB,GAAGX,KAAK,CAACY,MAAM,CAAC,aAAa,CAAC;;AAEpD;;AAEA;EACCD,gBAAgB,CAASE,WAAW,EAAE;AACzC;AAEO,SAASC,SAASA,CAACd,KAAY,EAAiB;AACrD,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;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,
|
|
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,EAAE;IAC9B,IAAIC,oBAAoB,GAAG,EAAE;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,EAAE,EAAE;AAChCA,UAAAA,qBAAqB,GAAGE,CAAC;AAC3B;AAEAD,QAAAA,oBAAoB,GAAGC,CAAC;AAC1B,OAAC,MAAM,IAAIF,qBAAqB,KAAK,EAAE,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
CHANGED
|
@@ -4,6 +4,7 @@ function uniqueId() {
|
|
|
4
4
|
// @ts-expect-error this one-liner abuses weird JavaScript semantics that
|
|
5
5
|
// TypeScript (legitimately) doesn't like, but they're nonetheless valid and
|
|
6
6
|
// specced.
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/restrict-plus-operands, @typescript-eslint/no-unsafe-member-access
|
|
7
8
|
return ([3e7] + -1e3 + -4e3 + -2e3 + -1e11).replace(/[0-3]/g, a => (a * 4 ^ Math.random() * 16 >> (a & 2)).toString(16));
|
|
8
9
|
}
|
|
9
10
|
|
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,
|
|
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 // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/restrict-plus-operands, @typescript-eslint/no-unsafe-member-access\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;AACA;EACA,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,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;;;;"}
|