ember-primitives 0.13.0 → 0.15.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/utils.d.ts +1 -1
- package/declarations/components/-private/utils.d.ts.map +1 -1
- package/declarations/components/menu.d.ts +67 -0
- package/declarations/components/menu.d.ts.map +1 -0
- package/declarations/components/popover.d.ts +5 -3
- package/declarations/components/popover.d.ts.map +1 -1
- package/declarations/components/toggle-group.d.ts +88 -6
- package/declarations/components/toggle-group.d.ts.map +1 -1
- package/declarations/components/toggle.d.ts +1 -1
- package/declarations/components/toggle.d.ts.map +1 -1
- package/declarations/floating-ui/component.d.ts +46 -0
- package/declarations/floating-ui/component.d.ts.map +1 -0
- package/declarations/floating-ui/middleware.d.ts +3 -0
- package/declarations/floating-ui/middleware.d.ts.map +1 -0
- package/declarations/floating-ui/modifier.d.ts +22 -0
- package/declarations/floating-ui/modifier.d.ts.map +1 -0
- package/declarations/floating-ui.d.ts +3 -0
- package/declarations/floating-ui.d.ts.map +1 -0
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/services/ember-primitives/setup.d.ts +3 -3
- package/declarations/services/ember-primitives/setup.d.ts.map +1 -1
- package/dist/_app_/components/menu.js +1 -0
- package/dist/components/-private/utils.js +3 -1
- package/dist/components/-private/utils.js.map +1 -1
- package/dist/components/menu.js +123 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/popover.js +5 -3
- package/dist/components/popover.js.map +1 -1
- package/dist/components/toggle-group.js +67 -12
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.js +1 -0
- package/dist/components/toggle.js.map +1 -1
- package/dist/floating-ui/component.js +42 -0
- package/dist/floating-ui/component.js.map +1 -0
- package/dist/floating-ui/middleware.js +14 -0
- package/dist/floating-ui/middleware.js.map +1 -0
- package/dist/floating-ui/modifier.js +57 -0
- package/dist/floating-ui/modifier.js.map +1 -0
- package/dist/floating-ui.js +3 -0
- package/dist/floating-ui.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/services/ember-primitives/setup.js +2 -1
- package/dist/services/ember-primitives/setup.js.map +1 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-scheme.d.ts","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;oBACa,MAAM;;QAOpB;;WAEG;
|
|
1
|
+
{"version":3,"file":"color-scheme.d.ts","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;oBACa,MAAM;;QAOpB;;WAEG;2BACgB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI;;;QAKhD;;WAEG;2BACgB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI;;IAKlD;;OAEG;;CAgBJ,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,IAAI,SAiCnB;AAED;;GAEG;AACH,eAAO,MAAM,OAAO;;;mBAGH,MAAM;;CAEtB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,eAAe;;;oBAGV,MAAM;;CAEvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,WAAW,UAInD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;AAkBpD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,WAAW,QAItD"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* If the user provides an onChange or similar function, use that,
|
|
3
3
|
* otherwise fallback to the uncontrolled toggle
|
|
4
4
|
*/
|
|
5
|
-
export declare function toggleWithFallback(uncontrolledToggle: (...args: unknown[]) => void, controlledToggle?: (...args:
|
|
5
|
+
export declare function toggleWithFallback(uncontrolledToggle: (...args: unknown[]) => void, controlledToggle?: (...args: any[]) => void, ...args: unknown[]): void;
|
|
6
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/-private/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/-private/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,EAEhD,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAC3C,GAAG,IAAI,EAAE,OAAO,EAAE,QAOnB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { cell } from 'ember-resources';
|
|
3
|
+
import { type Signature as PopoverSignature } from "./popover";
|
|
4
|
+
import type { TOC } from '@ember/component/template-only';
|
|
5
|
+
import type { WithBoundArgs } from '@glint/template';
|
|
6
|
+
type Cell<V> = ReturnType<typeof cell<V>>;
|
|
7
|
+
export interface Signature {
|
|
8
|
+
Args: PopoverSignature['Args'];
|
|
9
|
+
Blocks: {
|
|
10
|
+
default: [
|
|
11
|
+
{
|
|
12
|
+
arrow: PopoverSignature['Blocks']['default'][0]['arrow'];
|
|
13
|
+
Trigger: WithBoundArgs<typeof Trigger, 'triggerElement' | 'contentId' | 'isOpen' | 'hook'>;
|
|
14
|
+
Content: WithBoundArgs<typeof Content, 'triggerElement' | 'contentId' | 'isOpen' | 'PopoverContent'>;
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
declare const Separator: TOC<{
|
|
21
|
+
Element: HTMLDivElement;
|
|
22
|
+
Args: {};
|
|
23
|
+
Blocks: {
|
|
24
|
+
default: [];
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
declare const Item: TOC<{
|
|
28
|
+
Element: HTMLButtonElement;
|
|
29
|
+
Args: {
|
|
30
|
+
onSelect?: (event: Event) => void;
|
|
31
|
+
};
|
|
32
|
+
Blocks: {
|
|
33
|
+
default: [];
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
declare const Content: TOC<{
|
|
37
|
+
Element: HTMLDivElement;
|
|
38
|
+
Args: {
|
|
39
|
+
triggerElement: Cell<HTMLElement>;
|
|
40
|
+
contentId: string;
|
|
41
|
+
isOpen: Cell<boolean>;
|
|
42
|
+
PopoverContent: PopoverSignature['Blocks']['default'][0]['Content'];
|
|
43
|
+
};
|
|
44
|
+
Blocks: {
|
|
45
|
+
default: [{
|
|
46
|
+
Item: typeof Item;
|
|
47
|
+
Separator: typeof Separator;
|
|
48
|
+
}];
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
declare const Trigger: TOC<{
|
|
52
|
+
Element: HTMLButtonElement;
|
|
53
|
+
Args: {
|
|
54
|
+
triggerElement: Cell<HTMLElement>;
|
|
55
|
+
contentId: string;
|
|
56
|
+
isOpen: Cell<boolean>;
|
|
57
|
+
hook: PopoverSignature['Blocks']['default'][0]['hook'];
|
|
58
|
+
};
|
|
59
|
+
Blocks: {
|
|
60
|
+
default: [];
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
export declare class Menu extends Component<Signature> {
|
|
64
|
+
contentId: string;
|
|
65
|
+
}
|
|
66
|
+
export default Menu;
|
|
67
|
+
//# sourceMappingURL=menu.d.ts.map
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ell } from 'ember-resources';
|
|
2
|
+
import type { Signature as FloatingUiComponentSignature } from '../floating-ui/component.ts';
|
|
3
|
+
import type { Signature as HookSignature } from '../floating-ui/modifier.ts';
|
|
2
4
|
import type { TOC } from '@ember/component/template-only';
|
|
3
5
|
import type { MiddlewareData } from '@floating-ui/dom';
|
|
4
6
|
import type { ModifierLike, WithBoundArgs } from '@glint/template';
|
|
5
|
-
import type { Signature as HookSignature } from 'ember-velcro/modifiers/velcro';
|
|
6
7
|
export interface Signature {
|
|
7
8
|
Args: {
|
|
8
9
|
/**
|
|
@@ -63,9 +64,10 @@ export interface Signature {
|
|
|
63
64
|
Blocks: {
|
|
64
65
|
default: [
|
|
65
66
|
{
|
|
66
|
-
hook:
|
|
67
|
+
hook: FloatingUiComponentSignature['Blocks']['default'][0]['hook'];
|
|
68
|
+
setHook: FloatingUiComponentSignature['Blocks']['default'][0]['setHook'];
|
|
67
69
|
Content: WithBoundArgs<typeof Content, 'loop'>;
|
|
68
|
-
data:
|
|
70
|
+
data: FloatingUiComponentSignature['Blocks']['default'][0]['data'];
|
|
69
71
|
arrow: WithBoundArgs<ModifierLike<AttachArrowSignature>, 'arrowElement' | 'data'>;
|
|
70
72
|
}
|
|
71
73
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/components/popover.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAMvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/components/popover.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAMvC,OAAO,KAAK,EAAE,SAAS,IAAI,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EA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AC;AAEH,eAAe,OAAO,CAAC"}
|
|
@@ -25,7 +25,7 @@ export interface ItemSignature<Value = any> {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
export type Item<Value = any> = ComponentLike<ItemSignature<Value>>;
|
|
28
|
-
export
|
|
28
|
+
export interface SingleSignature<Value> {
|
|
29
29
|
Element: HTMLDivElement;
|
|
30
30
|
Args: {
|
|
31
31
|
/**
|
|
@@ -40,18 +40,100 @@ export declare class ToggleGroup<Value = any> extends Component<{
|
|
|
40
40
|
*
|
|
41
41
|
* When none of the toggles are selected, undefined will be passed.
|
|
42
42
|
*/
|
|
43
|
-
onChange
|
|
43
|
+
onChange?: (value: Value | undefined) => void;
|
|
44
44
|
};
|
|
45
45
|
Blocks: {
|
|
46
46
|
default: [
|
|
47
47
|
{
|
|
48
|
+
/**
|
|
49
|
+
* The Toggle Switch
|
|
50
|
+
*/
|
|
48
51
|
Item: Item;
|
|
49
52
|
}
|
|
50
53
|
];
|
|
51
54
|
};
|
|
52
|
-
}> {
|
|
53
|
-
activePressed?: Value;
|
|
54
|
-
handleToggle: (value: Value) => void;
|
|
55
|
-
isPressed: (value: Value | undefined) => boolean;
|
|
56
55
|
}
|
|
56
|
+
export interface MultiSignature<Value = any> {
|
|
57
|
+
Element: HTMLDivElement;
|
|
58
|
+
Args: {
|
|
59
|
+
/**
|
|
60
|
+
* Optionally set the initial toggle state
|
|
61
|
+
*/
|
|
62
|
+
value?: Value[] | Set<Value> | Value;
|
|
63
|
+
/**
|
|
64
|
+
* Callback for when the toggle-group's state is changed.
|
|
65
|
+
*
|
|
66
|
+
* Can be used to control the state of the component.
|
|
67
|
+
*
|
|
68
|
+
*
|
|
69
|
+
* When none of the toggles are selected, undefined will be passed.
|
|
70
|
+
*/
|
|
71
|
+
onChange?: (value: Set<Value>) => void;
|
|
72
|
+
};
|
|
73
|
+
Blocks: {
|
|
74
|
+
default: [
|
|
75
|
+
{
|
|
76
|
+
/**
|
|
77
|
+
* The Toggle Switch
|
|
78
|
+
*/
|
|
79
|
+
Item: Item;
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
interface PrivateSingleSignature<Value = any> {
|
|
85
|
+
Element: HTMLDivElement;
|
|
86
|
+
Args: {
|
|
87
|
+
type?: 'single';
|
|
88
|
+
/**
|
|
89
|
+
* Optionally set the initial toggle state
|
|
90
|
+
*/
|
|
91
|
+
value?: Value;
|
|
92
|
+
/**
|
|
93
|
+
* Callback for when the toggle-group's state is changed.
|
|
94
|
+
*
|
|
95
|
+
* Can be used to control the state of the component.
|
|
96
|
+
*
|
|
97
|
+
*
|
|
98
|
+
* When none of the toggles are selected, undefined will be passed.
|
|
99
|
+
*/
|
|
100
|
+
onChange?: (value: Value | undefined) => void;
|
|
101
|
+
};
|
|
102
|
+
Blocks: {
|
|
103
|
+
default: [
|
|
104
|
+
{
|
|
105
|
+
Item: Item;
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
interface PrivateMultiSignature<Value = any> {
|
|
111
|
+
Element: HTMLDivElement;
|
|
112
|
+
Args: {
|
|
113
|
+
type: 'multi';
|
|
114
|
+
/**
|
|
115
|
+
* Optionally set the initial toggle state
|
|
116
|
+
*/
|
|
117
|
+
value?: Value[] | Set<Value> | Value;
|
|
118
|
+
/**
|
|
119
|
+
* Callback for when the toggle-group's state is changed.
|
|
120
|
+
*
|
|
121
|
+
* Can be used to control the state of the component.
|
|
122
|
+
*
|
|
123
|
+
*
|
|
124
|
+
* When none of the toggles are selected, undefined will be passed.
|
|
125
|
+
*/
|
|
126
|
+
onChange?: (value: Set<Value>) => void;
|
|
127
|
+
};
|
|
128
|
+
Blocks: {
|
|
129
|
+
default: [
|
|
130
|
+
{
|
|
131
|
+
Item: Item;
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export declare class ToggleGroup<Value = any> extends Component<PrivateSingleSignature<Value> | PrivateMultiSignature<Value>> {
|
|
137
|
+
}
|
|
138
|
+
export {};
|
|
57
139
|
//# sourceMappingURL=toggle-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.d.ts","sourceRoot":"","sources":["../../src/components/toggle-group.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"toggle-group.d.ts","sourceRoot":"","sources":["../../src/components/toggle-group.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAc3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAYrD,MAAM,WAAW,aAAa,CAAC,KAAK,GAAG,GAAG;IACxC;;OAEG;IACH,OAAO,EAAE,iBAAiB,CAAC;IAC3B,IAAI,EAAE;QACJ;;;;WAIG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE;YACP;;;;eAIG;YACH,OAAO,EAAE,OAAO;SACjB,CAAC;KACH,CAAC;CACH;AAED,MAAM,MAAM,IAAI,CAAC,KAAK,GAAG,GAAG,IAAI,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,eAAe,CAAC,KAAK;IACpC,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE;QACJ;;WAEG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC;QACd;;;;;;;WAOG;QACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAC;KAC/C,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE;YACP;gBACE;;mBAEG;gBACH,IAAI,EAAE,IAAI,CAAC;aACZ;SACF,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,cAAc,CAAC,KAAK,GAAG,GAAG;IACzC,OAAO,EAAE,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AQ,SAAS,CACrD,sBAAsB,CAAC,KAAK,CAAC,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAC7D;CA0BA"}
|
|
@@ -19,7 +19,7 @@ export interface Signature<Value = any> {
|
|
|
19
19
|
* This can be useful when using the same function for the `@onChange`
|
|
20
20
|
* handler with multiple `<Toggle>` components.
|
|
21
21
|
*/
|
|
22
|
-
onChange?: (value
|
|
22
|
+
onChange?: (value: Value | undefined, pressed: boolean) => void;
|
|
23
23
|
/**
|
|
24
24
|
* When used in a group of Toggles, this option will be helpful to
|
|
25
25
|
* know which toggle was pressed if you're using the same @onChange
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/components/toggle.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/components/toggle.ts"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAG1D,MAAM,WAAW,SAAS,CAAC,KAAK,GAAG,GAAG;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,IAAI,EAAE;QACJ;;;;WAIG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;;;;;;;;;WAUG;QACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;QAEhE;;;;WAIG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC;QAEd;;WAEG;QACH,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,KAAK,OAAO,CAAC;KACpD,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE;YACP;;;;eAIG;YACH,OAAO,EAAE,OAAO;SACjB,CAAC;KACH,CAAC;CACH;AAaD,eAAO,MAAM,MAAM,EAAE,GAAG,CAAC,SAAS,CAmBhC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import VelcroModifier from './modifier.ts';
|
|
3
|
+
import type { Signature as ModifierSignature } from './modifier.ts';
|
|
4
|
+
import type { MiddlewareState } from '@floating-ui/dom';
|
|
5
|
+
import type { WithBoundArgs, WithBoundPositionals } from '@glint/template';
|
|
6
|
+
import type { ModifierLike } from '@glint/template';
|
|
7
|
+
type ModifierArgs = ModifierSignature['Args']['Named'];
|
|
8
|
+
export interface Signature {
|
|
9
|
+
Args: {
|
|
10
|
+
middleware?: ModifierArgs['middleware'];
|
|
11
|
+
placement?: ModifierArgs['placement'];
|
|
12
|
+
strategy?: ModifierArgs['strategy'];
|
|
13
|
+
flipOptions?: ModifierArgs['flipOptions'];
|
|
14
|
+
hideOptions?: ModifierArgs['hideOptions'];
|
|
15
|
+
shiftOptions?: ModifierArgs['shiftOptions'];
|
|
16
|
+
offsetOptions?: ModifierArgs['offsetOptions'];
|
|
17
|
+
};
|
|
18
|
+
Blocks: {
|
|
19
|
+
default: [
|
|
20
|
+
velcro: {
|
|
21
|
+
hook: ModifierLike<HookSignature>;
|
|
22
|
+
setHook: (element: HTMLElement | SVGElement) => void;
|
|
23
|
+
loop?: WithBoundArgs<WithBoundPositionals<typeof VelcroModifier, 1>, keyof ModifierArgs>;
|
|
24
|
+
data?: MiddlewareState;
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface HookSignature {
|
|
30
|
+
Element: HTMLElement | SVGElement;
|
|
31
|
+
}
|
|
32
|
+
export default class Velcro extends Component<Signature> {
|
|
33
|
+
hook?: HTMLElement | SVGElement;
|
|
34
|
+
velcroData?: MiddlewareState;
|
|
35
|
+
setVelcroData: ModifierArgs['setVelcroData'];
|
|
36
|
+
setHook: (element: HTMLElement | SVGElement) => void;
|
|
37
|
+
velcroHook: import("ember-modifier").FunctionBasedModifier<{
|
|
38
|
+
Element: HTMLElement | SVGElement;
|
|
39
|
+
Args: {
|
|
40
|
+
Named: import("ember-modifier/-private/signature.js").EmptyObject;
|
|
41
|
+
Positional: [];
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/floating-ui/component.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAM3C,OAAO,cAAc,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,KAAK,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE;QACJ,UAAU,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;QACxC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;QACtC,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;QACpC,WAAW,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;QAC1C,WAAW,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;QAC1C,YAAY,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;QAC5C,aAAa,CAAC,EAAE,YAAY,CAAC,eAAe,CAAC,CAAC;KAC/C,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;gBAClC,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,KAAK,IAAI,CAAC;gBACrD,IAAI,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,OAAO,cAAc,EAAE,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC,CAAC;gBACzF,IAAI,CAAC,EAAE,eAAe,CAAC;aACxB;SACF,CAAC;KACH,CAAC;CACH;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,WAAW,GAAG,UAAU,CAAC;CACnC;AAED,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,SAAS,CAAC,SAAS,CAAC;IAC7C,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAAa;IAG5C,UAAU,CAAC,EAAE,eAAe,CAAa;IAElD,aAAa,EAAE,YAAY,CAAC,eAAe,CAAC,CAAsC;IAElF,OAAO,YAAa,WAAW,GAAG,UAAU,UAE1C;IAEF,UAAU;;;;;;OAEP;CAyBJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/floating-ui/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wBAAgB,UAAU,IAAI,UAAU,CAUvC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Modifier from 'ember-modifier';
|
|
2
|
+
import type { FlipOptions, HideOptions, Middleware, OffsetOptions, Placement, ShiftOptions, Strategy } from '@floating-ui/dom';
|
|
3
|
+
export interface Signature {
|
|
4
|
+
Element: HTMLElement;
|
|
5
|
+
Args: {
|
|
6
|
+
Positional: [referenceElement: string | HTMLElement | SVGElement];
|
|
7
|
+
Named: {
|
|
8
|
+
strategy?: Strategy;
|
|
9
|
+
offsetOptions?: OffsetOptions;
|
|
10
|
+
placement?: Placement;
|
|
11
|
+
flipOptions?: FlipOptions;
|
|
12
|
+
shiftOptions?: ShiftOptions;
|
|
13
|
+
hideOptions?: HideOptions;
|
|
14
|
+
middleware?: Middleware[];
|
|
15
|
+
setVelcroData?: Middleware['fn'];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export default class VelcroModifier extends Modifier<Signature> {
|
|
20
|
+
modify(floatingElement: Signature['Element'], [_referenceElement]: Signature['Args']['Positional'], { strategy, offsetOptions, placement, flipOptions, shiftOptions, middleware, setVelcroData, }: Signature['Args']['Named']): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=modifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifier.d.ts","sourceRoot":"","sources":["../../src/floating-ui/modifier.ts"],"names":[],"mappings":"AAIA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAItC,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACZ,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE;QACJ,UAAU,EAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC,CAAC;QAClE,KAAK,EAAE;YACL,QAAQ,CAAC,EAAE,QAAQ,CAAC;YACpB,aAAa,CAAC,EAAE,aAAa,CAAC;YAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;YACtB,WAAW,CAAC,EAAE,WAAW,CAAC;YAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;YAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;YAC1B,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;YAC1B,aAAa,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;SAClC,CAAC;KACH,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,QAAQ,CAAC,SAAS,CAAC;IAC7D,MAAM,CACJ,eAAe,EAAE,SAAS,CAAC,SAAS,CAAC,EACrC,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,EACpD,EACE,QAAkB,EAClB,aAAiB,EACjB,SAAoB,EACpB,WAAW,EACX,YAAY,EACZ,UAAe,EACf,aAAa,GACd,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;CA+DhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating-ui.d.ts","sourceRoot":"","sources":["../src/floating-ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
package/declarations/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { ExternalLink } from "./components/external-link";
|
|
|
6
6
|
export { Form } from "./components/form";
|
|
7
7
|
export { StickyFooter } from "./components/layout/sticky-footer/index";
|
|
8
8
|
export { Link } from "./components/link";
|
|
9
|
+
export { Menu } from "./components/menu";
|
|
9
10
|
export { OTP, OTPInput } from "./components/one-time-password/index";
|
|
10
11
|
export { Popover } from "./components/popover";
|
|
11
12
|
export { Portal } from "./components/portal";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,YAAY,EACV,iCAAiC,EACjC,gCAAgC,EAChC,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OA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EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -18,10 +18,10 @@ export default class EmberPrimitivesSetup extends Service {
|
|
|
18
18
|
*
|
|
19
19
|
* Defaults to `true`,
|
|
20
20
|
*
|
|
21
|
-
* Will fallback to an existing tabster instance automatically if `
|
|
21
|
+
* Will fallback to an existing tabster instance automatically if `getTabster` returns a value.
|
|
22
22
|
*/
|
|
23
|
-
tabster?: boolean
|
|
24
|
-
setTabsterRoot?: boolean
|
|
23
|
+
tabster?: boolean;
|
|
24
|
+
setTabsterRoot?: boolean;
|
|
25
25
|
}) => void;
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/services/ember-primitives/setup.ts"],"names":[],"mappings":";;AACA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAIrC;;GAEG;AACH,eAAO,MAAM,UAAU,eAAyC,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,OAAO;;IACvD;;OAEG;IACH,KAAK;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/services/ember-primitives/setup.ts"],"names":[],"mappings":";;AACA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAIrC;;GAEG;AACH,eAAO,MAAM,UAAU,eAAyC,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,OAAO;;IACvD;;OAEG;IACH,KAAK,kCAGF;QACD;;;;;;;;;;WAUG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,UAeC;CAMH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "ember-primitives/components/menu";
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* If the user provides an onChange or similar function, use that,
|
|
3
3
|
* otherwise fallback to the uncontrolled toggle
|
|
4
4
|
*/
|
|
5
|
-
function toggleWithFallback(uncontrolledToggle,
|
|
5
|
+
function toggleWithFallback(uncontrolledToggle,
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
controlledToggle, ...args) {
|
|
6
8
|
if (controlledToggle) {
|
|
7
9
|
return controlledToggle(...args);
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/components/-private/utils.ts"],"sourcesContent":["/**\n * If the user provides an onChange or similar function, use that,\n * otherwise fallback to the uncontrolled toggle\n */\nexport function toggleWithFallback(\n uncontrolledToggle: (...args: unknown[]) => void,\n controlledToggle?: (...args:
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/components/-private/utils.ts"],"sourcesContent":["/**\n * If the user provides an onChange or similar function, use that,\n * otherwise fallback to the uncontrolled toggle\n */\nexport function toggleWithFallback(\n uncontrolledToggle: (...args: unknown[]) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n controlledToggle?: (...args: any[]) => void,\n ...args: unknown[]\n) {\n if (controlledToggle) {\n return controlledToggle(...args);\n }\n\n uncontrolledToggle(...args);\n}\n"],"names":["toggleWithFallback","uncontrolledToggle","controlledToggle","args"],"mappings":"AAAA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,kBAAgD;AAChD;AACAC,gBAA2C,EAC3C,GAAGC,IAAe,EAClB;AACA,EAAA,IAAID,gBAAgB,EAAE;AACpB,IAAA,OAAOA,gBAAgB,CAAC,GAAGC,IAAI,CAAC,CAAA;AAClC,GAAA;EAEAF,kBAAkB,CAAC,GAAGE,IAAI,CAAC,CAAA;AAC7B;;;;"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { guidFor } from '@ember/object/internals';
|
|
3
|
+
import { modifier } from 'ember-modifier';
|
|
4
|
+
import { cell } from 'ember-resources';
|
|
5
|
+
import { getTabsterAttribute, Types, getTabster } from 'tabster';
|
|
6
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
|
+
import { setComponentTemplate } from '@ember/component';
|
|
8
|
+
import templateOnly from '@ember/component/template-only';
|
|
9
|
+
import { on } from '@ember/modifier';
|
|
10
|
+
import { hash } from '@ember/helper';
|
|
11
|
+
import { Popover } from './popover.js';
|
|
12
|
+
|
|
13
|
+
const TABSTER_CONFIG_CONTENT = getTabsterAttribute({
|
|
14
|
+
mover: {
|
|
15
|
+
direction: Types.MoverDirections.Both,
|
|
16
|
+
cyclic: true
|
|
17
|
+
},
|
|
18
|
+
deloser: {}
|
|
19
|
+
}, true);
|
|
20
|
+
const TABSTER_CONFIG_TRIGGER = getTabsterAttribute({
|
|
21
|
+
deloser: {}
|
|
22
|
+
}, true);
|
|
23
|
+
const Separator = setComponentTemplate(precompileTemplate("\n <div role=\"separator\" ...attributes>\n {{yield}}\n </div>\n", {
|
|
24
|
+
strictMode: true
|
|
25
|
+
}), templateOnly());
|
|
26
|
+
/**
|
|
27
|
+
* We focus items on `pointerMove` to achieve the following:
|
|
28
|
+
*
|
|
29
|
+
* - Mouse over an item (it focuses)
|
|
30
|
+
* - Leave mouse where it is and use keyboard to focus a different item
|
|
31
|
+
* - Wiggle mouse without it leaving previously focused item
|
|
32
|
+
* - Previously focused item should re-focus
|
|
33
|
+
*
|
|
34
|
+
* If we used `mouseOver`/`mouseEnter` it would not re-focus when the mouse
|
|
35
|
+
* wiggles. This is to match native menu implementation.
|
|
36
|
+
*/
|
|
37
|
+
function focusOnHover(e1) {
|
|
38
|
+
const item1 = e1.currentTarget;
|
|
39
|
+
if (item1 instanceof HTMLElement) {
|
|
40
|
+
item1?.focus();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const Item = setComponentTemplate(precompileTemplate("\n <button type=\"button\" role=\"menuitem\" {{!-- @glint-ignore !--}} {{(if @onSelect (modifier on \"click\" @onSelect))}} {{on \"pointermove\" focusOnHover}} ...attributes>\n {{yield}}\n </button>\n", {
|
|
44
|
+
scope: () => ({
|
|
45
|
+
on,
|
|
46
|
+
focusOnHover
|
|
47
|
+
}),
|
|
48
|
+
strictMode: true
|
|
49
|
+
}), templateOnly());
|
|
50
|
+
const installContent = modifier((element1, _1, {
|
|
51
|
+
isOpen: isOpen1,
|
|
52
|
+
triggerElement: triggerElement1
|
|
53
|
+
}) => {
|
|
54
|
+
// focus first focusable element on the content
|
|
55
|
+
const tabster1 = getTabster(window);
|
|
56
|
+
const firstFocusable1 = tabster1?.focusable.findFirst({
|
|
57
|
+
container: element1
|
|
58
|
+
});
|
|
59
|
+
firstFocusable1?.focus();
|
|
60
|
+
// listen for "outside" clicks
|
|
61
|
+
function onDocumentClick1(e1) {
|
|
62
|
+
if (isOpen1.current && e1.target && !element1.contains(e1.target) && !triggerElement1.current?.contains(e1.target)) {
|
|
63
|
+
isOpen1.current = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// listen for the escape key
|
|
67
|
+
function onDocumentKeydown1(e1) {
|
|
68
|
+
if (isOpen1.current && e1.key === 'Escape') {
|
|
69
|
+
isOpen1.current = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
document.addEventListener('click', onDocumentClick1);
|
|
73
|
+
document.addEventListener('keydown', onDocumentKeydown1);
|
|
74
|
+
return () => {
|
|
75
|
+
document.removeEventListener('click', onDocumentClick1);
|
|
76
|
+
document.removeEventListener('keydown', onDocumentKeydown1);
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
const Content = setComponentTemplate(precompileTemplate("\n {{#if @isOpen.current}}\n <@PopoverContent id={{@contentId}} role=\"menu\" data-tabster={{TABSTER_CONFIG_CONTENT}} tabindex=\"0\" {{installContent isOpen=@isOpen triggerElement=@triggerElement}} {{on \"click\" @isOpen.toggle}} ...attributes>\n {{yield (hash Item=Item Separator=Separator)}}\n </@PopoverContent>\n {{/if}}\n", {
|
|
80
|
+
scope: () => ({
|
|
81
|
+
TABSTER_CONFIG_CONTENT,
|
|
82
|
+
installContent,
|
|
83
|
+
on,
|
|
84
|
+
hash,
|
|
85
|
+
Item,
|
|
86
|
+
Separator
|
|
87
|
+
}),
|
|
88
|
+
strictMode: true
|
|
89
|
+
}), templateOnly());
|
|
90
|
+
const installTrigger = modifier((element1, _1, {
|
|
91
|
+
triggerElement: triggerElement1
|
|
92
|
+
}) => {
|
|
93
|
+
triggerElement1.current = element1;
|
|
94
|
+
});
|
|
95
|
+
const Trigger = setComponentTemplate(precompileTemplate("\n <button data-tabster={{TABSTER_CONFIG_TRIGGER}} type=\"button\" aria-controls={{if @isOpen.current @contentId}} aria-haspopup=\"menu\" aria-expanded={{if @isOpen.current \"true\" \"false\"}} {{@hook}} {{installTrigger triggerElement=@triggerElement}} {{on \"click\" @isOpen.toggle}} ...attributes>\n {{yield}}\n </button>\n", {
|
|
96
|
+
scope: () => ({
|
|
97
|
+
TABSTER_CONFIG_TRIGGER,
|
|
98
|
+
installTrigger,
|
|
99
|
+
on
|
|
100
|
+
}),
|
|
101
|
+
strictMode: true
|
|
102
|
+
}), templateOnly());
|
|
103
|
+
const IsOpen = () => cell(false);
|
|
104
|
+
const TriggerElement = () => cell();
|
|
105
|
+
class Menu extends Component {
|
|
106
|
+
contentId = guidFor(this);
|
|
107
|
+
static {
|
|
108
|
+
setComponentTemplate(precompileTemplate("\n {{#let (IsOpen) (TriggerElement) as |isOpen triggerEl|}}\n <Popover @flipOptions={{@flipOptions}} @middleware={{@middleware}} @offsetOptions={{@offsetOptions}} @placement={{@placement}} @shiftOptions={{@shiftOptions}} @strategy={{@strategy}} @inline={{@inline}} as |p|>\n {{yield (hash Trigger=(component Trigger hook=p.hook isOpen=isOpen triggerElement=triggerEl contentId=this.contentId) Content=(component Content PopoverContent=p.Content isOpen=isOpen triggerElement=triggerEl contentId=this.contentId) arrow=p.arrow isOpen=isOpen.current)}}\n </Popover>\n {{/let}}\n ", {
|
|
109
|
+
scope: () => ({
|
|
110
|
+
IsOpen,
|
|
111
|
+
TriggerElement,
|
|
112
|
+
Popover,
|
|
113
|
+
hash,
|
|
114
|
+
Trigger,
|
|
115
|
+
Content
|
|
116
|
+
}),
|
|
117
|
+
strictMode: true
|
|
118
|
+
}), this);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { Menu, Menu as default };
|
|
123
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sources":["../../src/components/menu.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\nimport { cell } from 'ember-resources';\nimport { getTabster, getTabsterAttribute, Types } from 'tabster';\nimport { Popover, type Signature as PopoverSignature } from './popover.gts';\nimport type { TOC } from '@ember/component/template-only';\nimport type { WithBoundArgs } from '@glint/template';\ntype Cell<V> = ReturnType<typeof cell>;\nconst TABSTER_CONFIG_CONTENT = getTabsterAttribute({\n mover: {\n direction: Types.MoverDirections.Both,\n cyclic: true\n },\n deloser: {}\n}, true);\nconst TABSTER_CONFIG_TRIGGER = getTabsterAttribute({\n deloser: {}\n}, true);\nexport interface Signature {\n Args: PopoverSignature['Args'];\n Blocks: {\n default: [{\n arrow: PopoverSignature['Blocks']['default'][0]['arrow'];\n Trigger: WithBoundArgs<typeof Trigger, 'triggerElement' | 'contentId' | 'isOpen' | 'hook'>;\n Content: WithBoundArgs<typeof Content, 'triggerElement' | 'contentId' | 'isOpen' | 'PopoverContent'>;\n isOpen: boolean;\n }];\n };\n}\nconst Separator: TOC<{\n Element: HTMLDivElement;\n Args: {\n };\n Blocks: {\n default: [];\n };\n}> = template(`\n <div role=\"separator\" ...attributes>\n {{yield}}\n </div>\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\n/**\n * We focus items on `pointerMove` to achieve the following:\n *\n * - Mouse over an item (it focuses)\n * - Leave mouse where it is and use keyboard to focus a different item\n * - Wiggle mouse without it leaving previously focused item\n * - Previously focused item should re-focus\n *\n * If we used `mouseOver`/`mouseEnter` it would not re-focus when the mouse\n * wiggles. This is to match native menu implementation.\n */ function focusOnHover(e1: PointerEvent) {\n const item1 = e1.currentTarget;\n if (item1 instanceof HTMLElement) {\n item1?.focus();\n }\n}\nconst Item: TOC<{\n Element: HTMLButtonElement;\n Args: {\n onSelect?: (event: Event) => void;\n };\n Blocks: {\n default: [];\n };\n}> = template(`\n <button\n type=\"button\"\n role=\"menuitem\"\n {{! @glint-ignore !}}\n {{(if @onSelect (modifier on \"click\" @onSelect))}}\n {{on \"pointermove\" focusOnHover}}\n ...attributes\n >\n {{yield}}\n </button>\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\nconst installContent = modifier<{\n Element: HTMLElement;\n Args: {\n Named: {\n isOpen: Cell<boolean>;\n triggerElement: Cell<HTMLElement>;\n };\n };\n}>((element1, _1: [], { isOpen: isOpen1, triggerElement: triggerElement1 })=>{\n // focus first focusable element on the content\n const tabster1 = getTabster(window);\n const firstFocusable1 = tabster1?.focusable.findFirst({\n container: element1\n });\n firstFocusable1?.focus();\n // listen for \"outside\" clicks\n function onDocumentClick1(e1: MouseEvent) {\n if (isOpen1.current && e1.target && !element1.contains(e1.target as HTMLElement) && !triggerElement1.current?.contains(e1.target as HTMLElement)) {\n isOpen1.current = false;\n }\n }\n // listen for the escape key\n function onDocumentKeydown1(e1: KeyboardEvent) {\n if (isOpen1.current && e1.key === 'Escape') {\n isOpen1.current = false;\n }\n }\n document.addEventListener('click', onDocumentClick1);\n document.addEventListener('keydown', onDocumentKeydown1);\n return ()=>{\n document.removeEventListener('click', onDocumentClick1);\n document.removeEventListener('keydown', onDocumentKeydown1);\n };\n});\nconst Content: TOC<{\n Element: HTMLDivElement;\n Args: {\n triggerElement: Cell<HTMLElement>;\n contentId: string;\n isOpen: Cell<boolean>;\n PopoverContent: PopoverSignature['Blocks']['default'][0]['Content'];\n };\n Blocks: {\n default: [{\n Item: typeof Item;\n Separator: typeof Separator;\n }];\n };\n}> = template(`\n {{#if @isOpen.current}}\n <@PopoverContent\n id={{@contentId}}\n role=\"menu\"\n data-tabster={{TABSTER_CONFIG_CONTENT}}\n tabindex=\"0\"\n {{installContent isOpen=@isOpen triggerElement=@triggerElement}}\n {{on \"click\" @isOpen.toggle}}\n ...attributes\n >\n {{yield (hash Item=Item Separator=Separator)}}\n </@PopoverContent>\n {{/if}}\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\nconst installTrigger = modifier<{\n Element: HTMLElement;\n Args: {\n Named: {\n triggerElement: Cell<HTMLElement>;\n };\n };\n}>((element1, _1: [], { triggerElement: triggerElement1 })=>{\n triggerElement1.current = element1;\n});\nconst Trigger: TOC<{\n Element: HTMLButtonElement;\n Args: {\n triggerElement: Cell<HTMLElement>;\n contentId: string;\n isOpen: Cell<boolean>;\n hook: PopoverSignature['Blocks']['default'][0]['hook'];\n };\n Blocks: {\n default: [];\n };\n}> = template(`\n <button\n data-tabster={{TABSTER_CONFIG_TRIGGER}}\n type=\"button\"\n aria-controls={{if @isOpen.current @contentId}}\n aria-haspopup=\"menu\"\n aria-expanded={{if @isOpen.current \"true\" \"false\"}}\n {{@hook}}\n {{installTrigger triggerElement=@triggerElement}}\n {{on \"click\" @isOpen.toggle}}\n ...attributes\n >\n {{yield}}\n </button>\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\nconst IsOpen = ()=>cell<boolean>(false);\nconst TriggerElement = ()=>cell<HTMLElement>();\nexport class Menu extends Component<Signature> {\n contentId = guidFor(this);\n static{\n template(`\n {{#let (IsOpen) (TriggerElement) as |isOpen triggerEl|}}\n <Popover\n @flipOptions={{@flipOptions}}\n @middleware={{@middleware}}\n @offsetOptions={{@offsetOptions}}\n @placement={{@placement}}\n @shiftOptions={{@shiftOptions}}\n @strategy={{@strategy}}\n @inline={{@inline}}\n as |p|\n >\n {{yield\n (hash\n Trigger=(component\n Trigger hook=p.hook isOpen=isOpen triggerElement=triggerEl contentId=this.contentId\n )\n Content=(component\n Content\n PopoverContent=p.Content\n isOpen=isOpen\n triggerElement=triggerEl\n contentId=this.contentId\n )\n arrow=p.arrow\n isOpen=isOpen.current\n )\n }}\n </Popover>\n {{/let}}\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\nexport default Menu;\n"],"names":["TABSTER_CONFIG_CONTENT","getTabsterAttribute","mover","direction","Types","MoverDirections","Both","cyclic","deloser","TABSTER_CONFIG_TRIGGER","Separator","setComponentTemplate","precompileTemplate","strictMode","templateOnly","focusOnHover","e1","item1","currentTarget","HTMLElement","focus","Item","scope","on","installContent","modifier","element1","_1","isOpen","isOpen1","triggerElement","triggerElement1","tabster1","getTabster","window","firstFocusable1","focusable","findFirst","container","onDocumentClick1","current","target","contains","onDocumentKeydown1","key","document","addEventListener","removeEventListener","Content","hash","installTrigger","Trigger","IsOpen","cell","TriggerElement","Menu","Component","contentId","guidFor","Popover"],"mappings":";;;;;;;;;;;;AAYA,MAAMA,sBAAsB,GAAGC,mBAAmB,CAAC;AAC/CC,EAAAA,KAAK,EAAE;AACHC,IAAAA,SAAS,EAAEC,KAAK,CAACC,eAAe,CAACC,IAAI;AACrCC,IAAAA,MAAM,EAAE,IAAA;GACX;AACDC,EAAAA,OAAO,EAAE,EAAC;AACd,CAAC,EAAE,IAAI,CAAC,CAAA;AACR,MAAMC,sBAAsB,GAAGR,mBAAmB,CAAC;AAC/CO,EAAAA,OAAO,EAAE,EAAC;AACd,CAAC,EAAE,IAAI,CAAC,CAAA;AAYR,MAAME,SAOJ,GAAAC,oBAAA,CAAGC,kBAAA,CAIF,uEAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAIH,CAAC,CAAC,EAAAC,YAAA,EAAA,CAAA,CAAA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAI,SAASC,YAAYA,CAACC,EAAgB,EAAE;AACxC,EAAA,MAAMC,KAAK,GAAGD,EAAE,CAACE,aAAa,CAAA;EAC9B,IAAID,KAAK,YAAYE,WAAW,EAAE;IAC9BF,KAAK,EAAEG,KAAK,EAAE,CAAA;AAClB,GAAA;AACJ,CAAA;AACA,MAAMC,IAQJ,GAAAV,oBAAA,CAAGC,kBAAA,CAWF,+MAAA,EAAA;AAAAU,EAAAA,KAAA,EAAAA,OAAA;IAAAC,EAAA;AAAAR,IAAAA,YAAAA;AAAA,GAAA,CAAA;EAAAF,UAAA,EAAA,IAAA;AAIH,CAAC,CAAC,EAAAC,YAAA,EAAA,CAAA,CAAA;AACF,MAAMU,cAAc,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IAAI,CAAA,CAAA;AAKvB,GAAA;AACJ;;;;"}
|
|
@@ -7,7 +7,9 @@ import { TARGETS } from './portal-targets.js';
|
|
|
7
7
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
8
|
import { setComponentTemplate } from '@ember/component';
|
|
9
9
|
import templateOnly from '@ember/component/template-only';
|
|
10
|
-
import
|
|
10
|
+
import Velcro from '../floating-ui/component.js';
|
|
11
|
+
import '@ember/debug';
|
|
12
|
+
import '@ember/destroyable';
|
|
11
13
|
import { hash } from '@ember/helper';
|
|
12
14
|
|
|
13
15
|
function getElementTag(tagName1) {
|
|
@@ -80,10 +82,10 @@ function flipOptions(options1) {
|
|
|
80
82
|
...options1
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
|
-
const Popover = setComponentTemplate(precompileTemplate("\n {{#let (ArrowElement) as |arrowElement|}}\n <
|
|
85
|
+
const Popover = setComponentTemplate(precompileTemplate("\n {{#let (ArrowElement) as |arrowElement|}}\n <FloatingUI @placement={{@placement}} @strategy={{@strategy}} @middleware={{maybeAddArrow @middleware arrowElement.current}} @flipOptions={{flipOptions @flipOptions}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} as |fui|>\n {{yield (hash hook=fui.hook setHook=fui.setHook Content=(component Content loop=fui.loop inline=@inline) data=fui.data arrow=(modifier attachArrow arrowElement=arrowElement data=fui.data))}}\n </FloatingUI>\n {{/let}}\n", {
|
|
84
86
|
scope: () => ({
|
|
85
87
|
ArrowElement,
|
|
86
|
-
Velcro,
|
|
88
|
+
FloatingUI: Velcro,
|
|
87
89
|
maybeAddArrow,
|
|
88
90
|
flipOptions,
|
|
89
91
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../src/components/popover.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport { hash } from '@ember/helper';\nimport { arrow } from '@floating-ui/dom';\nimport { element } from 'ember-element-helper';\nimport { modifier } from 'ember-modifier';\nimport { cell } from 'ember-resources';\nimport { Velcro } from 'ember-velcro';\nimport { Portal } from './portal.gts';\nimport { TARGETS } from './portal-targets.gts';\nimport type { TOC } from '@ember/component/template-only';\nimport type { Middleware, MiddlewareData } from '@floating-ui/dom';\nimport type { ModifierLike, WithBoundArgs } from '@glint/template';\nimport type { Signature as HookSignature } from 'ember-velcro/modifiers/velcro';\nexport interface Signature {\n Args: {\n /**\n * See the Floating UI's [flip docs](https://floating-ui.com/docs/flip) for possible values.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ flipOptions?: HookSignature['Args']['Named']['flipOptions'];\n /**\n * Array of one or more objects to add to Floating UI's list of [middleware](https://floating-ui.com/docs/middleware)\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ middleware?: HookSignature['Args']['Named']['middleware'];\n /**\n * See the Floating UI's [offset docs](https://floating-ui.com/docs/offset) for possible values.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ offsetOptions?: HookSignature['Args']['Named']['offsetOptions'];\n /**\n * One of the possible [`placements`](https://floating-ui.com/docs/computeposition#placement). The default is 'bottom'.\n *\n * Possible values are\n * - top\n * - bottom\n * - right\n * - left\n *\n * And may optionally have `-start` or `-end` added to adjust position along the side.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ placement?: `${'top' | 'bottom' | 'left' | 'right'}${'' | '-start' | '-end'}`;\n /**\n * See the Floating UI's [shift docs](https://floating-ui.com/docs/shift) for possible values.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ shiftOptions?: HookSignature['Args']['Named']['shiftOptions'];\n /**\n * CSS position property, either `fixed` or `absolute`.\n *\n * Pros and cons of each strategy are explained on [Floating UI's Docs](https://floating-ui.com/docs/computePosition#strategy)\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ strategy?: HookSignature['Args']['Named']['strategy'];\n /**\n * By default, the popover is portaled.\n * If you don't control your CSS, and the positioning of the popover content\n * is misbehaving, you may pass \"@inline={{true}}\" to opt out of portalling.\n *\n * Inline may also be useful in nested menus, where you know exactly how the nesting occurs\n */ inline?: boolean;\n };\n Blocks: {\n default: [{\n hook: ModifierLike<HookSignature>;\n Content: WithBoundArgs<typeof Content, 'loop'>;\n data: MiddlewareData;\n arrow: WithBoundArgs<ModifierLike<AttachArrowSignature>, 'arrowElement' | 'data'>;\n }];\n };\n}\nfunction getElementTag(tagName1: undefined | string) {\n return tagName1 || 'div';\n}\n/**\n * Allows lazy evaluation of the portal target (do nothing until rendered)\n * This is useful because the algorithm for finding the portal target isn't cheap.\n */ const Content: TOC<{\n Element: HTMLDivElement;\n Args: {\n loop: ModifierLike<{\n Element: HTMLElement;\n }>;\n inline?: boolean;\n /**\n * By default the popover content is wrapped in a div.\n * You may change this by supplying the name of an element here.\n *\n * For example:\n * ```gjs\n * <Popover as |p|>\n * <p.Content @as=\"dialog\">\n * this is now focus trapped\n * </p.Content>\n * </Popover>\n * ```\n */ as?: string;\n };\n Blocks: {\n default: [];\n };\n}> = template(`\n {{#let (element (getElementTag @as)) as |El|}}\n {{#if @inline}}\n {{! @glint-ignore\n https://github.com/tildeio/ember-element-helper/issues/91\n https://github.com/typed-ember/glint/issues/610\n }}\n <El {{@loop}} ...attributes>\n {{yield}}\n </El>\n {{else}}\n <Portal @to={{TARGETS.popover}}>\n {{! @glint-ignore\n https://github.com/tildeio/ember-element-helper/issues/91\n https://github.com/typed-ember/glint/issues/610\n }}\n <El {{@loop}} ...attributes>\n {{yield}}\n </El>\n </Portal>\n {{/if}}\n {{/let}}\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\ninterface AttachArrowSignature {\n Element: HTMLElement;\n Args: {\n Named: {\n arrowElement: ReturnType<typeof ArrowElement>;\n data?: {\n middlewareData?: MiddlewareData;\n placement?: Placement;\n };\n };\n };\n}\nconst arrowSides = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right'\n};\ntype Direction = 'top' | 'bottom' | 'left' | 'right';\ntype Placement = `${Direction}${'' | '-start' | '-end'}`;\nconst attachArrow = modifier<AttachArrowSignature>((element1, _1: [], named1)=>{\n if (element1 === named1.arrowElement.current) {\n if (!named1.data) return;\n if (!named1.data.middlewareData) return;\n let { arrow: arrow1 } = named1.data.middlewareData;\n let { placement: placement1 } = named1.data;\n if (!arrow1) return;\n if (!placement1) return;\n let { x: arrowX1, y: arrowY1 } = arrow1;\n let otherSide1 = (placement1 as Placement).split('-')[0] as Direction;\n let staticSide1 = arrowSides[otherSide1];\n Object.assign(named1.arrowElement.current.style, {\n left: arrowX1 != null ? `${arrowX1}px` : '',\n top: arrowY1 != null ? `${arrowY1}px` : '',\n right: '',\n bottom: '',\n [staticSide1]: '-4px'\n });\n return;\n }\n (async ()=>{\n await Promise.resolve();\n named1.arrowElement.set(element1);\n })();\n});\nconst ArrowElement: () => ReturnType<typeof cell> = ()=>cell<HTMLElement>();\nfunction maybeAddArrow(middleware1: Middleware[] | undefined, element1: Element | undefined) {\n let result1 = [\n ...(middleware1 || [])\n ];\n if (element1) {\n result1.push(arrow({\n element: element1\n }));\n }\n return result1;\n}\nfunction flipOptions(options1: HookSignature['Args']['Named']['flipOptions']) {\n return {\n elementContext: 'reference',\n ...options1\n };\n}\nexport const Popover: TOC<Signature> = template(`\n {{#let (ArrowElement) as |arrowElement|}}\n <Velcro\n @placement={{@placement}}\n @strategy={{@strategy}}\n @middleware={{maybeAddArrow @middleware arrowElement.current}}\n @flipOptions={{flipOptions @flipOptions}}\n @shiftOptions={{@shiftOptions}}\n @offsetOptions={{@offsetOptions}}\n as |velcro|\n >\n {{yield\n (hash\n hook=velcro.hook\n Content=(component Content loop=velcro.loop inline=@inline)\n data=velcro.data\n arrow=(modifier attachArrow arrowElement=arrowElement data=velcro.data)\n )\n }}\n </Velcro>\n {{/let}}\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\nexport default Popover;\n"],"names":["getElementTag","tagName1","Content","setComponentTemplate","precompileTemplate","scope","element","Portal","TARGETS","strictMode","templateOnly","arrowSides","top","right","bottom","left","attachArrow","modifier","element1","_1","named1","arrowElement","current","data","middlewareData","arrow","arrow1","placement","placement1","x","arrowX1","y","arrowY1","otherSide1","split","staticSide1","Object","assign","style","Promise","resolve","set","ArrowElement","cell","maybeAddArrow","middleware1","result1","push","flipOptions","options1","elementContext","Popover","Velcro","hash"],"mappings":";;;;;;;;;;;;AAwEA,SAASA,aAAaA,CAACC,QAA4B,EAAE;EACjD,OAAOA,QAAQ,IAAI,KAAK,CAAA;AAC5B,CAAA;AACA;AACA;AACA;AACA;AAAI,MAAMC,OAwBR,GAAAC,oBAAA,CAAGC,kBAAA,CAsBF,upBAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,OAAA;IAAAN,aAAA;IAAAO,MAAA;AAAAC,IAAAA,OAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAIH,CAAC,CAAC,EAAAC,YAAA,EAAA,CAAA,CAAA;AAaF,MAAMC,UAAU,GAAG;AACfC,EAAAA,GAAG,EAAE,QAAQ;AACbC,EAAAA,KAAK,EAAE,MAAM;AACbC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,IAAI,EAAE,OAAA;AACV,CAAC,CAAA;AAGD,MAAMC,WAAW,GAAGC,QAAQ,CAAuB,CAACC,QAAQ,EAAEC,EAAM,EAAEC,MAAM,KAAG;AAC3E,EAAA,IAAIF,QAAQ,KAAKE,MAAM,CAACC,YAAY,CAACC,OAAO,EAAE;AAC1C,IAAA,IAAI,CAACF,MAAM,CAACG,IAAI,EAAE,OAAA;AAClB,IAAA,IAAI,CAACH,MAAM,CAACG,IAAI,CAACC,cAAc,EAAE,OAAA;IACjC,IAAI;AAAEC,MAAAA,KAAK,EAAEC,MAAAA;AAAO,KAAC,GAAGN,MAAM,CAACG,IAAI,CAACC,cAAc,CAAA;IAClD,IAAI;AAAEG,MAAAA,SAAS,EAAEC,UAAAA;KAAY,GAAGR,MAA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,KAAK,CAAC;AACfnB,MAAAA,OAAO,EAAEY,QAAAA;AACb,KAAC,CAAC,CAAC,CAAA;AACP,GAAA;AACA,EAAA,OAAO4B,OAAO,CAAA;AAClB,CAAA;AACA,SAASE,WAAWA,CAACC,QAAuD,EAAE;EAC1E,OAAO;AACHC,IAAAA,cAAc,EAAE,WAAW;IAC3B,GAAGD,QAAAA;GACN,CAAA;AACL,CAAA;MACaE,OAAuB,GAAAhD,oBAAA,CAAGC,kBAAA,CAqBpC,igBAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAqC,YAAA;IAAAU,MAAA;IAAAR,aAAA;IAAAI,WAAA;IAAAK,IAAA;IAAAnD,OAAA;AAAAc,IAAAA,WAAAA;AAAA,GAAA,CAAA;EAAAP,UAAA,EAAA,IAAA;AAIH,CAAC,CAAC,EAAAC,YAAA,EAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../src/components/popover.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport { hash } from '@ember/helper';\nimport { arrow } from '@floating-ui/dom';\nimport { element } from 'ember-element-helper';\nimport { modifier } from 'ember-modifier';\nimport { cell } from 'ember-resources';\nimport { FloatingUI } from '../floating-ui.ts';\nimport { Portal } from './portal.gts';\nimport { TARGETS } from './portal-targets.gts';\nimport type { Signature as FloatingUiComponentSignature } from '../floating-ui/component.ts';\nimport type { Signature as HookSignature } from '../floating-ui/modifier.ts';\nimport type { TOC } from '@ember/component/template-only';\nimport type { ElementContext, Middleware, MiddlewareData } from '@floating-ui/dom';\nimport type { ModifierLike, WithBoundArgs } from '@glint/template';\nexport interface Signature {\n Args: {\n /**\n * See the Floating UI's [flip docs](https://floating-ui.com/docs/flip) for possible values.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ flipOptions?: HookSignature['Args']['Named']['flipOptions'];\n /**\n * Array of one or more objects to add to Floating UI's list of [middleware](https://floating-ui.com/docs/middleware)\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ middleware?: HookSignature['Args']['Named']['middleware'];\n /**\n * See the Floating UI's [offset docs](https://floating-ui.com/docs/offset) for possible values.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ offsetOptions?: HookSignature['Args']['Named']['offsetOptions'];\n /**\n * One of the possible [`placements`](https://floating-ui.com/docs/computeposition#placement). The default is 'bottom'.\n *\n * Possible values are\n * - top\n * - bottom\n * - right\n * - left\n *\n * And may optionally have `-start` or `-end` added to adjust position along the side.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ placement?: `${'top' | 'bottom' | 'left' | 'right'}${'' | '-start' | '-end'}`;\n /**\n * See the Floating UI's [shift docs](https://floating-ui.com/docs/shift) for possible values.\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ shiftOptions?: HookSignature['Args']['Named']['shiftOptions'];\n /**\n * CSS position property, either `fixed` or `absolute`.\n *\n * Pros and cons of each strategy are explained on [Floating UI's Docs](https://floating-ui.com/docs/computePosition#strategy)\n *\n * This argument is forwarded to `ember-velcro`'s `<Velcro>` component.\n */ strategy?: HookSignature['Args']['Named']['strategy'];\n /**\n * By default, the popover is portaled.\n * If you don't control your CSS, and the positioning of the popover content\n * is misbehaving, you may pass \"@inline={{true}}\" to opt out of portalling.\n *\n * Inline may also be useful in nested menus, where you know exactly how the nesting occurs\n */ inline?: boolean;\n };\n Blocks: {\n default: [{\n hook: FloatingUiComponentSignature['Blocks']['default'][0]['hook'];\n setHook: FloatingUiComponentSignature['Blocks']['default'][0]['setHook'];\n Content: WithBoundArgs<typeof Content, 'loop'>;\n data: FloatingUiComponentSignature['Blocks']['default'][0]['data'];\n arrow: WithBoundArgs<ModifierLike<AttachArrowSignature>, 'arrowElement' | 'data'>;\n }];\n };\n}\nfunction getElementTag(tagName1: undefined | string) {\n return tagName1 || 'div';\n}\n/**\n * Allows lazy evaluation of the portal target (do nothing until rendered)\n * This is useful because the algorithm for finding the portal target isn't cheap.\n */ const Content: TOC<{\n Element: HTMLDivElement;\n Args: {\n loop: ModifierLike<{\n Element: HTMLElement;\n }>;\n inline?: boolean;\n /**\n * By default the popover content is wrapped in a div.\n * You may change this by supplying the name of an element here.\n *\n * For example:\n * ```gjs\n * <Popover as |p|>\n * <p.Content @as=\"dialog\">\n * this is now focus trapped\n * </p.Content>\n * </Popover>\n * ```\n */ as?: string;\n };\n Blocks: {\n default: [];\n };\n}> = template(`\n {{#let (element (getElementTag @as)) as |El|}}\n {{#if @inline}}\n {{! @glint-ignore\n https://github.com/tildeio/ember-element-helper/issues/91\n https://github.com/typed-ember/glint/issues/610\n }}\n <El {{@loop}} ...attributes>\n {{yield}}\n </El>\n {{else}}\n <Portal @to={{TARGETS.popover}}>\n {{! @glint-ignore\n https://github.com/tildeio/ember-element-helper/issues/91\n https://github.com/typed-ember/glint/issues/610\n }}\n <El {{@loop}} ...attributes>\n {{yield}}\n </El>\n </Portal>\n {{/if}}\n {{/let}}\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\ninterface AttachArrowSignature {\n Element: HTMLElement;\n Args: {\n Named: {\n arrowElement: ReturnType<typeof ArrowElement>;\n data?: {\n middlewareData?: MiddlewareData;\n placement?: Placement;\n };\n };\n };\n}\nconst arrowSides = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right'\n};\ntype Direction = 'top' | 'bottom' | 'left' | 'right';\ntype Placement = `${Direction}${'' | '-start' | '-end'}`;\nconst attachArrow = modifier<AttachArrowSignature>((element1, _1: [], named1)=>{\n if (element1 === named1.arrowElement.current) {\n if (!named1.data) return;\n if (!named1.data.middlewareData) return;\n let { arrow: arrow1 } = named1.data.middlewareData;\n let { placement: placement1 } = named1.data;\n if (!arrow1) return;\n if (!placement1) return;\n let { x: arrowX1, y: arrowY1 } = arrow1;\n let otherSide1 = (placement1 as Placement).split('-')[0] as Direction;\n let staticSide1 = arrowSides[otherSide1];\n Object.assign(named1.arrowElement.current.style, {\n left: arrowX1 != null ? `${arrowX1}px` : '',\n top: arrowY1 != null ? `${arrowY1}px` : '',\n right: '',\n bottom: '',\n [staticSide1]: '-4px'\n });\n return;\n }\n (async ()=>{\n await Promise.resolve();\n named1.arrowElement.set(element1);\n })();\n});\nconst ArrowElement: () => ReturnType<typeof cell> = ()=>cell<HTMLElement>();\nfunction maybeAddArrow(middleware1: Middleware[] | undefined, element1: Element | undefined) {\n let result1 = [\n ...(middleware1 || [])\n ];\n if (element1) {\n result1.push(arrow({\n element: element1\n }));\n }\n return result1;\n}\nfunction flipOptions(options1: HookSignature['Args']['Named']['flipOptions']) {\n return {\n elementContext: 'reference' as ElementContext,\n ...options1\n };\n}\nexport const Popover: TOC<Signature> = template(`\n {{#let (ArrowElement) as |arrowElement|}}\n <FloatingUI\n @placement={{@placement}}\n @strategy={{@strategy}}\n @middleware={{maybeAddArrow @middleware arrowElement.current}}\n @flipOptions={{flipOptions @flipOptions}}\n @shiftOptions={{@shiftOptions}}\n @offsetOptions={{@offsetOptions}}\n as |fui|\n >\n {{yield\n (hash\n hook=fui.hook\n setHook=fui.setHook\n Content=(component Content loop=fui.loop inline=@inline)\n data=fui.data\n arrow=(modifier attachArrow arrowElement=arrowElement data=fui.data)\n )\n }}\n </FloatingUI>\n {{/let}}\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\nexport default Popover;\n"],"names":["getElementTag","tagName1","Content","setComponentTemplate","precompileTemplate","scope","element","Portal","TARGETS","strictMode","templateOnly","arrowSides","top","right","bottom","left","attachArrow","modifier","element1","_1","named1","arrowElement","current","data","middlewareData","arrow","arrow1","placement","placement1","x","arrowX1","y","arrowY1","otherSide1","split","staticSide1","Object","assign","style","Promise","resolve","set","ArrowElement","cell","maybeAddArrow","middleware1","result1","push","flipOptions","options1","elementContext","Popover","FloatingUI","hash"],"mappings":";;;;;;;;;;;;;;AA0EA,SAASA,aAAaA,CAACC,QAA4B,EAAE;EACjD,OAAOA,QAAQ,IAAI,KAAK,CAAA;AAC5B,CAAA;A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,EAAAA,OAAA;IAAAqC,YAAA;gBAAAU,MAAA;IAAAR,aAAA;IAAAI,WAAA;IAAAK,IAAA;IAAAnD,OAAA;AAAAc,IAAAA,WAAAA;AAAA,GAAA,CAAA;EAAAP,UAAA,EAAA,IAAA;AAIH,CAAC,CAAC,EAAAC,YAAA,EAAA;;;;"}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
-
import {
|
|
2
|
+
import { cached } from '@glimmer/tracking';
|
|
3
|
+
import { getTabsterAttribute, Types } from 'tabster';
|
|
4
|
+
import { TrackedSet } from 'tracked-built-ins';
|
|
3
5
|
import { localCopy } from 'tracked-toolbox';
|
|
4
|
-
import { g, i } from 'decorator-transforms/runtime';
|
|
5
|
-
import { hash } from '@ember/helper';
|
|
6
|
-
import { Toggle } from './toggle.js';
|
|
7
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
|
+
import { g, i, n } from 'decorator-transforms/runtime';
|
|
9
|
+
import { hash } from '@ember/helper';
|
|
10
|
+
import { Toggle } from './toggle.js';
|
|
9
11
|
|
|
10
|
-
const TABSTER_CONFIG =
|
|
12
|
+
const TABSTER_CONFIG = getTabsterAttribute({
|
|
11
13
|
mover: {
|
|
12
14
|
direction: Types.MoverDirections.Both,
|
|
13
15
|
cyclic: true
|
|
14
16
|
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
}, true);
|
|
18
|
+
function isMulti(x1) {
|
|
19
|
+
return x1 === 'multi';
|
|
20
|
+
}
|
|
21
21
|
class ToggleGroup extends Component {
|
|
22
|
+
// See: https://github.com/typed-ember/glint/issues/715
|
|
23
|
+
static {
|
|
24
|
+
setComponentTemplate(precompileTemplate("\n {{#if (isMulti this.args.type)}}\n <MultiToggleGroup @value={{this.args.value}} @onChange={{this.args.onChange}} ...attributes as |x|>\n {{yield x}}\n </MultiToggleGroup>\n {{else}}\n <SingleToggleGroup @value={{this.args.value}} @onChange={{this.args.onChange}} ...attributes as |x|>\n {{yield x}}\n </SingleToggleGroup>\n {{/if}}\n ", {
|
|
25
|
+
scope: () => ({
|
|
26
|
+
isMulti,
|
|
27
|
+
MultiToggleGroup,
|
|
28
|
+
SingleToggleGroup
|
|
29
|
+
}),
|
|
30
|
+
strictMode: true
|
|
31
|
+
}), this);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
let SingleToggleGroup = class SingleToggleGroup extends Component {
|
|
22
35
|
static {
|
|
23
36
|
g(this.prototype, "activePressed", [localCopy('args.value')]);
|
|
24
37
|
}
|
|
@@ -42,7 +55,49 @@ class ToggleGroup extends Component {
|
|
|
42
55
|
strictMode: true
|
|
43
56
|
}), this);
|
|
44
57
|
}
|
|
45
|
-
}
|
|
58
|
+
};
|
|
59
|
+
let MultiToggleGroup = class MultiToggleGroup extends Component {
|
|
60
|
+
/**
|
|
61
|
+
* Normalizes @value to a Set
|
|
62
|
+
* and makes sure that even if the input Set is reactive,
|
|
63
|
+
* we don't mistakenly dirty it.
|
|
64
|
+
*/
|
|
65
|
+
get activePressed() {
|
|
66
|
+
let value1 = this.args.value;
|
|
67
|
+
if (!value1) {
|
|
68
|
+
return new TrackedSet();
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(value1)) {
|
|
71
|
+
return new TrackedSet(value1);
|
|
72
|
+
}
|
|
73
|
+
if (value1 instanceof Set) {
|
|
74
|
+
return new TrackedSet(value1);
|
|
75
|
+
}
|
|
76
|
+
return new TrackedSet([value1]);
|
|
77
|
+
}
|
|
78
|
+
static {
|
|
79
|
+
n(this.prototype, "activePressed", [cached]);
|
|
80
|
+
}
|
|
81
|
+
handleToggle = value1 => {
|
|
82
|
+
if (this.activePressed.has(value1)) {
|
|
83
|
+
this.activePressed.delete(value1);
|
|
84
|
+
} else {
|
|
85
|
+
this.activePressed.add(value1);
|
|
86
|
+
}
|
|
87
|
+
this.args.onChange?.(new Set(this.activePressed.values()));
|
|
88
|
+
};
|
|
89
|
+
isPressed = value1 => this.activePressed.has(value1);
|
|
90
|
+
static {
|
|
91
|
+
setComponentTemplate(precompileTemplate("\n <div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n </div>\n ", {
|
|
92
|
+
scope: () => ({
|
|
93
|
+
TABSTER_CONFIG,
|
|
94
|
+
hash,
|
|
95
|
+
Toggle
|
|
96
|
+
}),
|
|
97
|
+
strictMode: true
|
|
98
|
+
}), this);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
46
101
|
|
|
47
102
|
export { ToggleGroup };
|
|
48
103
|
//# sourceMappingURL=toggle-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.js","sources":["../../src/components/toggle-group.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { Types } from 'tabster';\n// The consumer will need to provide types for tracked-toolbox.\n// Or.. better yet, we PR to trakcked-toolbox to provide them\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { localCopy } from 'tracked-toolbox';\nimport { Toggle } from './toggle.gts';\nimport type { ComponentLike } from '@glint/template';\nconst TABSTER_CONFIG = JSON.stringify({\n mover: {\n direction: Types.MoverDirections.Both,\n cyclic: true\n }\n});\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ItemSignature<Value = any> {\n /**\n * The button element will have aria-pressed=\"true\" on it when the button is in the pressed state.\n */ Element: HTMLButtonElement;\n Args: {\n /**\n * When used in a group of Toggles, this option will be helpful to\n * know which toggle was pressed if you're using the same @onChange\n * handler for multiple toggles.\n */ value?: Value;\n };\n Blocks: {\n default: [/**\n * the current pressed state of the toggle button\n *\n * Useful when using the toggle button as an uncontrolled component\n */ pressed: boolean];\n };\n}\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Item<Value = any> = ComponentLike<ItemSignature<Value>>;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ToggleGroup<Value = any> extends Component<{\n Element: HTMLDivElement;\n Args: {\n /**\n * Optionally set the initial toggle state\n */ value?: Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */ onChange: (value: Value | undefined) => void;\n };\n Blocks: {\n default: [{\n Item: Item;\n }];\n };\n}> {\n @localCopy('args.value')\n activePressed?: Value;\n handleToggle = (value1: Value)=>{\n if (this.activePressed === value1) {\n this.activePressed = undefined;\n return;\n }\n this.activePressed = value1;\n this.args.onChange?.(this.activePressed);\n };\n isPressed = (value1: Value | undefined)=>value1 === this.activePressed;\n static{\n template(`\n <div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n </div>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["TABSTER_CONFIG","JSON","stringify","mover","direction","Types","MoverDirections","Both","cyclic","ToggleGroup","Component","g","this","prototype","localCopy","i","void 0","handleToggle","value1","activePressed","undefined","args","onChange","isPressed","setComponentTemplate","precompileTemplate","scope","hash","Toggle","strictMode"],"mappings":";;;;;;;;;AAWA,MAAMA,cAAc,GAAGC,IAAI,CAACC,SAAS,CAAC;AAClCC,EAAAA,KAAK,EAAE;AACHC,IAAAA,SAAS,EAAEC,KAAK,CAACC,eAAe,CAACC,IAAI;AACrCC,IAAAA,MAAM,EAAE,IAAA;AACZ,GAAA;AACJ,CAAC,CAAC,CAAA;AACF;;AAoBA;;AAEA;AACO,MAAMC,WAAW,SAAsBC,SAAS,CAoBpD;AAAA,EAAA;IAAAC,CAAA,CAAAC,IAAA,CAAAC,SAAA,oBACEC,SAAS,CAAC,YAAY,CAAC,CAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAAA,cAAA,IAAAC,CAAA,CAAAH,IAAA,oBAAAI,KAAA,CAAA,EAAA;EAExBC,YAAY,GAAIC,MAAa,IAAG;AAC5B,IAAA,IAAI,IAAI,CAACC,aAAa,KAAKD,MAAM,EAAE;MAC/B,IAAI,CAACC,aAAa,GAAGC,SAAS,CAAA;AAC9B,MAAA,OAAA;AACJ,KAAA;IACA,IAAI,CAACD,aAAa,GAAGD,MAAM,CAAA;IAC3B,IAAI,CAACG,IAAI,CAACC,QAAQ,GAAG,IAAI,CAACH,aAAa,CAAC,CAAA;GAC3C,CAAA;AACDI,EAAAA,SAAS,GAAIL,MAAyB,IAAGA,MAAM,KAAK,IAAI,CAACC,aAAa,CAAA;AACtE,EAAA;IACIK,oBAAA,CAAAC,kBAAA,CAIH,+KAAA,EAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAA1B,cAAA;QAAA2B,IAAA;AAAAC,QAAAA,MAAAA;AAAA,OAAA,CAAA;MAAAC,UAAA,EAAA,IAAA;KAKI,CAAC,EAJa,IAAI,CAAA,CAAA;AAKvB,GAAA;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"toggle-group.js","sources":["../../src/components/toggle-group.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { hash } from '@ember/helper';\nimport { getTabsterAttribute, Types } from 'tabster';\nimport { TrackedSet } from 'tracked-built-ins';\n// The consumer will need to provide types for tracked-toolbox.\n// Or.. better yet, we PR to trakcked-toolbox to provide them\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { localCopy } from 'tracked-toolbox';\nimport { Toggle } from './toggle.gts';\nimport type { ComponentLike } from '@glint/template';\nconst TABSTER_CONFIG = getTabsterAttribute({\n mover: {\n direction: Types.MoverDirections.Both,\n cyclic: true\n }\n}, true);\nexport interface ItemSignature<Value = any> {\n /**\n * The button element will have aria-pressed=\"true\" on it when the button is in the pressed state.\n */ Element: HTMLButtonElement;\n Args: {\n /**\n * When used in a group of Toggles, this option will be helpful to\n * know which toggle was pressed if you're using the same @onChange\n * handler for multiple toggles.\n */ value?: Value;\n };\n Blocks: {\n default: [/**\n * the current pressed state of the toggle button\n *\n * Useful when using the toggle button as an uncontrolled component\n */ pressed: boolean];\n };\n}\nexport type Item<Value = any> = ComponentLike<ItemSignature<Value>>;\nexport interface SingleSignature<Value> {\n Element: HTMLDivElement;\n Args: {\n /**\n * Optionally set the initial toggle state\n */ value?: Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */ onChange?: (value: Value | undefined) => void;\n };\n Blocks: {\n default: [{\n /**\n * The Toggle Switch\n */ Item: Item;\n }];\n };\n}\nexport interface MultiSignature<Value = any> {\n Element: HTMLDivElement;\n Args: {\n /**\n * Optionally set the initial toggle state\n */ value?: Value[] | Set<Value> | Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */ onChange?: (value: Set<Value>) => void;\n };\n Blocks: {\n default: [{\n /**\n * The Toggle Switch\n */ Item: Item;\n }];\n };\n}\ninterface PrivateSingleSignature<Value = any> {\n Element: HTMLDivElement;\n Args: {\n type?: 'single';\n /**\n * Optionally set the initial toggle state\n */ value?: Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */ onChange?: (value: Value | undefined) => void;\n };\n Blocks: {\n default: [{\n Item: Item;\n }];\n };\n}\ninterface PrivateMultiSignature<Value = any> {\n Element: HTMLDivElement;\n Args: {\n type: 'multi';\n /**\n * Optionally set the initial toggle state\n */ value?: Value[] | Set<Value> | Value;\n /**\n * Callback for when the toggle-group's state is changed.\n *\n * Can be used to control the state of the component.\n *\n *\n * When none of the toggles are selected, undefined will be passed.\n */ onChange?: (value: Set<Value>) => void;\n };\n Blocks: {\n default: [{\n Item: Item;\n }];\n };\n}\nfunction isMulti(x1: 'single' | 'multi' | undefined): x is 'multi' {\n return x1 === 'multi';\n}\nexport class ToggleGroup<Value = any> extends Component<PrivateSingleSignature<Value> | PrivateMultiSignature<Value>> {\n // See: https://github.com/typed-ember/glint/issues/715\n static{\n template(`\n {{#if (isMulti this.args.type)}}\n <MultiToggleGroup\n @value={{this.args.value}}\n @onChange={{this.args.onChange}}\n ...attributes\n as |x|\n >\n {{yield x}}\n </MultiToggleGroup>\n {{else}}\n <SingleToggleGroup\n @value={{this.args.value}}\n @onChange={{this.args.onChange}}\n ...attributes\n as |x|\n >\n {{yield x}}\n </SingleToggleGroup>\n {{/if}}\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\nlet SingleToggleGroup = class SingleToggleGroup<Value = any> extends Component<SingleSignature<Value>> {\n @localCopy('args.value')\n activePressed?: Value;\n handleToggle = (value1: Value)=>{\n if (this.activePressed === value1) {\n this.activePressed = undefined;\n return;\n }\n this.activePressed = value1;\n this.args.onChange?.(this.activePressed);\n };\n isPressed = (value1: Value | undefined)=>value1 === this.activePressed;\n static{\n template(`\n <div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n </div>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n};\nlet MultiToggleGroup = class MultiToggleGroup<Value = any> extends Component<MultiSignature<Value>> {\n /**\n * Normalizes @value to a Set\n * and makes sure that even if the input Set is reactive,\n * we don't mistakenly dirty it.\n */ @cached\n get activePressed(): TrackedSet<Value> {\n let value1 = this.args.value;\n if (!value1) {\n return new TrackedSet();\n }\n if (Array.isArray(value1)) {\n return new TrackedSet(value1);\n }\n if (value1 instanceof Set) {\n return new TrackedSet(value1);\n }\n return new TrackedSet([\n value1\n ]);\n }\n handleToggle = (value1: Value)=>{\n if (this.activePressed.has(value1)) {\n this.activePressed.delete(value1);\n } else {\n this.activePressed.add(value1);\n }\n this.args.onChange?.(new Set<Value>(this.activePressed.values()));\n };\n isPressed = (value1: Value)=>this.activePressed.has(value1);\n static{\n template(`\n <div data-tabster={{TABSTER_CONFIG}} ...attributes>\n {{yield (hash Item=(component Toggle onChange=this.handleToggle isPressed=this.isPressed))}}\n </div>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n};\n"],"names":["TABSTER_CONFIG","getTabsterAttribute","mover","direction","Types","MoverDirections","Both","cyclic","isMulti","x1","ToggleGroup","Component","setComponentTemplate","precompileTemplate","scope","MultiToggleGroup","SingleToggleGroup","strictMode","g","this","prototype","localCopy","i","void 0","handleToggle","value1","activePressed","undefined","args","onChange","isPressed","hash","Toggle","value","TrackedSet","Array","isArray","Set","n","cached","has","delete","add","values"],"mappings":";;;;;;;;;;;AAaA,MAAMA,cAAc,GAAGC,mBAAmB,CAAC;AACvCC,EAAAA,KAAK,EAAE;AACHC,IAAAA,SAAS,EAAEC,KAAK,CAACC,eAAe,CAACC,IAAI;AACrCC,IAAAA,MAAM,EAAE,IAAA;AACZ,GAAA;AACJ,CAAC,EAAE,IAAI,CAAC,CAAA;AA+GR,SAASC,OAAOA,CAACC,EAAkC,EAAgB;EAC/D,OAAOA,EAAE,KAAK,OAAO,CAAA;AACzB,CAAA;AACO,MAAMC,WAAW,SAAsBC,SAAS,CAA+D;AAClH;AACA,EAAA;IACIC,oBAAA,CAAAC,kBAAA,CAoBH,+XAAA,EAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAN,OAAA;QAAAO,gBAAA;AAAAC,QAAAA,iBAAAA;AAAA,OAAA,CAAA;MAAAC,UAAA,EAAA,IAAA;KAKI,CAAC,EAJa,IAAI,CAAA,CAAA;AAKvB,GAAA;AACJ,CAAA;AACA,IAAID,iBAAiB,GAAG,MAAMA,iBAAiB,SAAsBL,SAAS,CAAyB;AAAA,EAAA;I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AAA,OAAO,IAAIH,UAAU,CAACT,MAAM,CAAC,CAAA;AACjC,KAAA;AACA,IAAA,OAAO,IAAIS,UAAU,CAAC,CAClBT,MAAM,CACT,CAAC,CAAA;AACN,GAAA;AAAC,EAAA;AAAAa,IAAAA,CAAA,CAAAnB,IAAA,CAAAC,SAAA,oBAfEmB,MAAM,CAAA,CAAA,CAAA;AAAA,GAAA;EAgBTf,YAAY,GAAIC,MAAa,IAAG;IAC5B,IAAI,IAAI,CAACC,aAAa,CAACc,GAAG,CAACf,MAAM,CAAC,EAAE;AAChC,MAAA,IAAI,CAACC,aAAa,CAACe,MAAM,CAAChB,MAAM,CAAC,CAAA;AACrC,KAAC,MAAM;AACH,MAAA,IAAI,CAACC,aAAa,CAACgB,GAAG,CAACjB,MAAM,CAAC,CAAA;AAClC,KAAA;AACA,IAAA,IAAI,CAACG,IAAI,CAACC,QAAQ,GAAG,IAAIQ,GAAG,CAAQ,IAAI,CAACX,aAAa,CAACiB,MAAM,EAAE,CAAC,CAAC,CAAA;GACpE,CAAA;EACDb,SAAS,GAAIL,MAAa,IAAG,IAAI,CAACC,aAAa,CAACc,GAAG,CAACf,MAAM,CAAC,CAAA;AAC3D,EAAA;IACIb,oBAAA,CAAAC,kBAAA,CAIH,+KAAA,EAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAd,cAAA;QAAA+B,IAAA;AAAAC,QAAAA,MAAAA;AAAA,OAAA,CAAA;MAAAf,UAAA,EAAA,IAAA;KAKI,CAAC,EAJa,IAAI,CAAA,CAAA;AAKvB,GAAA;AACJ,CAAC;;;;"}
|
|
@@ -6,6 +6,7 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
6
6
|
import { setComponentTemplate } from '@ember/component';
|
|
7
7
|
import templateOnly from '@ember/component/template-only';
|
|
8
8
|
|
|
9
|
+
// import Component from '@glimmer/component';
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
11
|
function isPressed(pressed1, value1, isPressed1) {
|
|
11
12
|
if (!value1) return Boolean(pressed1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.js","sources":["../../src/components/toggle.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport { fn } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { cell } from 'ember-resources';\nimport { toggleWithFallback } from './-private/utils.ts';\nimport type { TOC } from '@ember/component/template-only';\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface Signature<Value = any> {\n Element: HTMLButtonElement;\n Args: {\n /**\n * The pressed-state of the toggle.\n *\n * Can be used to control the state of the component.\n */ pressed?: boolean;\n /**\n * Callback for when the toggle's state is changed.\n *\n * Can be used to control the state of the component.\n *\n * if a `@value` is passed to this `<Toggle>`, that @value will\n * be passed to the `@onChange` handler.\n *\n * This can be useful when using the same function for the `@onChange`\n * handler with multiple `<Toggle>` components.\n */ onChange?: (value
|
|
1
|
+
{"version":3,"file":"toggle.js","sources":["../../src/components/toggle.gts"],"sourcesContent":["// import Component from '@glimmer/component';\nimport { template } from \"@ember/template-compiler\";\nimport { fn } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { cell } from 'ember-resources';\nimport { toggleWithFallback } from './-private/utils.ts';\nimport type { TOC } from '@ember/component/template-only';\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface Signature<Value = any> {\n Element: HTMLButtonElement;\n Args: {\n /**\n * The pressed-state of the toggle.\n *\n * Can be used to control the state of the component.\n */ pressed?: boolean;\n /**\n * Callback for when the toggle's state is changed.\n *\n * Can be used to control the state of the component.\n *\n * if a `@value` is passed to this `<Toggle>`, that @value will\n * be passed to the `@onChange` handler.\n *\n * This can be useful when using the same function for the `@onChange`\n * handler with multiple `<Toggle>` components.\n */ onChange?: (value: Value | undefined, pressed: boolean) => void;\n /**\n * When used in a group of Toggles, this option will be helpful to\n * know which toggle was pressed if you're using the same @onChange\n * handler for multiple toggles.\n */ value?: Value;\n /**\n * When controlling state in a wrapping component, this function can be used in conjunction with `@value` to determine if this `<Toggle>` should appear pressed.\n */ isPressed?: (value?: Value | undefined) => boolean;\n };\n Blocks: {\n default: [/**\n * the current pressed state of the toggle button\n *\n * Useful when using the toggle button as an uncontrolled component\n */ pressed: boolean];\n };\n}\nfunction isPressed(pressed1?: boolean, value1?: unknown, isPressed1?: (value?: unknown) => boolean): boolean {\n if (!value1) return Boolean(pressed1);\n if (!isPressed1) return Boolean(pressed1);\n return isPressed1(value1);\n}\nexport const Toggle: TOC<Signature> = template(`\n {{#let (cell (isPressed @pressed @value @isPressed)) as |pressed|}}\n <button\n type=\"button\"\n aria-pressed=\"{{pressed.current}}\"\n {{on \"click\" (fn toggleWithFallback pressed.toggle @onChange @value)}}\n ...attributes\n >\n {{yield pressed.current}}\n </button>\n {{/let}}\n`, {\n eval () {\n return eval(arguments[0]);\n }\n});\nexport default Toggle;\n"],"names":["isPressed","pressed1","value1","isPressed1","Boolean","Toggle","setComponentTemplate","precompileTemplate","scope","cell","on","fn","toggleWithFallback","strictMode","templateOnly"],"mappings":";;;;;;;;AAAA;AAOA;AAqCA,SAASA,SAASA,CAACC,QAAkB,EAAEC,MAAgB,EAAEC,UAAyC,EAAW;AACzG,EAAA,IAAI,CAACD,MAAM,EAAE,OAAOE,OAAO,CAACH,QAAQ,CAAC,CAAA;AACrC,EAAA,IAAI,CAACE,UAAU,EAAE,OAAOC,OAAO,CAACH,QAAQ,CAAC,CAAA;EACzC,OAAOE,UAAU,CAACD,MAAM,CAAC,CAAA;AAC7B,CAAA;MACaG,MAAsB,GAAAC,oBAAA,CAAGC,kBAAA,CAWnC,iSAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,IAAA;IAAAT,SAAA;IAAAU,EAAA;IAAAC,EAAA;AAAAC,IAAAA,kBAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAIH,CAAC,CAAC,EAAAC,YAAA,EAAA;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { modifier } from 'ember-modifier';
|
|
4
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
5
|
+
import VelcroModifier from './modifier.js';
|
|
6
|
+
import { hash } from '@ember/helper';
|
|
7
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
|
+
import { setComponentTemplate } from '@ember/component';
|
|
9
|
+
|
|
10
|
+
class Velcro extends Component {
|
|
11
|
+
static {
|
|
12
|
+
g(this.prototype, "hook", [tracked], function () {
|
|
13
|
+
return undefined;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
#hook = (i(this, "hook"), void 0);
|
|
17
|
+
static {
|
|
18
|
+
g(this.prototype, "velcroData", [tracked], function () {
|
|
19
|
+
return undefined;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
#velcroData = (i(this, "velcroData"), void 0); // set by VelcroModifier
|
|
23
|
+
setVelcroData = data1 => this.velcroData = data1;
|
|
24
|
+
setHook = element1 => {
|
|
25
|
+
this.hook = element1;
|
|
26
|
+
};
|
|
27
|
+
velcroHook = modifier(element1 => {
|
|
28
|
+
this.setHook(element1);
|
|
29
|
+
});
|
|
30
|
+
static {
|
|
31
|
+
setComponentTemplate(precompileTemplate("\n {{#let (modifier VelcroModifier flipOptions=@flipOptions hideOptions=@hideOptions middleware=@middleware offsetOptions=@offsetOptions placement=@placement shiftOptions=@shiftOptions strategy=@strategy setVelcroData=this.setVelcroData) as |loop|}}\n {{#let (if this.hook (modifier loop this.hook)) as |loopWithHook|}}\n {{yield (hash hook=this.velcroHook setHook=this.setHook loop=loopWithHook data=this.velcroData)}}\n {{/let}}\n {{/let}}\n ", {
|
|
32
|
+
scope: () => ({
|
|
33
|
+
VelcroModifier,
|
|
34
|
+
hash
|
|
35
|
+
}),
|
|
36
|
+
strictMode: true
|
|
37
|
+
}), this);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { Velcro as default };
|
|
42
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/floating-ui/component.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { hash } from '@ember/helper';\nimport { modifier } from 'ember-modifier';\nimport VelcroModifier from './modifier.ts';\nimport type { Signature as ModifierSignature } from './modifier.ts';\nimport type { MiddlewareState } from '@floating-ui/dom';\nimport type { WithBoundArgs, WithBoundPositionals } from '@glint/template';\nimport type { ModifierLike } from '@glint/template';\ntype ModifierArgs = ModifierSignature['Args']['Named'];\nexport interface Signature {\n Args: {\n middleware?: ModifierArgs['middleware'];\n placement?: ModifierArgs['placement'];\n strategy?: ModifierArgs['strategy'];\n flipOptions?: ModifierArgs['flipOptions'];\n hideOptions?: ModifierArgs['hideOptions'];\n shiftOptions?: ModifierArgs['shiftOptions'];\n offsetOptions?: ModifierArgs['offsetOptions'];\n };\n Blocks: {\n default: [velcro: {\n hook: ModifierLike<HookSignature>;\n setHook: (element: HTMLElement | SVGElement) => void;\n loop?: WithBoundArgs<WithBoundPositionals<typeof VelcroModifier, 1>, keyof ModifierArgs>;\n data?: MiddlewareState;\n }];\n };\n}\ninterface HookSignature {\n Element: HTMLElement | SVGElement;\n}\nexport default class Velcro extends Component<Signature> {\n @tracked\n hook?: HTMLElement | SVGElement = undefined;\n // set by VelcroModifier\n @tracked\n velcroData?: MiddlewareState = undefined;\n setVelcroData: ModifierArgs['setVelcroData'] = (data1)=>(this.velcroData = data1);\n setHook = (element1: HTMLElement | SVGElement)=>{\n this.hook = element1;\n };\n velcroHook = modifier<HookSignature>((element1: HTMLElement | SVGElement)=>{\n this.setHook(element1);\n });\n static{\n template(`\n {{#let\n (modifier\n VelcroModifier\n flipOptions=@flipOptions\n hideOptions=@hideOptions\n middleware=@middleware\n offsetOptions=@offsetOptions\n placement=@placement\n shiftOptions=@shiftOptions\n strategy=@strategy\n setVelcroData=this.setVelcroData\n )\n as |loop|\n }}\n {{#let (if this.hook (modifier loop this.hook)) as |loopWithHook|}}\n {{yield\n (hash hook=this.velcroHook setHook=this.setHook loop=loopWithHook data=this.velcroData)\n }}\n {{/let}}\n {{/let}}\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["Velcro","Component","g","this","prototype","tracked","undefined","i","void 0","setVelcroData","data1","velcroData","setHook","element1","hook","velcroHook","modifier","setComponentTemplate","precompileTemplate","scope","VelcroModifier","hash","strictMode"],"mappings":";;;;;;;;;AAiCe,MAAMA,MAAM,SAASC,SAAS,CAAY;AAAA,EAAA;AAAAC,IAAAA,CAAA,CAAAC,IAAA,CAAAC,SAAA,WACpDC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAC0BC,SAAS,CAAA;AAAA,KAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAAA,KAAA,IAAAC,CAAA,CAAAJ,IAAA,WAAAK,KAAA,CAAA,EAAA;AAAA,EAAA;AAAAN,IAAAA,CAAA,CAAAC,IAAA,CAAAC,SAAA,iBAE1CC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OACuBC,SAAS,CAAA;AAAA,KAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAAA,WAAA,IAAAC,CAAA,CAAAJ,IAAA,EAAA,YAAA,CAAA,EAAAK,MAAA,EAFxC;AAGAC,EAAAA,aAAa,GAAmCC,KAAK,IAAI,IAAI,CAACC,UAAU,GAAGD,KAAM,CAAA;EACjFE,OAAO,GAAIC,QAAkC,IAAG;IAC5C,IAAI,CAACC,IAAI,GAAGD,QAAQ,CAAA;GACvB,CAAA;AACDE,EAAAA,UAAU,GAAGC,QAAQ,CAAiBH,QAAkC,IAAG;AACvE,IAAA,IAAI,CAACD,OAAO,CAACC,QAAQ,CAAC,CAAA;AAC1B,GAAC,CAAC,CAAA;AACF,EAAA;IACII,oBAAA,CAAAC,kBAAA,CAqBH,sdAAA,EAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,cAAA;AAAAC,QAAAA,IAAAA;AAAA,OAAA,CAAA;MAAAC,UAAA,EAAA,IAAA;KAKI,CAAC,EAJa,IAAI,CAAA,CAAA;AAKvB,GAAA;AACJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sources":["../../src/floating-ui/middleware.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\n\nexport function velcroData(): Middleware {\n return {\n name: 'metadata',\n fn: (data) => {\n // https://floating-ui.com/docs/middleware#always-return-an-object\n return {\n data,\n };\n },\n };\n}\n"],"names":["velcroData","name","fn","data"],"mappings":"AAEO,SAASA,UAAUA,GAAe;EACvC,OAAO;AACLC,IAAAA,IAAI,EAAE,UAAU;IAChBC,EAAE,EAAGC,IAAI,IAAK;AACZ;MACA,OAAO;AACLA,QAAAA,IAAAA;OACD,CAAA;AACH,KAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { assert } from '@ember/debug';
|
|
2
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
3
|
+
import { autoUpdate, computePosition, offset, flip, shift, hide } from '@floating-ui/dom';
|
|
4
|
+
import Modifier from 'ember-modifier';
|
|
5
|
+
import { velcroData } from './middleware.js';
|
|
6
|
+
|
|
7
|
+
class VelcroModifier extends Modifier {
|
|
8
|
+
modify(floatingElement, [_referenceElement], {
|
|
9
|
+
strategy = 'fixed',
|
|
10
|
+
offsetOptions = 0,
|
|
11
|
+
placement = 'bottom',
|
|
12
|
+
flipOptions,
|
|
13
|
+
shiftOptions,
|
|
14
|
+
middleware = [],
|
|
15
|
+
setVelcroData
|
|
16
|
+
}) {
|
|
17
|
+
const referenceElement = typeof _referenceElement === 'string' ? document.querySelector(_referenceElement) : _referenceElement;
|
|
18
|
+
assert('no reference element defined', referenceElement instanceof HTMLElement || referenceElement instanceof SVGElement);
|
|
19
|
+
assert('no floating element defined', floatingElement instanceof HTMLElement || _referenceElement instanceof SVGElement);
|
|
20
|
+
assert('reference and floating elements cannot be the same element', floatingElement !== _referenceElement);
|
|
21
|
+
assert('@middleware must be an array of one or more objects', Array.isArray(middleware));
|
|
22
|
+
Object.assign(floatingElement.style, {
|
|
23
|
+
position: strategy,
|
|
24
|
+
top: '0',
|
|
25
|
+
left: '0'
|
|
26
|
+
});
|
|
27
|
+
let update = async () => {
|
|
28
|
+
let {
|
|
29
|
+
middlewareData,
|
|
30
|
+
x,
|
|
31
|
+
y
|
|
32
|
+
} = await computePosition(referenceElement, floatingElement, {
|
|
33
|
+
middleware: [offset(offsetOptions), flip(flipOptions), shift(shiftOptions), ...middleware, hide({
|
|
34
|
+
strategy: 'referenceHidden'
|
|
35
|
+
}), hide({
|
|
36
|
+
strategy: 'escaped'
|
|
37
|
+
}), velcroData()],
|
|
38
|
+
placement,
|
|
39
|
+
strategy
|
|
40
|
+
});
|
|
41
|
+
let referenceHidden = middlewareData.hide?.referenceHidden;
|
|
42
|
+
Object.assign(floatingElement.style, {
|
|
43
|
+
top: `${y}px`,
|
|
44
|
+
left: `${x}px`,
|
|
45
|
+
margin: 0,
|
|
46
|
+
visibility: referenceHidden ? 'hidden' : 'visible'
|
|
47
|
+
});
|
|
48
|
+
setVelcroData?.(middlewareData['metadata']);
|
|
49
|
+
};
|
|
50
|
+
update();
|
|
51
|
+
let cleanup = autoUpdate(referenceElement, floatingElement, update);
|
|
52
|
+
registerDestructor(this, cleanup);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { VelcroModifier as default };
|
|
57
|
+
//# sourceMappingURL=modifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifier.js","sources":["../../src/floating-ui/modifier.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\n\nimport { autoUpdate, computePosition, flip, hide, offset, shift } from '@floating-ui/dom';\nimport Modifier from 'ember-modifier';\n\nimport { velcroData } 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 Element: HTMLElement;\n Args: {\n Positional: [referenceElement: string | HTMLElement | SVGElement];\n Named: {\n strategy?: Strategy;\n offsetOptions?: OffsetOptions;\n placement?: Placement;\n flipOptions?: FlipOptions;\n shiftOptions?: ShiftOptions;\n hideOptions?: HideOptions;\n middleware?: Middleware[];\n setVelcroData?: Middleware['fn'];\n };\n };\n}\n\nexport default class VelcroModifier extends Modifier<Signature> {\n modify(\n floatingElement: Signature['Element'],\n [_referenceElement]: Signature['Args']['Positional'],\n {\n strategy = 'fixed',\n offsetOptions = 0,\n placement = 'bottom',\n flipOptions,\n shiftOptions,\n middleware = [],\n setVelcroData,\n }: Signature['Args']['Named']\n ) {\n const referenceElement: null | HTMLElement | SVGElement =\n typeof _referenceElement === 'string'\n ? document.querySelector(_referenceElement)\n : _referenceElement;\n\n assert(\n 'no reference element defined',\n referenceElement instanceof HTMLElement || referenceElement instanceof SVGElement\n );\n\n assert(\n 'no floating element defined',\n floatingElement instanceof HTMLElement || _referenceElement instanceof SVGElement\n );\n\n assert(\n 'reference and floating elements cannot be the same element',\n floatingElement !== _referenceElement\n );\n\n assert('@middleware must be an array of one or more objects', Array.isArray(middleware));\n\n Object.assign(floatingElement.style, {\n position: strategy,\n top: '0',\n left: '0',\n });\n\n let update = async () => {\n let { middlewareData, x, y } = await computePosition(referenceElement, floatingElement, {\n middleware: [\n offset(offsetOptions),\n flip(flipOptions),\n shift(shiftOptions),\n ...middleware,\n hide({ strategy: 'referenceHidden' }),\n hide({ strategy: 'escaped' }),\n velcroData(),\n ],\n placement,\n strategy,\n });\n\n let referenceHidden = middlewareData.hide?.referenceHidden;\n\n Object.assign(floatingElement.style, {\n top: `${y}px`,\n left: `${x}px`,\n margin: 0,\n visibility: referenceHidden ? 'hidden' : 'visible',\n });\n\n setVelcroData?.(middlewareData['metadata']);\n };\n\n update();\n\n let cleanup = autoUpdate(referenceElement, floatingElement, update);\n\n registerDestructor(this, cleanup);\n }\n}\n"],"names":["VelcroModifier","Modifier","modify","floatingElement","_referenceElement","strategy","offsetOptions","placement","flipOptions","shiftOptions","middleware","setVelcroData","referenceElement","document","querySelector","assert","HTMLElement","SVGElement","Array","isArray","Object","assign","style","position","top","left","update","middlewareData","x","y","computePosition","offset","flip","shift","hide","velcroData","referenceHidden","margin","visibility","cleanup","autoUpdate","registerDestructor"],"mappings":";;;;;;AAmCe,MAAMA,cAAc,SAASC,QAAQ,CAAY;AAC9DC,EAAAA,MAAMA,CACJC,eAAqC,EACrC,CAACC,iBAAiB,CAAkC,EACpD;AACEC,IAAAA,QAAQ,GAAG,OAAO;AAClBC,IAAAA,aAAa,GAAG,CAAC;AACjBC,IAAAA,SAAS,GAAG,QAAQ;IACpBC,WAAW;IACXC,YAAY;AACZC,IAAAA,UAAU,GAAG,EAAE;AACfC,IAAAA,aAAAA;AAC0B,GAAC,EAC7B;AACA,IAAA,MAAMC,gBAAiD,GACrD,OAAOR,iBAAiB,KAAK,QAAQ,GACjCS,QAAQ,CAACC,aAAa,CAACV,iBAAiB,CAAC,GACzCA,iBAAiB,CAAA;IAEvBW,MAAM,CACJ,8BAA8B,EAC9BH,gBAAgB,YAAYI,WAAW,IAAIJ,gBAAgB,YAAYK,UACzE,CAAC,CAAA;IAEDF,MAAM,CACJ,6BAA6B,EAC7BZ,eAAe,YAAYa,WAAW,IAAIZ,iBAAiB,YAAYa,UACzE,CAAC,CAAA;AAEDF,IAAAA,MAAM,CACJ,4DAA4D,EAC5DZ,eAAe,KAAKC,iBACtB,CAAC,CAAA;IAEDW,MAAM,CAAC,qDAAqD,EAAEG,KAAK,CAACC,OAAO,CAACT,UAAU,CAAC,CAAC,CAAA;AAExFU,IAAAA,MAAM,CAACC,M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B,MAAM,CAAC,CAAA;AAEnEe,IAAAA,kBAAkB,CAAC,IAAI,EAAEF,OAAO,CAAC,CAAA;AACnC,GAAA;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating-ui.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { ExternalLink } from './components/external-link.js';
|
|
|
6
6
|
export { Form } from './components/form.js';
|
|
7
7
|
export { StickyFooter } from './components/layout/sticky-footer/index.js';
|
|
8
8
|
export { Link } from './components/link.js';
|
|
9
|
+
export { Menu } from './components/menu.js';
|
|
9
10
|
export { OTPInput } from './components/one-time-password/input.js';
|
|
10
11
|
export { OTP } from './components/one-time-password/otp.js';
|
|
11
12
|
export { Popover } from './components/popover.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/index.gts';\nexport { Link } from './components/link.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 * from './helpers.ts';\nexport type { default as SetupService } from './services/ember-primitives/setup.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 { StickyFooter } from './components/layout/sticky-footer/index.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 * from './helpers.ts';\nexport type { default as SetupService } from './services/ember-primitives/setup.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,CAAA;AAC3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Service from '@ember/service';
|
|
2
|
-
import { getTabster, createTabster, getMover } from 'tabster';
|
|
2
|
+
import { getTabster, createTabster, getMover, getDeloser } from 'tabster';
|
|
3
3
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
5
|
|
|
@@ -28,6 +28,7 @@ class EmberPrimitivesSetup extends Service {
|
|
|
28
28
|
};
|
|
29
29
|
#setupTabster = tabster => {
|
|
30
30
|
getMover(tabster);
|
|
31
|
+
getDeloser(tabster);
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sources":["../../../src/services/ember-primitives/setup.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport Service from '@ember/service';\n\nimport { createTabster, getMover, getTabster } from 'tabster';\n\n/**\n * @internal\n */\nexport const PRIMITIVES = Symbol.for('ember-primitives-globals');\n\nexport default class EmberPrimitivesSetup extends Service {\n /**\n * Sets up required features for accessibility.\n */\n setup = ({\n tabster,\n setTabsterRoot,\n }: {\n /**\n * Let this setup function initalize tabster.\n * https://tabster.io/docs/core\n *\n * This should be done only once per application as we don't want\n * focus managers fighting with each other.\n *\n * Defaults to `true`,\n *\n * Will fallback to an existing tabster instance automatically if `
|
|
1
|
+
{"version":3,"file":"setup.js","sources":["../../../src/services/ember-primitives/setup.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport Service from '@ember/service';\n\nimport { createTabster, getDeloser, getMover, getTabster } from 'tabster';\n\n/**\n * @internal\n */\nexport const PRIMITIVES = Symbol.for('ember-primitives-globals');\n\nexport default class EmberPrimitivesSetup extends Service {\n /**\n * Sets up required features for accessibility.\n */\n setup = ({\n tabster,\n setTabsterRoot,\n }: {\n /**\n * Let this setup function initalize tabster.\n * https://tabster.io/docs/core\n *\n * This should be done only once per application as we don't want\n * focus managers fighting with each other.\n *\n * Defaults to `true`,\n *\n * Will fallback to an existing tabster instance automatically if `getTabster` returns a value.\n */\n tabster?: boolean;\n setTabsterRoot?: boolean;\n } = {}) => {\n tabster ??= true;\n setTabsterRoot ??= true;\n\n if (!tabster) {\n return;\n }\n\n let existing = getTabster(window);\n\n this.#setupTabster(existing ?? createTabster(window));\n\n if (setTabsterRoot) {\n document.body.setAttribute('data-tabster', '{ \"root\": {} }');\n }\n };\n\n #setupTabster = (tabster: ReturnType<typeof createTabster>) => {\n getMover(tabster);\n getDeloser(tabster);\n };\n}\n"],"names":["PRIMITIVES","Symbol","for","EmberPrimitivesSetup","Service","setup","tabster","setTabsterRoot","existing","getTabster","window","createTabster","document","body","setAttribute","getMover","getDeloser"],"mappings":";;;AAAA;;AAKA;AACA;AACA;AACO,MAAMA,UAAU,GAAGC,MAAM,CAACC,GAAG,CAAC,0BAA0B,EAAC;AAEjD,MAAMC,oBAAoB,SAASC,OAAO,CAAC;AACxD;AACF;AACA;AACEC,EAAAA,KAAK,GAAGA,CAAC;IACPC,OAAO;AACPC,IAAAA,cAAAA;GAeD,GAAG,EAAE,KAAK;AACTD,IAAAA,OAAO,KAAK,IAAI,CAAA;AAChBC,IAAAA,cAAc,KAAK,IAAI,CAAA;IAEvB,IAAI,CAACD,OAAO,EAAE;AACZ,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,IAAIE,QAAQ,GAAGC,UAAU,CAACC,MAAM,CAAC,CAAA;IAEjC,IAAI,CAAC,aAAa,CAACF,QAAQ,IAAIG,aAAa,CAACD,MAAM,CAAC,CAAC,CAAA;AAErD,IAAA,IAAIH,cAAc,EAAE;MAClBK,QAAQ,CAACC,IAAI,CAACC,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAA;AAC9D,KAAA;GACD,CAAA;EAED,aAAa,GAAIR,OAAyC,IAAK;IAC7DS,QAAQ,CAACT,OAAO,CAAC,CAAA;IACjBU,UAAU,CAACV,OAAO,CAAC,CAAA;GACpB,CAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Making apps easier to build",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.23.9",
|
|
21
21
|
"@embroider/addon-shim": "^1.8.7",
|
|
22
|
-
"@embroider/macros": "1.
|
|
23
|
-
"@floating-ui/dom": "^1.5.
|
|
22
|
+
"@embroider/macros": "1.15.1",
|
|
23
|
+
"@floating-ui/dom": "^1.5.3",
|
|
24
24
|
"decorator-transforms": "^1.1.0",
|
|
25
25
|
"ember-element-helper": "^0.8.4",
|
|
26
|
-
"ember-velcro": "^2.1.3",
|
|
27
26
|
"reactiveweb": "^1.2.0",
|
|
28
|
-
"tabster": "^7.0
|
|
27
|
+
"tabster": "^7.1.0",
|
|
28
|
+
"tracked-built-ins": "^3.2.0",
|
|
29
29
|
"tracked-toolbox": "^2.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"./components/external-link.js": "./dist/_app_/components/external-link.js",
|
|
92
92
|
"./components/form.js": "./dist/_app_/components/form.js",
|
|
93
93
|
"./components/link.js": "./dist/_app_/components/link.js",
|
|
94
|
+
"./components/menu.js": "./dist/_app_/components/menu.js",
|
|
94
95
|
"./components/popover.js": "./dist/_app_/components/popover.js",
|
|
95
96
|
"./components/portal-targets.js": "./dist/_app_/components/portal-targets.js",
|
|
96
97
|
"./components/portal.js": "./dist/_app_/components/portal.js",
|