ember-primitives 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/components/heading.d.ts.map +1 -1
- package/declarations/components/one-time-password.d.ts +3 -0
- package/declarations/components/one-time-password.d.ts.map +1 -0
- package/declarations/components/shadowed.d.ts +33 -3
- package/declarations/components/shadowed.d.ts.map +1 -1
- package/declarations/index.d.ts +1 -1
- package/declarations/index.d.ts.map +1 -1
- package/declarations/test-support/dom.d.ts +14 -0
- package/declarations/test-support/dom.d.ts.map +1 -0
- package/declarations/test-support.d.ts +7 -0
- package/declarations/test-support.d.ts.map +1 -0
- package/dist/{floating-ui/modifier.js → component-Bs3N-G9z.js} +72 -4
- package/dist/component-Bs3N-G9z.js.map +1 -0
- package/dist/components/accordion.js +60 -1
- package/dist/components/heading.js +64 -7
- package/dist/components/one-time-password.js +3 -0
- package/dist/components/one-time-password.js.map +1 -0
- package/dist/components/popover.js +1 -2
- package/dist/components/rating.js +1 -1
- package/dist/components/shadowed.js +47 -35
- package/dist/components/switch.js +8 -2
- package/dist/components/toggle.js +1 -1
- package/dist/components/zoetrope.js +1 -1
- package/dist/floating-ui.js +1 -2
- package/dist/index-D052JWRa.js +149 -0
- package/dist/index-D052JWRa.js.map +1 -0
- package/dist/{components/zoetrope/index.js → index-DKE67I8L.js} +3 -3
- package/dist/index-DKE67I8L.js.map +1 -0
- package/dist/index.js +3 -4
- package/dist/otp-C6hCCXKx.js +291 -0
- package/dist/otp-C6hCCXKx.js.map +1 -0
- package/dist/test-support.js +255 -0
- package/dist/test-support.js.map +1 -0
- package/dist/{components/-private/utils.js → utils-C5796IKA.js} +2 -2
- package/dist/utils-C5796IKA.js.map +1 -0
- package/package.json +1 -9
- package/declarations/components/one-time-password/index.d.ts +0 -3
- package/declarations/components/one-time-password/index.d.ts.map +0 -1
- package/declarations/test-support/index.d.ts +0 -6
- package/declarations/test-support/index.d.ts.map +0 -1
- package/dist/components/-private/typed-elements.js +0 -14
- package/dist/components/-private/typed-elements.js.map +0 -1
- package/dist/components/-private/utils.js.map +0 -1
- package/dist/components/accordion/content.js +0 -6
- package/dist/components/accordion/content.js.map +0 -1
- package/dist/components/accordion/header.js +0 -7
- package/dist/components/accordion/header.js.map +0 -1
- package/dist/components/accordion/item.js +0 -7
- package/dist/components/accordion/item.js.map +0 -1
- package/dist/components/accordion/public.js +0 -2
- package/dist/components/accordion/public.js.map +0 -1
- package/dist/components/accordion/trigger.js +0 -7
- package/dist/components/accordion/trigger.js.map +0 -1
- package/dist/components/one-time-password/buttons.js +0 -26
- package/dist/components/one-time-password/buttons.js.map +0 -1
- package/dist/components/one-time-password/index.js +0 -4
- package/dist/components/one-time-password/index.js.map +0 -1
- package/dist/components/one-time-password/input.js +0 -90
- package/dist/components/one-time-password/input.js.map +0 -1
- package/dist/components/one-time-password/otp.js +0 -58
- package/dist/components/one-time-password/otp.js.map +0 -1
- package/dist/components/one-time-password/utils.js +0 -144
- package/dist/components/one-time-password/utils.js.map +0 -1
- package/dist/components/rating/index.js +0 -45
- package/dist/components/rating/index.js.map +0 -1
- package/dist/components/rating/public-types.js +0 -2
- package/dist/components/rating/public-types.js.map +0 -1
- package/dist/components/rating/range.js +0 -15
- package/dist/components/rating/range.js.map +0 -1
- package/dist/components/rating/stars.js +0 -19
- package/dist/components/rating/stars.js.map +0 -1
- package/dist/components/rating/state.js +0 -82
- package/dist/components/rating/state.js.map +0 -1
- package/dist/components/rating/utils.js +0 -18
- package/dist/components/rating/utils.js.map +0 -1
- package/dist/components/zoetrope/index.js.map +0 -1
- package/dist/components/zoetrope/types.js +0 -2
- package/dist/components/zoetrope/types.js.map +0 -1
- package/dist/floating-ui/component.js +0 -63
- package/dist/floating-ui/component.js.map +0 -1
- package/dist/floating-ui/middleware.js +0 -15
- package/dist/floating-ui/middleware.js.map +0 -1
- package/dist/floating-ui/modifier.js.map +0 -1
- package/dist/item-CwIzoqlC.js +0 -68
- package/dist/item-CwIzoqlC.js.map +0 -1
- package/dist/test-support/a11y.js +0 -24
- package/dist/test-support/a11y.js.map +0 -1
- package/dist/test-support/index.js +0 -7
- package/dist/test-support/index.js.map +0 -1
- package/dist/test-support/otp.js +0 -34
- package/dist/test-support/otp.js.map +0 -1
- package/dist/test-support/rating.js +0 -92
- package/dist/test-support/rating.js.map +0 -1
- package/dist/test-support/routing.js +0 -54
- package/dist/test-support/routing.js.map +0 -1
- package/dist/test-support/zoetrope.js +0 -43
- package/dist/test-support/zoetrope.js.map +0 -1
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
|
|
4
|
-
function getInputs(current) {
|
|
5
|
-
const fieldset = current.closest('fieldset');
|
|
6
|
-
assert('[BUG]: fieldset went missing', fieldset);
|
|
7
|
-
return [...fieldset.querySelectorAll('input')];
|
|
8
|
-
}
|
|
9
|
-
function nextInput(current) {
|
|
10
|
-
const inputs = getInputs(current);
|
|
11
|
-
const currentIndex = inputs.indexOf(current);
|
|
12
|
-
return inputs[currentIndex + 1];
|
|
13
|
-
}
|
|
14
|
-
function selectAll(event) {
|
|
15
|
-
const target = event.target;
|
|
16
|
-
assert(`selectAll is only meant for use with input elements`, target instanceof HTMLInputElement);
|
|
17
|
-
target.select();
|
|
18
|
-
}
|
|
19
|
-
function handlePaste(event) {
|
|
20
|
-
const target = event.target;
|
|
21
|
-
assert(`handlePaste is only meant for use with input elements`, target instanceof HTMLInputElement);
|
|
22
|
-
const clipboardData = event.clipboardData;
|
|
23
|
-
assert(`Could not get clipboardData while handling the paste event on OTP. Please report this issue on the ember-primitives repo with a reproduction. Thanks!`, clipboardData);
|
|
24
|
-
|
|
25
|
-
// This is typically not good to prevent paste.
|
|
26
|
-
// But because of the UX we're implementing,
|
|
27
|
-
// we want to split the pasted value across
|
|
28
|
-
// multiple text fields
|
|
29
|
-
event.preventDefault();
|
|
30
|
-
const value = clipboardData.getData('Text');
|
|
31
|
-
const digits = value;
|
|
32
|
-
let i = 0;
|
|
33
|
-
let currElement = target;
|
|
34
|
-
while (currElement) {
|
|
35
|
-
currElement.value = digits[i++] || '';
|
|
36
|
-
const next = nextInput(currElement);
|
|
37
|
-
if (next instanceof HTMLInputElement) {
|
|
38
|
-
currElement = next;
|
|
39
|
-
} else {
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// We want to select the first field again
|
|
45
|
-
// so that if someone holds paste, or
|
|
46
|
-
// pastes again, they get the same result.
|
|
47
|
-
target.select();
|
|
48
|
-
}
|
|
49
|
-
function handleNavigation(event) {
|
|
50
|
-
switch (event.key) {
|
|
51
|
-
case 'Backspace':
|
|
52
|
-
return handleBackspace(event);
|
|
53
|
-
case 'ArrowLeft':
|
|
54
|
-
return focusLeft(event);
|
|
55
|
-
case 'ArrowRight':
|
|
56
|
-
return focusRight(event);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function focusLeft(event) {
|
|
60
|
-
const target = event.target;
|
|
61
|
-
assert(`only allowed on input elements`, target instanceof HTMLInputElement);
|
|
62
|
-
const input = previousInput(target);
|
|
63
|
-
input?.focus();
|
|
64
|
-
requestAnimationFrame(() => {
|
|
65
|
-
input?.select();
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function focusRight(event) {
|
|
69
|
-
const target = event.target;
|
|
70
|
-
assert(`only allowed on input elements`, target instanceof HTMLInputElement);
|
|
71
|
-
const input = nextInput(target);
|
|
72
|
-
input?.focus();
|
|
73
|
-
requestAnimationFrame(() => {
|
|
74
|
-
input?.select();
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
const syntheticEvent = new InputEvent('input');
|
|
78
|
-
function handleBackspace(event) {
|
|
79
|
-
if (event.key !== 'Backspace') return;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* We have to prevent default because we
|
|
83
|
-
* - want to clear the whole field
|
|
84
|
-
* - have the focus behavior keep up with the key-repeat
|
|
85
|
-
* speed of the user's computer
|
|
86
|
-
*/
|
|
87
|
-
event.preventDefault();
|
|
88
|
-
const target = event.target;
|
|
89
|
-
if (target && 'value' in target) {
|
|
90
|
-
if (target.value === '') {
|
|
91
|
-
focusLeft({
|
|
92
|
-
target
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
target.value = '';
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
target?.dispatchEvent(syntheticEvent);
|
|
99
|
-
}
|
|
100
|
-
function previousInput(current) {
|
|
101
|
-
const inputs = getInputs(current);
|
|
102
|
-
const currentIndex = inputs.indexOf(current);
|
|
103
|
-
return inputs[currentIndex - 1];
|
|
104
|
-
}
|
|
105
|
-
const autoAdvance = event => {
|
|
106
|
-
assert('[BUG]: autoAdvance called on non-input element', event.target instanceof HTMLInputElement);
|
|
107
|
-
const value = event.target.value;
|
|
108
|
-
if (value.length === 0) return;
|
|
109
|
-
if (value.length > 0) {
|
|
110
|
-
if ('data' in event && event.data && typeof event.data === 'string') {
|
|
111
|
-
event.target.value = event.data;
|
|
112
|
-
}
|
|
113
|
-
return focusRight(event);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
function getCollectiveValue(elementTarget, length) {
|
|
117
|
-
if (!elementTarget) return;
|
|
118
|
-
assert(`[BUG]: somehow the element target is not HTMLElement`, elementTarget instanceof HTMLElement);
|
|
119
|
-
let parent;
|
|
120
|
-
|
|
121
|
-
// TODO: should this logic be extracted?
|
|
122
|
-
// why is getting the target element within a shadow root hard?
|
|
123
|
-
if (!(elementTarget instanceof HTMLInputElement)) {
|
|
124
|
-
if (elementTarget.shadowRoot) {
|
|
125
|
-
parent = elementTarget.shadowRoot;
|
|
126
|
-
} else {
|
|
127
|
-
parent = elementTarget.closest('fieldset');
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
parent = elementTarget.closest('fieldset');
|
|
131
|
-
}
|
|
132
|
-
assert(`[BUG]: somehow the input fields were rendered without a parent element`, parent);
|
|
133
|
-
const elements = parent.querySelectorAll('input');
|
|
134
|
-
let value = '';
|
|
135
|
-
assert(`found elements (${elements.length}) do not match length (${length}). Was the same OTP input rendered more than once?`, elements.length === length);
|
|
136
|
-
for (const element of elements) {
|
|
137
|
-
assert('[BUG]: how did the queried elements become a non-input element?', element instanceof HTMLInputElement);
|
|
138
|
-
value += element.value;
|
|
139
|
-
}
|
|
140
|
-
return value;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export { autoAdvance, getCollectiveValue, handleNavigation, handlePaste, selectAll };
|
|
144
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import Component from '@glimmer/component';
|
|
3
|
-
import { hash } from '@ember/helper';
|
|
4
|
-
import { on } from '@ember/modifier';
|
|
5
|
-
import { uniqueId } from '../../utils.js';
|
|
6
|
-
import { RatingRange } from './range.js';
|
|
7
|
-
import { Stars } from './stars.js';
|
|
8
|
-
import { RatingState } from './state.js';
|
|
9
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
|
-
import { setComponentTemplate } from '@ember/component';
|
|
11
|
-
|
|
12
|
-
class Rating extends Component {
|
|
13
|
-
name = `rating-${uniqueId()}`;
|
|
14
|
-
get icon() {
|
|
15
|
-
return this.args.icon ?? "★";
|
|
16
|
-
}
|
|
17
|
-
get isInteractive() {
|
|
18
|
-
return this.args.interactive ?? true;
|
|
19
|
-
}
|
|
20
|
-
get isChangeable() {
|
|
21
|
-
const readonly = this.args.readonly ?? false;
|
|
22
|
-
return !readonly && this.isInteractive;
|
|
23
|
-
}
|
|
24
|
-
get isReadonly() {
|
|
25
|
-
return !this.isChangeable;
|
|
26
|
-
}
|
|
27
|
-
get needsDescription() {
|
|
28
|
-
return !this.isInteractive;
|
|
29
|
-
}
|
|
30
|
-
static {
|
|
31
|
-
setComponentTemplate(precompileTemplate("\n <RatingState @max={{@max}} @value={{@value}} @name={{this.name}} @readonly={{this.isReadonly}} @onChange={{@onChange}} as |r publicState|>\n <fieldset class=\"ember-primitives__rating\" data-total={{r.total}} data-value={{r.value}} data-readonly={{this.isReadonly}} {{!-- We use event delegation, this isn't a primary interactive -- we're capturing events from inputs --}} {{!-- template-lint-disable no-invalid-interactive --}} {{on \"click\" r.handleClick}} ...attributes>\n {{#let (component Stars stars=r.stars icon=this.icon isReadonly=this.isReadonly name=this.name total=r.total currentValue=r.value) as |RatingStars|}}\n\n {{#if (has-block)}}\n {{yield (hash max=r.total total=r.total value=r.value name=this.name isReadonly=this.isReadonly isChangeable=this.isChangeable Stars=RatingStars Range=(component RatingRange max=r.total value=r.value name=this.name handleChange=r.handleChange))}}\n {{else}}\n {{#if this.needsDescription}}\n {{#if (has-block \"label\")}}\n {{yield publicState to=\"label\"}}\n {{else}}\n <span visually-hidden class=\"ember-primitives__rating__label\">Rated\n {{r.value}}\n out of\n {{r.total}}</span>\n {{/if}}\n {{else}}\n {{#if (has-block \"label\")}}\n <legend>\n {{yield publicState to=\"label\"}}\n </legend>\n {{/if}}\n {{/if}}\n\n <RatingStars />\n {{/if}}\n {{/let}}\n\n </fieldset>\n </RatingState>\n ", {
|
|
32
|
-
strictMode: true,
|
|
33
|
-
scope: () => ({
|
|
34
|
-
RatingState,
|
|
35
|
-
on,
|
|
36
|
-
Stars,
|
|
37
|
-
hash,
|
|
38
|
-
RatingRange
|
|
39
|
-
})
|
|
40
|
-
}), this);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { Rating };
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"public-types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { on } from '@ember/modifier';
|
|
3
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
|
-
import { setComponentTemplate } from '@ember/component';
|
|
5
|
-
import templateOnly from '@ember/component/template-only';
|
|
6
|
-
|
|
7
|
-
const RatingRange = setComponentTemplate(precompileTemplate("\n <input ...attributes name={{@name}} type=\"range\" max={{@max}} value={{@value}} {{on \"change\" @handleChange}} />\n", {
|
|
8
|
-
strictMode: true,
|
|
9
|
-
scope: () => ({
|
|
10
|
-
on
|
|
11
|
-
})
|
|
12
|
-
}), templateOnly());
|
|
13
|
-
|
|
14
|
-
export { RatingRange };
|
|
15
|
-
//# sourceMappingURL=range.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { uniqueId } from '../../utils.js';
|
|
3
|
-
import { isString, lte, percentSelected } from './utils.js';
|
|
4
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
|
-
import { setComponentTemplate } from '@ember/component';
|
|
6
|
-
import templateOnly from '@ember/component/template-only';
|
|
7
|
-
|
|
8
|
-
const Stars = setComponentTemplate(precompileTemplate("\n <div class=\"ember-primitives__rating__items\">\n {{#each @stars as |star|}}\n {{#let (uniqueId) as |id|}}\n <span class=\"ember-primitives__rating__item\" data-number={{star}} data-percent-selected={{percentSelected star @currentValue}} data-selected={{lte star @currentValue}} data-readonly={{@isReadonly}}>\n <label for=\"input-{{id}}\">\n <span visually-hidden>{{star}} star</span>\n <span aria-hidden=\"true\">\n {{#if (isString @icon)}}\n {{@icon}}\n {{else}}\n <@icon @value={{star}} @isSelected={{lte star @currentValue}} @percentSelected={{percentSelected star @currentValue}} @readonly={{@isReadonly}} />\n {{/if}}\n </span>\n </label>\n\n <input id=\"input-{{id}}\" type=\"radio\" name={{@name}} value={{star}} readonly={{@isReadonly}} checked={{lte star @currentValue}} />\n </span>\n {{/let}}\n {{/each}}\n </div>\n", {
|
|
9
|
-
strictMode: true,
|
|
10
|
-
scope: () => ({
|
|
11
|
-
uniqueId,
|
|
12
|
-
percentSelected,
|
|
13
|
-
lte,
|
|
14
|
-
isString
|
|
15
|
-
})
|
|
16
|
-
}), templateOnly());
|
|
17
|
-
|
|
18
|
-
export { Stars };
|
|
19
|
-
//# sourceMappingURL=stars.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stars.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import Component from '@glimmer/component';
|
|
3
|
-
import { cached } from '@glimmer/tracking';
|
|
4
|
-
import { assert } from '@ember/debug';
|
|
5
|
-
import { hash } from '@ember/helper';
|
|
6
|
-
import { localCopy } from 'tracked-toolbox';
|
|
7
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
|
-
import { setComponentTemplate } from '@ember/component';
|
|
9
|
-
import { g, i, n } from 'decorator-transforms/runtime';
|
|
10
|
-
|
|
11
|
-
class RatingState extends Component {
|
|
12
|
-
static {
|
|
13
|
-
g(this.prototype, "_value", [localCopy("args.value")]);
|
|
14
|
-
}
|
|
15
|
-
#_value = (i(this, "_value"), void 0); // eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
16
|
-
get value() {
|
|
17
|
-
return this._value ?? 0;
|
|
18
|
-
}
|
|
19
|
-
get stars() {
|
|
20
|
-
return Array.from({
|
|
21
|
-
length: this.args.max ?? 5
|
|
22
|
-
}, (_, index) => index + 1);
|
|
23
|
-
}
|
|
24
|
-
static {
|
|
25
|
-
n(this.prototype, "stars", [cached]);
|
|
26
|
-
}
|
|
27
|
-
setRating = value => {
|
|
28
|
-
if (this.args.readonly) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (value === this._value) {
|
|
32
|
-
this._value = 0;
|
|
33
|
-
} else {
|
|
34
|
-
this._value = value;
|
|
35
|
-
}
|
|
36
|
-
this.args.onChange?.(value);
|
|
37
|
-
};
|
|
38
|
-
setFromString = value => {
|
|
39
|
-
assert("[BUG]: value from input must be a string.", typeof value === "string");
|
|
40
|
-
const num = parseFloat(value);
|
|
41
|
-
if (isNaN(num)) {
|
|
42
|
-
// something went wrong.
|
|
43
|
-
// Since we're using event delegation,
|
|
44
|
-
// this could be from an unrelated input
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
this.setRating(num);
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Click events are captured by
|
|
51
|
-
* - radio changes (mouse and keyboard)
|
|
52
|
-
* - but only range clicks
|
|
53
|
-
*/
|
|
54
|
-
handleClick = event => {
|
|
55
|
-
// Since we're doing event delegation on a click, we want to make sure
|
|
56
|
-
// we don't do anything on other elements
|
|
57
|
-
const isValid = event.target instanceof HTMLInputElement && event.target.name === this.args.name && event.target.type === "radio";
|
|
58
|
-
if (!isValid) return;
|
|
59
|
-
const selected = event.target?.value;
|
|
60
|
-
this.setFromString(selected);
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Only attached to a range element, if present.
|
|
64
|
-
* Range elements don't fire click events on keyboard usage, like radios do
|
|
65
|
-
*/
|
|
66
|
-
handleChange = event => {
|
|
67
|
-
const isValid = event.target !== null && "value" in event.target;
|
|
68
|
-
if (!isValid) return;
|
|
69
|
-
this.setFromString(event.target.value);
|
|
70
|
-
};
|
|
71
|
-
static {
|
|
72
|
-
setComponentTemplate(precompileTemplate("\n {{yield (hash stars=this.stars total=this.stars.length handleClick=this.handleClick handleChange=this.handleChange setRating=this.setRating value=this.value) (hash total=this.stars.length value=this.value)}}\n ", {
|
|
73
|
-
strictMode: true,
|
|
74
|
-
scope: () => ({
|
|
75
|
-
hash
|
|
76
|
-
})
|
|
77
|
-
}), this);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { RatingState };
|
|
82
|
-
//# sourceMappingURL=state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function isString(x) {
|
|
3
|
-
return typeof x === 'string';
|
|
4
|
-
}
|
|
5
|
-
function lte(a, b) {
|
|
6
|
-
return a <= b;
|
|
7
|
-
}
|
|
8
|
-
function percentSelected(a, b) {
|
|
9
|
-
const diff = b + 1 - a;
|
|
10
|
-
if (diff < 0) return 0;
|
|
11
|
-
if (diff > 1) return 100;
|
|
12
|
-
if (a === b) return 100;
|
|
13
|
-
const percent = diff * 100;
|
|
14
|
-
return percent;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { isString, lte, percentSelected };
|
|
18
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import Component from '@glimmer/component';
|
|
3
|
-
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
import { hash } from '@ember/helper';
|
|
5
|
-
import { modifier } from 'ember-modifier';
|
|
6
|
-
import { anchorTo } from './modifier.js';
|
|
7
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
|
-
import { setComponentTemplate } from '@ember/component';
|
|
9
|
-
import { g, i } from 'decorator-transforms/runtime';
|
|
10
|
-
|
|
11
|
-
const ref = modifier((element, positional) => {
|
|
12
|
-
const fn = positional[0];
|
|
13
|
-
fn(element);
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* A component that provides no DOM and yields two modifiers for creating
|
|
17
|
-
* creating floating uis, such as menus, popovers, tooltips, etc.
|
|
18
|
-
* This component currently uses [Floating UI](https://floating-ui.com/)
|
|
19
|
-
* but will be switching to [CSS Anchor Positioning](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_anchor_positioning) when that lands.
|
|
20
|
-
*
|
|
21
|
-
* Example usage:
|
|
22
|
-
* ```gjs
|
|
23
|
-
* import { FloatingUI } from 'ember-primitives/floating-ui';
|
|
24
|
-
*
|
|
25
|
-
* <template>
|
|
26
|
-
* <FloatingUI as |reference floating|>
|
|
27
|
-
* <button {{reference}}> ... </button>
|
|
28
|
-
* <menu {{floating}}> ... </menu>
|
|
29
|
-
* </FloatingUI>
|
|
30
|
-
* </template>
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
class FloatingUI extends Component {
|
|
34
|
-
static {
|
|
35
|
-
g(this.prototype, "reference", [tracked], function () {
|
|
36
|
-
return undefined;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
#reference = (i(this, "reference"), void 0);
|
|
40
|
-
static {
|
|
41
|
-
g(this.prototype, "data", [tracked], function () {
|
|
42
|
-
return undefined;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
#data = (i(this, "data"), void 0);
|
|
46
|
-
setData = data => this.data = data;
|
|
47
|
-
setReference = element => {
|
|
48
|
-
this.reference = element;
|
|
49
|
-
};
|
|
50
|
-
static {
|
|
51
|
-
setComponentTemplate(precompileTemplate("\n {{#let (modifier anchorTo flipOptions=@flipOptions hideOptions=@hideOptions middleware=@middleware offsetOptions=@offsetOptions placement=@placement shiftOptions=@shiftOptions strategy=@strategy setData=this.setData) as |prewiredAnchorTo|}}\n {{#let (if this.reference (modifier prewiredAnchorTo this.reference)) as |floating|}}\n {{!-- @glint-nocheck -- Excessively deep, possibly infinite --}}\n {{yield (modifier ref this.setReference) floating (hash setReference=this.setReference data=this.data)}}\n {{/let}}\n {{/let}}\n ", {
|
|
52
|
-
strictMode: true,
|
|
53
|
-
scope: () => ({
|
|
54
|
-
anchorTo,
|
|
55
|
-
ref,
|
|
56
|
-
hash
|
|
57
|
-
})
|
|
58
|
-
}), this);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { FloatingUI };
|
|
63
|
-
//# sourceMappingURL=component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function exposeMetadata() {
|
|
3
|
-
return {
|
|
4
|
-
name: 'metadata',
|
|
5
|
-
fn: data => {
|
|
6
|
-
// https://floating-ui.com/docs/middleware#always-return-an-object
|
|
7
|
-
return {
|
|
8
|
-
data
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { exposeMetadata };
|
|
15
|
-
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modifier.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/item-CwIzoqlC.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import Component from '@glimmer/component';
|
|
3
|
-
import { hash } from '@ember/helper';
|
|
4
|
-
import { on } from '@ember/modifier';
|
|
5
|
-
import { precompileTemplate } from '@ember/template-compilation';
|
|
6
|
-
import { setComponentTemplate } from '@ember/component';
|
|
7
|
-
import templateOnly from '@ember/component/template-only';
|
|
8
|
-
|
|
9
|
-
class AccordionContent extends Component {
|
|
10
|
-
static {
|
|
11
|
-
setComponentTemplate(precompileTemplate("\n <div role=\"region\" id={{@value}} data-state={{getDataState @isExpanded}} hidden={{this.isHidden}} data-disabled={{@disabled}} ...attributes>\n {{yield}}\n </div>\n ", {
|
|
12
|
-
strictMode: true,
|
|
13
|
-
scope: () => ({
|
|
14
|
-
getDataState
|
|
15
|
-
})
|
|
16
|
-
}), this);
|
|
17
|
-
}
|
|
18
|
-
get isHidden() {
|
|
19
|
-
return !this.args.isExpanded;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const AccordionTrigger = setComponentTemplate(precompileTemplate("\n <button type=\"button\" aria-controls={{@value}} aria-expanded={{@isExpanded}} data-state={{getDataState @isExpanded}} data-disabled={{@disabled}} aria-disabled={{if @disabled \"true\" \"false\"}} {{on \"click\" @toggleItem}} ...attributes>\n {{yield}}\n </button>\n", {
|
|
24
|
-
strictMode: true,
|
|
25
|
-
scope: () => ({
|
|
26
|
-
getDataState,
|
|
27
|
-
on
|
|
28
|
-
})
|
|
29
|
-
}), templateOnly());
|
|
30
|
-
|
|
31
|
-
const AccordionHeader = setComponentTemplate(precompileTemplate("\n <div role=\"heading\" aria-level=\"3\" data-state={{getDataState @isExpanded}} data-disabled={{@disabled}} ...attributes>\n {{yield (hash Trigger=(component Trigger value=@value isExpanded=@isExpanded disabled=@disabled toggleItem=@toggleItem))}}\n </div>\n", {
|
|
32
|
-
strictMode: true,
|
|
33
|
-
scope: () => ({
|
|
34
|
-
getDataState,
|
|
35
|
-
hash,
|
|
36
|
-
Trigger: AccordionTrigger
|
|
37
|
-
})
|
|
38
|
-
}), templateOnly());
|
|
39
|
-
|
|
40
|
-
function getDataState(isExpanded) {
|
|
41
|
-
return isExpanded ? "open" : "closed";
|
|
42
|
-
}
|
|
43
|
-
class AccordionItem extends Component {
|
|
44
|
-
static {
|
|
45
|
-
setComponentTemplate(precompileTemplate("\n <div data-state={{getDataState this.isExpanded}} data-disabled={{@disabled}} ...attributes>\n {{yield (hash isExpanded=this.isExpanded Header=(component Header value=@value isExpanded=this.isExpanded disabled=@disabled toggleItem=this.toggleItem) Content=(component Content value=@value isExpanded=this.isExpanded disabled=@disabled))}}\n </div>\n ", {
|
|
46
|
-
strictMode: true,
|
|
47
|
-
scope: () => ({
|
|
48
|
-
getDataState,
|
|
49
|
-
hash,
|
|
50
|
-
Header: AccordionHeader,
|
|
51
|
-
Content: AccordionContent
|
|
52
|
-
})
|
|
53
|
-
}), this);
|
|
54
|
-
}
|
|
55
|
-
get isExpanded() {
|
|
56
|
-
if (Array.isArray(this.args.selectedValue)) {
|
|
57
|
-
return this.args.selectedValue.includes(this.args.value);
|
|
58
|
-
}
|
|
59
|
-
return this.args.selectedValue === this.args.value;
|
|
60
|
-
}
|
|
61
|
-
toggleItem = () => {
|
|
62
|
-
if (this.args.disabled) return;
|
|
63
|
-
this.args.toggleItem(this.args.value);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { AccordionItem as A, AccordionContent as a, AccordionTrigger as b, AccordionHeader as c, getDataState as g };
|
|
68
|
-
//# sourceMappingURL=item-CwIzoqlC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"item-CwIzoqlC.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
import { setupTabster as setupTabster$1 } from '../tabster.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Sets up all support utilities for primitive components.
|
|
7
|
-
* Including the tabster root.
|
|
8
|
-
*/
|
|
9
|
-
async function setup(owner) {
|
|
10
|
-
await setupTabster$1(owner, {
|
|
11
|
-
setTabsterRoot: false
|
|
12
|
-
});
|
|
13
|
-
document.querySelector('#ember-testing')?.setAttribute('data-tabster', '{ "root": {} }');
|
|
14
|
-
}
|
|
15
|
-
function setupTabster(hooks) {
|
|
16
|
-
hooks.beforeEach(async function () {
|
|
17
|
-
const owner = this.owner;
|
|
18
|
-
assert(`Test does not have an owner, be sure to use setupRenderingTest, setupTest, or setupApplicationTest (from ember-qunit (or similar))`, owner);
|
|
19
|
-
await setup(this.owner);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { setupTabster };
|
|
24
|
-
//# sourceMappingURL=a11y.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"a11y.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/test-support/otp.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
import { find, fillIn, settled } from '@ember/test-helpers';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {string} code the code to fill the input(s) with.
|
|
7
|
-
* @param {string} [ selector ] if there are multiple OTP components on a page, this can be used to select one of them.
|
|
8
|
-
*/
|
|
9
|
-
async function fillOTP(code, selector) {
|
|
10
|
-
const ancestor = selector ? find(selector) : document;
|
|
11
|
-
assert(`Could not find ancestor element, does your selector match an existing element?`, ancestor);
|
|
12
|
-
const fieldset = ancestor instanceof HTMLFieldSetElement ? ancestor : ancestor.querySelector('fieldset');
|
|
13
|
-
assert(`Could not find containing fieldset element (this holds the OTP Input fields). Was the OTP component rendered?`, fieldset);
|
|
14
|
-
const inputs = fieldset.querySelectorAll('input');
|
|
15
|
-
assert(`code cannot be longer than the available inputs. code is of length ${code.length} but there are ${inputs.length}`, code.length <= inputs.length);
|
|
16
|
-
const chars = code.split('');
|
|
17
|
-
assert(`OTP Input for index 0 is missing!`, inputs[0]);
|
|
18
|
-
assert(`Character at index 0 is missing`, chars[0]);
|
|
19
|
-
for (let i = 0; i < chars.length; i++) {
|
|
20
|
-
const input = inputs[i];
|
|
21
|
-
const char = chars[i];
|
|
22
|
-
assert(`Input at index ${i} is missing`, input);
|
|
23
|
-
assert(`Character at index ${i} is missing`, char);
|
|
24
|
-
input.value = char;
|
|
25
|
-
}
|
|
26
|
-
await fillIn(inputs[0], chars[0]);
|
|
27
|
-
|
|
28
|
-
// Account for out-of-settled-system delay due to RAF debounce.
|
|
29
|
-
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
30
|
-
await settled();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { fillOTP };
|
|
34
|
-
//# sourceMappingURL=otp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otp.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|