ember-primitives 0.44.0 → 0.45.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.
Files changed (97) hide show
  1. package/declarations/components/heading.d.ts.map +1 -1
  2. package/declarations/components/one-time-password.d.ts +3 -0
  3. package/declarations/components/one-time-password.d.ts.map +1 -0
  4. package/declarations/components/shadowed.d.ts +33 -3
  5. package/declarations/components/shadowed.d.ts.map +1 -1
  6. package/declarations/index.d.ts +1 -1
  7. package/declarations/index.d.ts.map +1 -1
  8. package/declarations/test-support/dom.d.ts +14 -0
  9. package/declarations/test-support/dom.d.ts.map +1 -0
  10. package/declarations/test-support.d.ts +7 -0
  11. package/declarations/test-support.d.ts.map +1 -0
  12. package/dist/{floating-ui/modifier.js → component-Bs3N-G9z.js} +72 -4
  13. package/dist/component-Bs3N-G9z.js.map +1 -0
  14. package/dist/components/accordion.js +60 -1
  15. package/dist/components/heading.js +74 -7
  16. package/dist/components/one-time-password.js +3 -0
  17. package/dist/components/one-time-password.js.map +1 -0
  18. package/dist/components/popover.js +1 -2
  19. package/dist/components/rating.js +1 -1
  20. package/dist/components/shadowed.js +47 -35
  21. package/dist/components/switch.js +8 -2
  22. package/dist/components/toggle.js +1 -1
  23. package/dist/components/zoetrope.js +1 -1
  24. package/dist/floating-ui.js +1 -2
  25. package/dist/index-D052JWRa.js +149 -0
  26. package/dist/index-D052JWRa.js.map +1 -0
  27. package/dist/{components/zoetrope/index.js → index-DKE67I8L.js} +3 -3
  28. package/dist/index-DKE67I8L.js.map +1 -0
  29. package/dist/index.js +3 -4
  30. package/dist/otp-C6hCCXKx.js +291 -0
  31. package/dist/otp-C6hCCXKx.js.map +1 -0
  32. package/dist/test-support.js +255 -0
  33. package/dist/test-support.js.map +1 -0
  34. package/dist/{components/-private/utils.js → utils-C5796IKA.js} +2 -2
  35. package/dist/utils-C5796IKA.js.map +1 -0
  36. package/package.json +1 -9
  37. package/declarations/components/one-time-password/index.d.ts +0 -3
  38. package/declarations/components/one-time-password/index.d.ts.map +0 -1
  39. package/declarations/test-support/index.d.ts +0 -6
  40. package/declarations/test-support/index.d.ts.map +0 -1
  41. package/dist/components/-private/typed-elements.js +0 -14
  42. package/dist/components/-private/typed-elements.js.map +0 -1
  43. package/dist/components/-private/utils.js.map +0 -1
  44. package/dist/components/accordion/content.js +0 -6
  45. package/dist/components/accordion/content.js.map +0 -1
  46. package/dist/components/accordion/header.js +0 -7
  47. package/dist/components/accordion/header.js.map +0 -1
  48. package/dist/components/accordion/item.js +0 -7
  49. package/dist/components/accordion/item.js.map +0 -1
  50. package/dist/components/accordion/public.js +0 -2
  51. package/dist/components/accordion/public.js.map +0 -1
  52. package/dist/components/accordion/trigger.js +0 -7
  53. package/dist/components/accordion/trigger.js.map +0 -1
  54. package/dist/components/one-time-password/buttons.js +0 -26
  55. package/dist/components/one-time-password/buttons.js.map +0 -1
  56. package/dist/components/one-time-password/index.js +0 -4
  57. package/dist/components/one-time-password/index.js.map +0 -1
  58. package/dist/components/one-time-password/input.js +0 -90
  59. package/dist/components/one-time-password/input.js.map +0 -1
  60. package/dist/components/one-time-password/otp.js +0 -58
  61. package/dist/components/one-time-password/otp.js.map +0 -1
  62. package/dist/components/one-time-password/utils.js +0 -144
  63. package/dist/components/one-time-password/utils.js.map +0 -1
  64. package/dist/components/rating/index.js +0 -45
  65. package/dist/components/rating/index.js.map +0 -1
  66. package/dist/components/rating/public-types.js +0 -2
  67. package/dist/components/rating/public-types.js.map +0 -1
  68. package/dist/components/rating/range.js +0 -15
  69. package/dist/components/rating/range.js.map +0 -1
  70. package/dist/components/rating/stars.js +0 -19
  71. package/dist/components/rating/stars.js.map +0 -1
  72. package/dist/components/rating/state.js +0 -82
  73. package/dist/components/rating/state.js.map +0 -1
  74. package/dist/components/rating/utils.js +0 -18
  75. package/dist/components/rating/utils.js.map +0 -1
  76. package/dist/components/zoetrope/index.js.map +0 -1
  77. package/dist/components/zoetrope/types.js +0 -2
  78. package/dist/components/zoetrope/types.js.map +0 -1
  79. package/dist/floating-ui/component.js +0 -63
  80. package/dist/floating-ui/component.js.map +0 -1
  81. package/dist/floating-ui/middleware.js +0 -15
  82. package/dist/floating-ui/middleware.js.map +0 -1
  83. package/dist/floating-ui/modifier.js.map +0 -1
  84. package/dist/item-CwIzoqlC.js +0 -68
  85. package/dist/item-CwIzoqlC.js.map +0 -1
  86. package/dist/test-support/a11y.js +0 -24
  87. package/dist/test-support/a11y.js.map +0 -1
  88. package/dist/test-support/index.js +0 -7
  89. package/dist/test-support/index.js.map +0 -1
  90. package/dist/test-support/otp.js +0 -34
  91. package/dist/test-support/otp.js.map +0 -1
  92. package/dist/test-support/rating.js +0 -92
  93. package/dist/test-support/rating.js.map +0 -1
  94. package/dist/test-support/routing.js +0 -54
  95. package/dist/test-support/routing.js.map +0 -1
  96. package/dist/test-support/zoetrope.js +0 -43
  97. package/dist/test-support/zoetrope.js.map +0 -1
@@ -1,92 +0,0 @@
1
-
2
- import { assert } from '@ember/debug';
3
- import { find, findAll, click, fillIn } from '@ember/test-helpers';
4
-
5
- const selectors = {
6
- root: '.ember-primitives__rating',
7
- item: '.ember-primitives__rating__item',
8
- label: '.ember-primitives__rating__label'};
9
- const stars = {
10
- selected: '★',
11
- unselected: '☆'
12
- };
13
-
14
- /**
15
- * Test utility for interacting with the
16
- * Rating component.
17
- *
18
- * Simulates user behavior and provides high level functions so you don't need to worry about the DOM.
19
- *
20
- * Actual elements are not exposed, as the elements are private API.
21
- * Even as you build a design system, the DOM should not be exposed to your consumers.
22
- */
23
- function rating(selector) {
24
- const root = `${selector ?? ''}${selectors.root}`;
25
- return new RatingPageObject(root);
26
- }
27
- class RatingPageObject {
28
- #root;
29
- constructor(root) {
30
- this.#root = root;
31
- }
32
- get #rootElement() {
33
- const element = find(this.#root);
34
- assert(`Could not find the root element for the <Rating> component. Used the selector \`${this.#root}\`. Was it rendered?`, element);
35
- return element;
36
- }
37
- get #labelElement() {
38
- const element = find(`${this.#root} ${selectors.label}`);
39
- assert(`Could not find the label for the <Rating> component. Was it rendered?`, element);
40
- return element;
41
- }
42
- get label() {
43
- return this.#labelElement.textContent?.replaceAll(/\s+/g, ' ').trim();
44
- }
45
- get #starElements() {
46
- const elements = findAll(`${this.#root} ${selectors.item}`);
47
- assert(`There are no stars/items. Is the <Rating> component misconfigured?`, elements.length > 0);
48
- return elements;
49
- }
50
- get stars() {
51
- const elements = this.#starElements;
52
- return elements.map(x => x.hasAttribute('data-selected') ? stars.selected : stars.unselected).join(' ');
53
- }
54
- get starTexts() {
55
- const elements = this.#starElements;
56
- return elements.map(x => x.querySelector('[aria-hidden]')?.textContent?.trim()).join(' ');
57
- }
58
- get value() {
59
- const value = this.#rootElement.getAttribute(`data-value`);
60
- assert(`data-value attribute is missing on element '${this.#root}'`, value);
61
- const number = parseFloat(value);
62
- return number;
63
- }
64
- get isReadonly() {
65
- return this.#starElements.every(x => x.hasAttribute('data-readonly'));
66
- }
67
- async select(stars) {
68
- const root = this.#rootElement;
69
- const star = root.querySelector(`[data-number="${stars}"] input`);
70
- if (star) {
71
- await click(star);
72
- return;
73
- }
74
-
75
- /**
76
- * When we don't have an input, we require an input --
77
- * which is also the only way we can choose non-integer values.
78
- *
79
- * Should be able to be a number input or range input.
80
- */
81
- const input = root.querySelector('input[type="number"], input[type="range"]');
82
- if (input) {
83
- await fillIn(input, `${stars}`);
84
- return;
85
- }
86
- const available = [...root.querySelectorAll('[data-number]')].map(x => x.getAttribute('data-number'));
87
- assert(`Could not find item/star in <Rating> with value '${stars}' (or a number or range input with the same "name" value). Is the number (${stars}) correct and in-range for this component? The found available values are ${available.join(', ')}.`);
88
- }
89
- }
90
-
91
- export { rating };
92
- //# sourceMappingURL=rating.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rating.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,54 +0,0 @@
1
-
2
- import { assert } from '@ember/debug';
3
- import Router from '@ember/routing/router';
4
- import { properLinks } from '../proper-links.js';
5
- import { c } from 'decorator-transforms/runtime';
6
-
7
- /**
8
- * Allows setting up routes in tests without the need to scaffold routes in the actual app,
9
- * allowing for iterating on many different routing scenario / configurations rapidly.
10
- *
11
- * Example:
12
- * ```js
13
- * import { setupRouting } from 'ember-primitives/test-support';
14
- *
15
- * ...
16
- *
17
- * test('my test', async function (assert) {
18
- * setupRouting(this.owner, function () {
19
- * this.route('foo');
20
- * this.route('bar', function () {
21
- * this.route('a');
22
- * this.route('b');
23
- * })
24
- * });
25
- *
26
- * await visit('/bar/b');
27
- * });
28
- * ```
29
- *
30
- */
31
- function setupRouting(owner, map, options) {
32
- if (options?.rootURL) {
33
- assert('rootURL must begin with a forward slash ("/")', options?.rootURL?.startsWith('/'));
34
- }
35
- const TestRouter = c(class TestRouter extends Router {
36
- rootURL = options?.rootURL ?? '/';
37
- }, [properLinks]);
38
- TestRouter.map(map);
39
- owner.register('router:main', TestRouter);
40
-
41
- // eslint-disable-next-line ember/no-private-routing-service
42
- const iKnowWhatIMDoing = owner.lookup('router:main');
43
-
44
- // We need a public testing API for this sort of stuff
45
-
46
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
47
- iKnowWhatIMDoing.setupRouter();
48
- }
49
- function getRouter(owner) {
50
- return owner.lookup('service:router');
51
- }
52
-
53
- export { getRouter, setupRouting };
54
- //# sourceMappingURL=routing.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routing.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,43 +0,0 @@
1
-
2
- import { click } from '@ember/test-helpers';
3
-
4
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
5
- class ZoetropeHelper {
6
- parentSelector = '.ember-primitives__zoetrope';
7
- constructor(parentSelector) {
8
- if (parentSelector) {
9
- this.parentSelector = parentSelector;
10
- }
11
- }
12
- async scrollLeft() {
13
- await click(`${this.parentSelector} .ember-primitives__zoetrope__controls button:first-child`);
14
- }
15
- async scrollRight() {
16
- await click(`${this.parentSelector} .ember-primitives__zoetrope__controls button:last-child`);
17
- }
18
- visibleItems() {
19
- const zoetropeContent = document.querySelectorAll(`${this.parentSelector} .ember-primitives__zoetrope__scroller > *`);
20
- let firstVisibleItemIndex = -1;
21
- let lastVisibleItemIndex = -1;
22
- for (let i = 0; i < zoetropeContent.length; i++) {
23
- const item = zoetropeContent[i];
24
- const rect = item.getBoundingClientRect();
25
- const parentRect = item.parentElement.getBoundingClientRect();
26
- if (rect.right >= parentRect?.left && rect.left <= parentRect?.right) {
27
- if (firstVisibleItemIndex === -1) {
28
- firstVisibleItemIndex = i;
29
- }
30
- lastVisibleItemIndex = i;
31
- } else if (firstVisibleItemIndex !== -1) {
32
- break;
33
- }
34
- }
35
- return Array.from(zoetropeContent).slice(firstVisibleItemIndex, lastVisibleItemIndex + 1);
36
- }
37
- visibleItemCount() {
38
- return this.visibleItems().length;
39
- }
40
- }
41
-
42
- export { ZoetropeHelper };
43
- //# sourceMappingURL=zoetrope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zoetrope.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}