@infonomic/uikit 7.0.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/dist/components/accordion/accordion.contract.d.ts +2 -2
- package/dist/components/accordion/accordion.contract.d.ts.map +1 -1
- package/dist/components/accordion/accordion.contract.js +2 -2
- package/dist/components/accordion/accordion.module.css +16 -5
- package/dist/components/accordion/accordion_module.css +4 -6
- package/dist/components/button/button.astro +14 -8
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +2 -1
- package/dist/components/dropdown/dropdown.contract.d.ts +2 -2
- package/dist/components/dropdown/dropdown.contract.d.ts.map +1 -1
- package/dist/components/dropdown/dropdown.contract.js +3 -2
- package/dist/components/dropdown/dropdown.module.css +11 -0
- package/dist/components/dropdown/dropdown_module.css +5 -0
- package/dist/components/inputs/checkbox.contract.d.ts +4 -4
- package/dist/components/inputs/checkbox.contract.d.ts.map +1 -1
- package/dist/components/inputs/checkbox.contract.js +5 -3
- package/dist/components/inputs/checkbox.d.ts +6 -0
- package/dist/components/inputs/checkbox.d.ts.map +1 -1
- package/dist/components/inputs/checkbox.module.css +29 -3
- package/dist/components/inputs/checkbox_module.css +25 -3
- package/dist/components/tabs/tabs.contract.d.ts +2 -2
- package/dist/components/tabs/tabs.contract.d.ts.map +1 -1
- package/dist/components/tabs/tabs.contract.js +3 -2
- package/dist/components/tabs/tabs.module.css +9 -0
- package/dist/components/tabs/tabs_module.css +1 -1
- package/dist/css/accordion.css +4 -6
- package/dist/css/checkbox.css +25 -3
- package/dist/css/dropdown.css +5 -0
- package/dist/css/tabs.css +1 -1
- package/dist/lib/ripple.d.ts +55 -6
- package/dist/lib/ripple.d.ts.map +1 -1
- package/dist/lib/ripple.js +61 -10
- package/dist/styles/components-vanilla.css +1 -1
- package/dist/styles/styles.css +1 -1
- package/dist/widgets/drawer/drawer.contract.d.ts +1 -1
- package/dist/widgets/drawer/drawer.contract.d.ts.map +1 -1
- package/dist/widgets/drawer/drawer.contract.js +1 -1
- package/package.json +22 -17
- package/src/components/accordion/accordion.contract.ts +2 -2
- package/src/components/accordion/accordion.module.css +16 -5
- package/src/components/button/button.astro +14 -8
- package/src/components/button/button.tsx +4 -0
- package/src/components/dropdown/dropdown.contract.ts +2 -2
- package/src/components/dropdown/dropdown.module.css +11 -0
- package/src/components/dropdown/dropdown.stories.tsx +6 -0
- package/src/components/inputs/checkbox.contract.ts +6 -4
- package/src/components/inputs/checkbox.module.css +29 -3
- package/src/components/inputs/checkbox.stories.tsx +43 -0
- package/src/components/inputs/checkbox.tsx +6 -0
- package/src/components/tabs/tabs.contract.ts +3 -2
- package/src/components/tabs/tabs.module.css +9 -0
- package/src/lib/ripple.ts +136 -13
- package/src/styles/theme/defaults.css +3 -2
- package/src/styles/utils/utility-classes.css +3 -2
- package/src/widgets/drawer/drawer.contract.ts +1 -1
|
@@ -39,6 +39,10 @@ export const Button = ({
|
|
|
39
39
|
type,
|
|
40
40
|
className: cx(buttonClasses({ variant, size, intent, fullWidth }), className),
|
|
41
41
|
children,
|
|
42
|
+
// Read by `attachRipple` from `@infonomic/uikit/ripple`. `self` says this
|
|
43
|
+
// button makes its own ripple, so a page that also attaches the shared
|
|
44
|
+
// listener draws one ripple for a press, not two. `false` turns it off.
|
|
45
|
+
'data-ripple': ripple === true ? 'self' : 'false',
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
if (ripple === true) {
|
|
@@ -23,10 +23,10 @@ export const dropdownContract = {
|
|
|
23
23
|
},
|
|
24
24
|
item: {
|
|
25
25
|
description:
|
|
26
|
-
'One choice in the menu. Base UI `Menu.Item`. Highlighted while it has `data-highlighted`.',
|
|
26
|
+
'One choice in the menu. Base UI `Menu.Item`. Highlighted while it has `data-highlighted`, and dimmed while it has `data-disabled`.',
|
|
27
27
|
plainClass: 'infonomic-dropdown-item',
|
|
28
28
|
moduleClass: 'dropdown-item',
|
|
29
|
-
states: ['data-highlighted'],
|
|
29
|
+
states: ['data-highlighted', 'data-disabled'],
|
|
30
30
|
},
|
|
31
31
|
separator: {
|
|
32
32
|
description: 'A line between groups of items. Base UI `Menu.Separator`.',
|
|
@@ -71,6 +71,17 @@
|
|
|
71
71
|
color: var(--surface-item-text-hover);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/*
|
|
75
|
+
* A disabled item is dimmed and takes no pointer. A keyboard highlight still
|
|
76
|
+
* shows on it, dimmed, so focus is never invisible where the behaviour layer
|
|
77
|
+
* lets focus reach a disabled item.
|
|
78
|
+
*/
|
|
79
|
+
.dropdown-item[data-disabled],
|
|
80
|
+
:global(.infonomic-dropdown-item)[data-disabled] {
|
|
81
|
+
opacity: 0.5;
|
|
82
|
+
pointer-events: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
.dropdown-separator,
|
|
75
86
|
:global(.infonomic-dropdown-separator) {
|
|
76
87
|
width: 90%;
|
|
@@ -75,6 +75,12 @@ export const Dropdown: Story = {
|
|
|
75
75
|
<span className="dropdown-item-content-text">Menu Item 2</span>
|
|
76
76
|
</div>
|
|
77
77
|
</DropdownComponent.Item>
|
|
78
|
+
<DropdownComponent.Item disabled>
|
|
79
|
+
<div className="dropdown-item-content">
|
|
80
|
+
<span className="dropdown-item-content-icon" />
|
|
81
|
+
<span className="dropdown-item-content-text">Menu Item 3 (disabled)</span>
|
|
82
|
+
</div>
|
|
83
|
+
</DropdownComponent.Item>
|
|
78
84
|
<DropdownComponent.Separator />
|
|
79
85
|
<DropdownComponent.Item>
|
|
80
86
|
<div className="dropdown-item-content">
|
|
@@ -44,13 +44,14 @@ export const checkboxContract = {
|
|
|
44
44
|
danger: 'infonomic-checkbox-danger',
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
|
-
states: ['data-checked', 'data-disabled'],
|
|
47
|
+
states: ['data-checked', 'data-indeterminate', 'data-disabled'],
|
|
48
48
|
},
|
|
49
49
|
indicator: {
|
|
50
|
-
description:
|
|
50
|
+
description:
|
|
51
|
+
'Holds the check mark and shows it while checked. Base UI `Checkbox.Indicator`. While it has `data-indeterminate` it shows a dash instead, drawn by the stylesheet, so it must stay mounted in that state.',
|
|
51
52
|
plainClass: 'infonomic-checkbox-indicator',
|
|
52
53
|
moduleClass: 'indicator',
|
|
53
|
-
states: ['data-checked', 'data-unchecked'],
|
|
54
|
+
states: ['data-checked', 'data-unchecked', 'data-indeterminate'],
|
|
54
55
|
},
|
|
55
56
|
icon: {
|
|
56
57
|
description: 'The check mark.',
|
|
@@ -58,7 +59,8 @@ export const checkboxContract = {
|
|
|
58
59
|
moduleClass: 'icon',
|
|
59
60
|
},
|
|
60
61
|
label: {
|
|
61
|
-
description:
|
|
62
|
+
description:
|
|
63
|
+
'The text label beside the box. Its size follows the size class on the box, so it must be a later sibling of the box, not a `<label>` wrapped around it.',
|
|
62
64
|
plainClass: 'infonomic-checkbox-label',
|
|
63
65
|
themingVariables: ['--label-color'],
|
|
64
66
|
moduleClass: 'label',
|
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
.checkbox[data-checked],
|
|
46
|
-
|
|
46
|
+
.checkbox[data-indeterminate],
|
|
47
|
+
:global(.infonomic-checkbox)[data-checked],
|
|
48
|
+
:global(.infonomic-checkbox)[data-indeterminate] {
|
|
47
49
|
outline-color: var(--ring-color);
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -97,6 +99,26 @@
|
|
|
97
99
|
transform: scale(0.8);
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
/*
|
|
103
|
+
* Indeterminate: some, not all, of the boxes a parent stands for are ticked.
|
|
104
|
+
* The box is filled as when checked and shows a dash, drawn here so that no
|
|
105
|
+
* second icon is needed in the markup. The check mark stays hidden.
|
|
106
|
+
*/
|
|
107
|
+
.indicator[data-indeterminate],
|
|
108
|
+
:global(.infonomic-checkbox-indicator)[data-indeterminate] {
|
|
109
|
+
position: relative;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.indicator[data-indeterminate]::before,
|
|
113
|
+
:global(.infonomic-checkbox-indicator)[data-indeterminate]::before {
|
|
114
|
+
content: "";
|
|
115
|
+
position: absolute;
|
|
116
|
+
width: 55%;
|
|
117
|
+
height: 2px;
|
|
118
|
+
border-radius: 1px;
|
|
119
|
+
background-color: var(--checkbox-icon-color);
|
|
120
|
+
}
|
|
121
|
+
|
|
100
122
|
.label,
|
|
101
123
|
:global(.infonomic-checkbox-label) {
|
|
102
124
|
margin-left: 0.25rem;
|
|
@@ -170,7 +192,9 @@
|
|
|
170
192
|
}
|
|
171
193
|
|
|
172
194
|
.outlined[data-checked],
|
|
173
|
-
|
|
195
|
+
.outlined[data-indeterminate],
|
|
196
|
+
:global(.infonomic-checkbox-outlined)[data-checked],
|
|
197
|
+
:global(.infonomic-checkbox-outlined)[data-indeterminate] {
|
|
174
198
|
--ring-color: var(--checkbox-variant-outline-ring-color);
|
|
175
199
|
background-color: var(--checkbox-variant-outlined);
|
|
176
200
|
}
|
|
@@ -182,7 +206,9 @@
|
|
|
182
206
|
}
|
|
183
207
|
|
|
184
208
|
.filled[data-checked],
|
|
185
|
-
|
|
209
|
+
.filled[data-indeterminate],
|
|
210
|
+
:global(.infonomic-checkbox-filled)[data-checked],
|
|
211
|
+
:global(.infonomic-checkbox-filled)[data-indeterminate] {
|
|
186
212
|
--ring-color: var(--checkbox-variant-outline-ring-color);
|
|
187
213
|
}
|
|
188
214
|
|
|
@@ -283,3 +283,46 @@ export const Disabled = (): React.JSX.Element => {
|
|
|
283
283
|
</div>
|
|
284
284
|
)
|
|
285
285
|
}
|
|
286
|
+
|
|
287
|
+
const toppings = ['Olives', 'Mushrooms', 'Peppers']
|
|
288
|
+
|
|
289
|
+
export const Indeterminate = (): React.JSX.Element => {
|
|
290
|
+
const [chosen, setChosen] = useState<string[]>(['Olives'])
|
|
291
|
+
const all = chosen.length === toppings.length
|
|
292
|
+
const some = chosen.length > 0 && !all
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<div style={{ maxWidth: '800px', margin: '2rem auto 2rem' }} className="grid gap-4">
|
|
296
|
+
<Checkbox
|
|
297
|
+
id="all-toppings"
|
|
298
|
+
name="all-toppings"
|
|
299
|
+
label="All toppings"
|
|
300
|
+
checked={all}
|
|
301
|
+
indeterminate={some}
|
|
302
|
+
onCheckedChange={(checked) => setChosen(checked ? toppings : [])}
|
|
303
|
+
/>
|
|
304
|
+
<Checkbox
|
|
305
|
+
id="all-toppings-filled"
|
|
306
|
+
name="all-toppings-filled"
|
|
307
|
+
label="All toppings (filled, success)"
|
|
308
|
+
variant="filled"
|
|
309
|
+
intent="success"
|
|
310
|
+
checked={all}
|
|
311
|
+
indeterminate={some}
|
|
312
|
+
onCheckedChange={(checked) => setChosen(checked ? toppings : [])}
|
|
313
|
+
/>
|
|
314
|
+
{toppings.map((topping) => (
|
|
315
|
+
<Checkbox
|
|
316
|
+
key={topping}
|
|
317
|
+
id={`topping-${topping}`}
|
|
318
|
+
name={`topping-${topping}`}
|
|
319
|
+
label={topping}
|
|
320
|
+
checked={chosen.includes(topping)}
|
|
321
|
+
onCheckedChange={(checked) =>
|
|
322
|
+
setChosen(checked ? [...chosen, topping] : chosen.filter((item) => item !== topping))
|
|
323
|
+
}
|
|
324
|
+
/>
|
|
325
|
+
))}
|
|
326
|
+
</div>
|
|
327
|
+
)
|
|
328
|
+
}
|
|
@@ -20,6 +20,12 @@ export interface CheckboxProps {
|
|
|
20
20
|
intent?: Intent
|
|
21
21
|
reverse?: boolean
|
|
22
22
|
checked?: boolean
|
|
23
|
+
/**
|
|
24
|
+
* Shows the mixed state: a dash in a filled box, and `aria-checked="mixed"`.
|
|
25
|
+
* For a parent checkbox when some, not all, of the boxes it stands for are
|
|
26
|
+
* ticked.
|
|
27
|
+
*/
|
|
28
|
+
indeterminate?: boolean
|
|
23
29
|
disabled?: boolean
|
|
24
30
|
className?: string
|
|
25
31
|
checkBoxClasses?: string
|
|
@@ -20,10 +20,11 @@ export const tabsContract = {
|
|
|
20
20
|
moduleClass: 'tabs-trigger',
|
|
21
21
|
},
|
|
22
22
|
content: {
|
|
23
|
-
description:
|
|
23
|
+
description:
|
|
24
|
+
'One panel. Base UI `Tabs.Panel`. Hidden while it has `data-hidden`, and while it has `data-ending-style`: there is no exit animation, so an outgoing panel that is still mounted does not show beside the incoming one.',
|
|
24
25
|
plainClass: 'infonomic-tabs-content',
|
|
25
26
|
moduleClass: 'tabs-content',
|
|
26
|
-
states: ['data-hidden'],
|
|
27
|
+
states: ['data-hidden', 'data-ending-style'],
|
|
27
28
|
},
|
|
28
29
|
},
|
|
29
30
|
} as const satisfies ComponentContract
|
|
@@ -58,6 +58,15 @@
|
|
|
58
58
|
display: none;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/*
|
|
62
|
+
* A behaviour layer may keep the outgoing panel mounted, with this
|
|
63
|
+
* attribute, until its exit finishes. The kit has no tab exit, so the panel
|
|
64
|
+
* is hidden at once and never shows beside the incoming one.
|
|
65
|
+
*/
|
|
66
|
+
&[data-ending-style] {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
61
70
|
&:focus {
|
|
62
71
|
outline: none;
|
|
63
72
|
}
|
package/src/lib/ripple.ts
CHANGED
|
@@ -5,11 +5,45 @@
|
|
|
5
5
|
* Original work licensed under the MIT License.
|
|
6
6
|
* Copyright (c) 2021 Sajad Ahmad Nawabi
|
|
7
7
|
*
|
|
8
|
-
* Adapted for use as an
|
|
8
|
+
* Adapted for use as an ESM/TypeScript module with minor improvements. It uses
|
|
9
|
+
* the DOM only, so any framework can import it.
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
export type RippleColor = 'light' | 'dark'
|
|
12
13
|
|
|
14
|
+
/** The part of a mouse or pointer event that a ripple needs. */
|
|
15
|
+
export interface RipplePress {
|
|
16
|
+
clientX: number
|
|
17
|
+
clientY: number
|
|
18
|
+
currentTarget: EventTarget | null
|
|
19
|
+
/** The mouse button, where the event has one. Only the main button ripples. */
|
|
20
|
+
button?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// `false` turns the ripple off, on an element or on anything around it.
|
|
24
|
+
const optOutSelector = '[data-ripple="false"]'
|
|
25
|
+
const disabledSelector = ':disabled, [data-disabled], [aria-disabled="true"]'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether a press on `element` may draw a ripple. Every ripple goes through
|
|
29
|
+
* this, whichever listener asked for it, so the rules are the same for a React
|
|
30
|
+
* Button, an Astro Button and a button drawn by any other framework.
|
|
31
|
+
*
|
|
32
|
+
* No ripple for: any mouse button but the main one, a disabled element
|
|
33
|
+
* (`disabled`, `data-disabled` or `aria-disabled="true"`), an element with
|
|
34
|
+
* `data-ripple="false"` or inside one, and a user who has asked for reduced
|
|
35
|
+
* motion.
|
|
36
|
+
*
|
|
37
|
+
* It asks the element's own document and window, not the globals, so it works
|
|
38
|
+
* for an element inside an iframe.
|
|
39
|
+
*/
|
|
40
|
+
export function canRipple(event: { button?: number }, element: Element): boolean {
|
|
41
|
+
if (event.button != null && event.button !== 0) return false
|
|
42
|
+
if (element.matches(disabledSelector) || element.closest(optOutSelector) != null) return false
|
|
43
|
+
const view = element.ownerDocument.defaultView
|
|
44
|
+
return view?.matchMedia?.('(prefers-reduced-motion: reduce)').matches !== true
|
|
45
|
+
}
|
|
46
|
+
|
|
13
47
|
export class Ripple {
|
|
14
48
|
private x = 0
|
|
15
49
|
private y = 0
|
|
@@ -48,8 +82,8 @@ export class Ripple {
|
|
|
48
82
|
element.style.width = element.style.height = `${radius * 2}px`
|
|
49
83
|
}
|
|
50
84
|
|
|
51
|
-
private applyAnimation(element: HTMLSpanElement):
|
|
52
|
-
element.animate(
|
|
85
|
+
private applyAnimation(element: HTMLSpanElement): Animation {
|
|
86
|
+
return element.animate(
|
|
53
87
|
[
|
|
54
88
|
{ transform: 'scale(0)', opacity: 1 },
|
|
55
89
|
{ transform: 'scale(1.5)', opacity: 0 },
|
|
@@ -61,13 +95,24 @@ export class Ripple {
|
|
|
61
95
|
)
|
|
62
96
|
}
|
|
63
97
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Draws one ripple from the point of the press.
|
|
100
|
+
*
|
|
101
|
+
* The ripple is drawn in `target`, or in the event's `currentTarget` when no
|
|
102
|
+
* target is given. Pass the target when the listener is on an ancestor, where
|
|
103
|
+
* `currentTarget` is that ancestor and not the element pressed.
|
|
104
|
+
*
|
|
105
|
+
* Nothing is drawn when `canRipple` says no: see the rules there.
|
|
106
|
+
*/
|
|
107
|
+
create(event: RipplePress, color: RippleColor = 'light', target?: HTMLElement): void {
|
|
108
|
+
const element = target ?? (event.currentTarget as HTMLElement | null)
|
|
109
|
+
if (element == null || !canRipple(event, element)) return
|
|
110
|
+
const view = element.ownerDocument.defaultView
|
|
111
|
+
if (view == null) return
|
|
69
112
|
|
|
70
|
-
element.
|
|
113
|
+
// The circle is placed against the element and clipped to it. An element
|
|
114
|
+
// that is already positioned keeps its own position.
|
|
115
|
+
if (view.getComputedStyle(element).position === 'static') element.style.position = 'relative'
|
|
71
116
|
element.style.overflow = 'hidden'
|
|
72
117
|
|
|
73
118
|
const rect = element.getBoundingClientRect()
|
|
@@ -81,14 +126,92 @@ export class Ripple {
|
|
|
81
126
|
rect.top
|
|
82
127
|
)
|
|
83
128
|
|
|
84
|
-
const circle =
|
|
129
|
+
const circle = element.ownerDocument.createElement('span')
|
|
85
130
|
|
|
86
131
|
this.applyStyles(circle, color, rect, radius, event.clientX, event.clientY)
|
|
87
|
-
this.applyAnimation(circle)
|
|
88
|
-
|
|
89
132
|
element.appendChild(circle)
|
|
90
133
|
|
|
91
|
-
|
|
134
|
+
// Removed when the animation ends, or when it is cancelled, which is what
|
|
135
|
+
// happens if the element leaves the page first.
|
|
136
|
+
const remove = (): void => circle.remove()
|
|
137
|
+
this.applyAnimation(circle).finished.then(remove, remove)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const buttonSelector = '.infonomic-button'
|
|
142
|
+
const lightSelector = '.infonomic-button-filled, .infonomic-button-gradient'
|
|
143
|
+
// `self` marks a button that makes its own ripple, as the React Button does, so
|
|
144
|
+
// that a page with both kinds never draws two for one press.
|
|
145
|
+
const ownRippleSelector = '[data-ripple="self"]'
|
|
146
|
+
|
|
147
|
+
interface Attachment {
|
|
148
|
+
count: number
|
|
149
|
+
detach: () => void
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const attachments = new WeakMap<Document | Element, Attachment>()
|
|
153
|
+
|
|
154
|
+
// Presses already answered. Roots can overlap, a container inside a document
|
|
155
|
+
// that is attached too, and the press reaches both listeners.
|
|
156
|
+
const answered = new WeakSet<Event>()
|
|
157
|
+
|
|
158
|
+
/** An element from any window: `instanceof Element` fails across iframes. */
|
|
159
|
+
const isElement = (node: unknown): node is Element =>
|
|
160
|
+
node != null && (node as Node).nodeType === 1 && typeof (node as Element).closest === 'function'
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Gives every kit button inside `root` a ripple, with one listener on `root`.
|
|
164
|
+
*
|
|
165
|
+
* A press on an element with the `infonomic-button` class, or on anything
|
|
166
|
+
* inside one, draws a ripple in that button: light on a filled or gradient
|
|
167
|
+
* button, dark on the others. Buttons added later are covered too.
|
|
168
|
+
*
|
|
169
|
+
* No ripple is drawn where `canRipple` says no, or for a button that makes its
|
|
170
|
+
* own ripple (`data-ripple="self"`).
|
|
171
|
+
*
|
|
172
|
+
* Returns a function that removes the ripple from `root`. A press draws one
|
|
173
|
+
* ripple however many roots it passes through: attaching to the same root more
|
|
174
|
+
* than once, or to a container inside an attached document, changes nothing.
|
|
175
|
+
* Each attachment is removed on its own, and a root's listener stays until
|
|
176
|
+
* every caller for that root has detached.
|
|
177
|
+
*
|
|
178
|
+
* `root` may belong to another window, such as an iframe's document.
|
|
179
|
+
*/
|
|
180
|
+
export function attachRipple(root: Document | Element): () => void {
|
|
181
|
+
let attachment = attachments.get(root)
|
|
182
|
+
|
|
183
|
+
if (attachment == null) {
|
|
184
|
+
const ripple = new Ripple()
|
|
185
|
+
const onPointerDown = (event: Event): void => {
|
|
186
|
+
const press = event as PointerEvent
|
|
187
|
+
if (answered.has(press) || !isElement(press.target)) return
|
|
188
|
+
const button = press.target.closest<HTMLElement>(buttonSelector)
|
|
189
|
+
if (button == null || !root.contains(button)) return
|
|
190
|
+
answered.add(press)
|
|
191
|
+
if (button.matches(ownRippleSelector)) return
|
|
192
|
+
ripple.create(press, button.matches(lightSelector) ? 'light' : 'dark', button)
|
|
193
|
+
}
|
|
194
|
+
root.addEventListener('pointerdown', onPointerDown)
|
|
195
|
+
const created: Attachment = {
|
|
196
|
+
count: 0,
|
|
197
|
+
detach: () => root.removeEventListener('pointerdown', onPointerDown),
|
|
198
|
+
}
|
|
199
|
+
attachments.set(root, created)
|
|
200
|
+
attachment = created
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const current = attachment
|
|
204
|
+
current.count += 1
|
|
205
|
+
let detached = false
|
|
206
|
+
|
|
207
|
+
return () => {
|
|
208
|
+
if (detached) return
|
|
209
|
+
detached = true
|
|
210
|
+
current.count -= 1
|
|
211
|
+
if (current.count === 0) {
|
|
212
|
+
current.detach()
|
|
213
|
+
attachments.delete(root)
|
|
214
|
+
}
|
|
92
215
|
}
|
|
93
216
|
}
|
|
94
217
|
|
|
@@ -68,10 +68,11 @@
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/* External link indicator */
|
|
71
|
+
/* The icons are inlined so that a host has no files to serve. */
|
|
71
72
|
.external-link::after {
|
|
72
73
|
content: "";
|
|
73
74
|
display: inline-block;
|
|
74
|
-
background-image: url("/
|
|
75
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000855'%3E%3Cpath d='M19 19H5V5h7V3H3v18h18v-9h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'/%3E%3C/svg%3E");
|
|
75
76
|
background-repeat: no-repeat;
|
|
76
77
|
background-position: 20% 50%;
|
|
77
78
|
background-size: 65% auto;
|
|
@@ -82,6 +83,6 @@
|
|
|
82
83
|
|
|
83
84
|
.dark .external-link::after,
|
|
84
85
|
[data-theme="dark"] .external-link::after {
|
|
85
|
-
background-image: url("/
|
|
86
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23dddddd'%3E%3Cpath d='M19 19H5V5h7V3H3v18h18v-9h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'/%3E%3C/svg%3E");
|
|
86
87
|
}
|
|
87
88
|
}
|
|
@@ -56,10 +56,11 @@
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/* External link */
|
|
59
|
+
/* The icons are inlined so that a host has no files to serve. */
|
|
59
60
|
.external-link::after {
|
|
60
61
|
content: "";
|
|
61
62
|
display: inline-block;
|
|
62
|
-
background-image: url("/
|
|
63
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000855'%3E%3Cpath d='M19 19H5V5h7V3H3v18h18v-9h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'/%3E%3C/svg%3E");
|
|
63
64
|
background-repeat: no-repeat;
|
|
64
65
|
background-position: 20% 50%;
|
|
65
66
|
background-size: 65% auto;
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
|
|
71
72
|
.dark .external-link::after,
|
|
72
73
|
[data-theme="dark"] .external-link::after {
|
|
73
|
-
background-image: url("/
|
|
74
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23dddddd'%3E%3Cpath d='M19 19H5V5h7V3H3v18h18v-9h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'/%3E%3C/svg%3E");
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
.primary-strong {
|
|
@@ -13,7 +13,7 @@ export const drawerContract = {
|
|
|
13
13
|
},
|
|
14
14
|
wrapper: {
|
|
15
15
|
description:
|
|
16
|
-
'The panel that slides in from the side. Base UI `Drawer.Popup`. The width class sets its width, and the depth class adjusts a drawer opened over another.',
|
|
16
|
+
'The panel that slides in from the right edge, the only side the stylesheet supports. Base UI `Drawer.Popup`. The width class sets its width, and the depth class adjusts a drawer opened over another.',
|
|
17
17
|
plainClass: 'infonomic-drawer-wrapper',
|
|
18
18
|
moduleClass: 'drawer-wrapper',
|
|
19
19
|
modifiers: {
|