@splendidlabz/svelte 4.3.1 → 4.5.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/CHANGELOG.md +29 -0
- package/components/Breadcrumbs/Breadcrumbs.svelte +10 -9
- package/components/Breadcrumbs/Crumb.svelte +2 -1
- package/components/ContentList/ContentList.svelte +1 -1
- package/components/Disclosure/Disclosure/DisclosureContent.svelte +6 -8
- package/components/Disclosure/Disclosure/DisclosureTrigger.svelte +34 -9
- package/components/Disclosure/Disclosure/disclosure.svelte.js +61 -79
- package/components/Disclosure/Drawer/DrawerCloseButton.svelte +14 -30
- package/components/Disclosure/Drawer/DrawerContent.svelte +58 -74
- package/components/Disclosure/Drawer/DrawerTrigger.svelte +13 -6
- package/components/Disclosure/Drawer/drawer.js +3 -27
- package/components/Disclosure/Drawer/index.js +6 -2
- package/components/Disclosure/Modal/ModalContent.svelte +122 -32
- package/components/Disclosure/Modal/ModalTrigger.svelte +63 -6
- package/components/Disclosure/Modal/index.js +2 -2
- package/components/Disclosure/Popover/PopoverContent.svelte +109 -97
- package/components/Disclosure/Popover/PopoverTrigger.svelte +67 -22
- package/components/Disclosure/Popover/floating.js +278 -117
- package/components/Disclosure/Popover/index.js +3 -2
- package/components/Disclosure/index.js +3 -7
- package/components/Disclosure/shared.js +1 -0
- package/components/DisclosureOld/Drawer/DrawerCloseButton.svelte +37 -0
- package/components/DisclosureOld/Drawer/DrawerContent.svelte +92 -0
- package/components/DisclosureOld/Drawer/DrawerTrigger.svelte +11 -0
- package/components/{Disclosure/DrawerNew → DisclosureOld/Drawer}/drawer.js +0 -26
- package/components/{Disclosure/DrawerNew → DisclosureOld/Drawer}/index.js +2 -6
- package/components/DisclosureOld/Modal/ModalContent.svelte +42 -0
- package/components/DisclosureOld/Modal/ModalTrigger.svelte +11 -0
- package/components/DisclosureOld/Modal/index.js +5 -0
- package/components/DisclosureOld/Old/DisclosureContentOld.svelte +97 -0
- package/components/DisclosureOld/Old/DisclosureTriggerOld.svelte +51 -0
- package/components/{Disclosure → DisclosureOld}/Popover/PopoverCloseButton.svelte +4 -1
- package/components/DisclosureOld/Popover/PopoverContent.svelte +107 -0
- package/components/DisclosureOld/Popover/PopoverTrigger.svelte +33 -0
- package/components/DisclosureOld/Popover/floating.js +171 -0
- package/components/DisclosureOld/Popover/index.js +5 -0
- package/components/{Disclosure → DisclosureOld}/Tooltip/TooltipTrigger.svelte +1 -1
- package/components/{Disclosure → DisclosureOld}/disclosure.js +44 -40
- package/components/Form/Combobox/AutocompleteInput.svelte +3 -3
- package/components/Form/Combobox/AutocompleteOptions.svelte +5 -5
- package/components/Form/Combobox/TimepickerInput.svelte +7 -7
- package/components/Form/Combobox/TimepickerOptions.svelte +7 -7
- package/components/Form/Combobox/autocomplete.js +2 -2
- package/components/Form/Combobox/combobox.js +2 -2
- package/components/SVG/SVG.svelte +46 -0
- package/components/SVG/SVGGradient.svelte +37 -0
- package/components/SVG/index.js +2 -1
- package/package.json +3 -3
- package/actions/resize-observer.js +0 -43
- package/actions/scroll-observer.js +0 -47
- package/components/Disclosure/Disclosure/disclosure-popover.svelte.js +0 -7
- package/components/Disclosure/DisclosureNew/DisclosureCloseButton.svelte +0 -38
- package/components/Disclosure/DisclosureNew/DisclosureContent.svelte +0 -53
- package/components/Disclosure/DisclosureNew/DisclosureTrigger.svelte +0 -79
- package/components/Disclosure/DisclosureNew/disclosures.svelte.js +0 -55
- package/components/Disclosure/DisclosureNew/index.js +0 -5
- package/components/Disclosure/Drawer/DrawerNew.svelte +0 -0
- package/components/Disclosure/DrawerNew/DrawerCloseButton.svelte +0 -21
- package/components/Disclosure/DrawerNew/DrawerContent.svelte +0 -45
- package/components/Disclosure/DrawerNew/DrawerTrigger.svelte +0 -15
- package/components/Disclosure/ModalNew/ModalContent.svelte +0 -132
- package/components/Disclosure/ModalNew/ModalTrigger.svelte +0 -68
- package/components/Disclosure/ModalNew/index.js +0 -5
- package/components/Disclosure/PopoverNew/PopoverContent.svelte +0 -119
- package/components/Disclosure/PopoverNew/PopoverTrigger.svelte +0 -77
- package/components/Disclosure/PopoverNew/floating.js +0 -332
- package/components/Disclosure/PopoverNew/index.js +0 -6
- package/components/Disclosure/state.svelte.js +0 -138
- /package/components/Disclosure/{ModalNew → Modal}/ModalClose.svelte +0 -0
- /package/components/Disclosure/{PopoverNew → Popover}/Popover.svelte +0 -0
- /package/components/Disclosure/{PopoverNew → Popover}/PopoverClose.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Drawer/Drawer.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Dropdown/DropdownContent.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Dropdown/DropdownTrigger.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Dropdown/dropdown.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/Dropdown/index.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/Modal/Modal.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Modal/ModalCloseButton.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Modal/exit-intent.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/Modal/modal.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/Popover/popover.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/Popover/references/FollowTheMouse.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Tooltip/Tooltip.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Tooltip/TooltipContent.svelte +0 -0
- /package/components/{Disclosure → DisclosureOld}/Tooltip/index.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/Tooltip/tooltip.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/disclosure-store.js +0 -0
- /package/components/{Disclosure → DisclosureOld}/disclosure.svelte.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { delay, omitEmpty } from '@splendidlabz/utils'
|
|
1
2
|
import {
|
|
2
3
|
Focusable,
|
|
3
4
|
addListeners,
|
|
@@ -8,7 +9,6 @@ import {
|
|
|
8
9
|
removeListeners,
|
|
9
10
|
trapFocus,
|
|
10
11
|
} from '@splendidlabz/utils/dom'
|
|
11
|
-
import { delay, omitEmpty } from '@splendidlabz/utils'
|
|
12
12
|
import {
|
|
13
13
|
getDisclosure as getD,
|
|
14
14
|
getDisclosures,
|
|
@@ -45,14 +45,21 @@ export const DISCLOSURE_TRIGGER_OPT_KEYS = Object.keys(
|
|
|
45
45
|
* @property {(string|HTMLElement)} focusTargetWhenOpening - Focus target when disclosure content is opened. Can be 'first', 'content', or an HTMLElement.
|
|
46
46
|
*/
|
|
47
47
|
export const DEFAULT_DISCLOSURE_CONTENT_OPTS = {
|
|
48
|
-
|
|
49
|
-
closeOnEscapeButton: true,
|
|
48
|
+
lightDismiss: true,
|
|
50
49
|
focusManagement: 'manage', // false, `manage`, `trap`
|
|
51
|
-
focusTargetWhenOpening: 'content', // || false, 'first', 'content'.
|
|
50
|
+
focusTargetWhenOpening: 'content', // || false, 'first', 'content'.
|
|
52
51
|
focusTriggerOnClose: true,
|
|
53
52
|
inertOthers: false,
|
|
54
53
|
preventBodyScroll: false,
|
|
55
54
|
useAutoWidth: false,
|
|
55
|
+
onclick: null,
|
|
56
|
+
onkeydown: null,
|
|
57
|
+
ontoggle: null,
|
|
58
|
+
onbeforetoggle: null,
|
|
59
|
+
onopen: null,
|
|
60
|
+
onbeforeopen: null,
|
|
61
|
+
onclose: null,
|
|
62
|
+
onbeforeclose: null,
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
export const DISCLOSURE_CONTENT_OPT_KEYS = Object.keys(
|
|
@@ -66,6 +73,7 @@ export const DISCLOSURE_CONTENT_OPT_KEYS = Object.keys(
|
|
|
66
73
|
* @prop {DisclosureTriggerOpts} props - The trigger options.
|
|
67
74
|
*/
|
|
68
75
|
export function disclosureTrigger(node, props = {}) {
|
|
76
|
+
console.log('dt running')
|
|
69
77
|
const targetId = node.getAttribute('target')
|
|
70
78
|
|
|
71
79
|
const disclosureInfo = {
|
|
@@ -80,6 +88,7 @@ export function disclosureTrigger(node, props = {}) {
|
|
|
80
88
|
|
|
81
89
|
const d = initDisclosure(disclosureInfo)
|
|
82
90
|
node.setAttribute('aria-expanded', d.state.show)
|
|
91
|
+
node.setAttribute('data-show', d.state.show)
|
|
83
92
|
|
|
84
93
|
const listeners = [
|
|
85
94
|
{
|
|
@@ -97,12 +106,6 @@ export function disclosureTrigger(node, props = {}) {
|
|
|
97
106
|
node,
|
|
98
107
|
handler: tabOntoContent,
|
|
99
108
|
},
|
|
100
|
-
// Testing with removing this feature
|
|
101
|
-
// {
|
|
102
|
-
// event: 'keydown',
|
|
103
|
-
// node,
|
|
104
|
-
// handler: backToDisclosureContent,
|
|
105
|
-
// },
|
|
106
109
|
{
|
|
107
110
|
event: 'pointerenter',
|
|
108
111
|
node,
|
|
@@ -127,35 +130,26 @@ export function disclosureTrigger(node, props = {}) {
|
|
|
127
130
|
|
|
128
131
|
function handleClick(event) {
|
|
129
132
|
if (d.options.showOnClick) {
|
|
130
|
-
|
|
131
|
-
if (
|
|
133
|
+
const { show } = d.state
|
|
134
|
+
if (show === false) return open(d)
|
|
135
|
+
if (show === true) return close(d)
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
function closeOnEscapeButton(event) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
140
|
+
const { lightDismiss } = d.options
|
|
141
|
+
if (event.key !== 'Escape') return
|
|
142
|
+
if (lightDismiss) return close(d)
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
function tabOntoContent(event) {
|
|
142
146
|
if (d.state.show === false) return
|
|
143
|
-
console.log('tabOntoContent')
|
|
144
147
|
if (isTab(event)) {
|
|
145
148
|
event.preventDefault()
|
|
146
149
|
d.nodes.contentFocusables.first?.focus()
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
|
|
150
|
-
// function backToDisclosureContent(event) {
|
|
151
|
-
// if (d.options.shiftTabBackToContent === false) return
|
|
152
|
-
// if (isShiftTab(event) && d.state.show === true) {
|
|
153
|
-
// setTimeout(_ => {
|
|
154
|
-
// d.nodes.content.focus({ preventScroll: true })
|
|
155
|
-
// }, 0)
|
|
156
|
-
// }
|
|
157
|
-
// }
|
|
158
|
-
|
|
159
153
|
function handlePointerEnter(event) {
|
|
160
154
|
if (d.options.showOnHover) {
|
|
161
155
|
d.state.pointerLocation = 'trigger'
|
|
@@ -200,6 +194,8 @@ export function disclosureTrigger(node, props = {}) {
|
|
|
200
194
|
* @prop {DisclosureContentOpts} props - The trigger options.
|
|
201
195
|
*/
|
|
202
196
|
export function disclosureContent(node, props = {}) {
|
|
197
|
+
console.log('dc running')
|
|
198
|
+
|
|
203
199
|
const disclosureContentID = node.getAttribute('id')
|
|
204
200
|
const contentFocusables = Focusable(node)
|
|
205
201
|
|
|
@@ -222,7 +218,7 @@ export function disclosureContent(node, props = {}) {
|
|
|
222
218
|
// Opening actions
|
|
223
219
|
node.setAttribute('tabindex', '-1')
|
|
224
220
|
|
|
225
|
-
const { focusTargetWhenOpening, useAutoWidth } = d.options
|
|
221
|
+
const { focusTargetWhenOpening, useAutoWidth, onopen, ontoggle } = d.options
|
|
226
222
|
|
|
227
223
|
if (d.options.inertOthers) makeOthersInert(d)
|
|
228
224
|
if (d.options.preventBodyScroll) preventBodyScroll()
|
|
@@ -235,13 +231,16 @@ export function disclosureContent(node, props = {}) {
|
|
|
235
231
|
// Setting focus requires timeout. Otherwise, it won't work.
|
|
236
232
|
setTimeout(_ => {
|
|
237
233
|
if (focusTargetWhenOpening) {
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
if (
|
|
234
|
+
const target = focusTargetWhenOpening
|
|
235
|
+
if (target === 'content') node.focus()
|
|
236
|
+
if (target === 'first') contentFocusables.first?.focus()
|
|
237
|
+
if (target === 'second') contentFocusables[1]?.focus()
|
|
238
|
+
if (target instanceof HTMLElement) target.focus()
|
|
241
239
|
}
|
|
242
240
|
|
|
243
|
-
//
|
|
244
|
-
|
|
241
|
+
// Run opening functions
|
|
242
|
+
if (typeof onopen === 'function') onopen(d)
|
|
243
|
+
if (typeof ontoggle === 'function') ontoggle(d)
|
|
245
244
|
}, 0)
|
|
246
245
|
|
|
247
246
|
// Add event listeners
|
|
@@ -251,11 +250,6 @@ export function disclosureContent(node, props = {}) {
|
|
|
251
250
|
node: document,
|
|
252
251
|
handler: handleOutsideClick,
|
|
253
252
|
},
|
|
254
|
-
// {
|
|
255
|
-
// event: 'keydown',
|
|
256
|
-
// node: document,
|
|
257
|
-
// handler: closeAllOnEscape,
|
|
258
|
-
// },
|
|
259
253
|
{
|
|
260
254
|
event: 'keydown',
|
|
261
255
|
node,
|
|
@@ -286,7 +280,7 @@ export function disclosureContent(node, props = {}) {
|
|
|
286
280
|
// ========================
|
|
287
281
|
// Close if click is outside of contentNode and triggerNode
|
|
288
282
|
function handleOutsideClick(event) {
|
|
289
|
-
if (d.options.
|
|
283
|
+
if (d.options.lightDismiss === false) return
|
|
290
284
|
if (d.nodes.content.contains(event.target)) return
|
|
291
285
|
if (d.nodes.trigger.contains(event.target)) return
|
|
292
286
|
// Only close if state is currently set to show
|
|
@@ -323,7 +317,7 @@ export function disclosureContent(node, props = {}) {
|
|
|
323
317
|
})
|
|
324
318
|
}
|
|
325
319
|
|
|
326
|
-
if (d.options.
|
|
320
|
+
if (d.options.lightDismiss) closeOnEscape(event)
|
|
327
321
|
}
|
|
328
322
|
|
|
329
323
|
function closeOnEscape(event) {
|
|
@@ -346,10 +340,14 @@ export function disclosureContent(node, props = {}) {
|
|
|
346
340
|
// Methods
|
|
347
341
|
// ========================
|
|
348
342
|
export function open(d) {
|
|
343
|
+
const { onbeforeopen, onbeforetoggle } = d.options
|
|
344
|
+
if (typeof onbeforeopen === 'function') onbeforeopen(d)
|
|
345
|
+
if (typeof onbeforetoggle === 'function') onbeforetoggle(d)
|
|
349
346
|
if (d.state.show === true) return
|
|
350
347
|
d.state.show = true
|
|
351
348
|
const { trigger } = d.nodes
|
|
352
349
|
trigger.setAttribute('aria-expanded', d.state.show)
|
|
350
|
+
trigger.setAttribute('data-show', d.state.show)
|
|
353
351
|
|
|
354
352
|
if (d.options.closeOthers) closeOthersExcept(d.id)
|
|
355
353
|
|
|
@@ -360,18 +358,24 @@ export function open(d) {
|
|
|
360
358
|
}
|
|
361
359
|
|
|
362
360
|
export function close(d, { shouldFocusTrigger = false } = {}) {
|
|
361
|
+
const { onbeforeclose, onbeforetoggle, onclose, ontoggle } = d.options
|
|
362
|
+
if (typeof onbeforeclose === 'function') onbeforeclose(d)
|
|
363
|
+
if (typeof onbeforetoggle === 'function') onbeforetoggle(d)
|
|
363
364
|
if (d.state.show === false) return
|
|
364
365
|
d.state.show = false
|
|
365
366
|
|
|
366
|
-
const { trigger
|
|
367
|
+
const { trigger } = d.nodes
|
|
367
368
|
trigger.setAttribute('aria-expanded', d.state.show)
|
|
369
|
+
trigger.setAttribute('data-show', d.state.show)
|
|
368
370
|
revertInert(d)
|
|
369
371
|
|
|
370
372
|
updateDisclosure(d)
|
|
371
373
|
|
|
372
374
|
// Dispatch a close event
|
|
373
375
|
// If check because we can close disclosure content so quickly in some implementations it hasn't been opened yet. Example: Combobox.
|
|
374
|
-
if (
|
|
376
|
+
if (typeof onclose === 'function') onclose(d)
|
|
377
|
+
if (typeof ontoggle === 'function') ontoggle(d)
|
|
378
|
+
// if (content) content.dispatchEvent(new CustomEvent('close'))
|
|
375
379
|
|
|
376
380
|
// If it's mouse out, we no need to change focus back to trigger. Only bring focus back to trigger when using keyboard events, and only when necessary
|
|
377
381
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<!-- <script>
|
|
2
2
|
import { splitObject } from '@splendidlabz/utils'
|
|
3
|
-
import { disclosureTrigger } from '../../Disclosure/disclosure.js'
|
|
3
|
+
import { disclosureTrigger } from '../../Disclosure/Disclosure/Old/disclosure.jsd/disclosure.js'
|
|
4
4
|
import TextInput from '../TextInput.svelte'
|
|
5
5
|
import {
|
|
6
6
|
AUTOCOMPLETE_INPUT_OPT_KEYS,
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
],
|
|
61
61
|
]}
|
|
62
62
|
{...$$restProps}
|
|
63
|
-
/>
|
|
63
|
+
/> -->
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<!-- <script>
|
|
2
2
|
import { splitObject } from '@splendidlabz/utils'
|
|
3
3
|
import PopoverContent from '../../Disclosure/Popover/PopoverContent.svelte'
|
|
4
4
|
import {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
matches = Box.state.matches
|
|
33
33
|
searchState = Box.state.searchState
|
|
34
34
|
}
|
|
35
|
-
</script>
|
|
35
|
+
</script> -->
|
|
36
36
|
|
|
37
|
-
<PopoverContent
|
|
37
|
+
<!-- <PopoverContent
|
|
38
38
|
{id}
|
|
39
39
|
class="AutocompleteOptions ListboxPopover {klass}"
|
|
40
40
|
options={opts}
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
</div>
|
|
68
68
|
{/if}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
No results found. Optional
|
|
71
71
|
{#if searchState === 'complete' && matches.length === 0}
|
|
72
72
|
<div class="Card AutocompleteEmpty"><slot name="no-results"></slot></div>
|
|
73
73
|
{/if}
|
|
74
|
-
</PopoverContent>
|
|
74
|
+
</PopoverContent> -->
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<!-- <script>
|
|
2
2
|
import { splitObject } from '@splendidlabz/utils'
|
|
3
3
|
import {
|
|
4
4
|
DISCLOSURE_TRIGGER_OPT_KEYS,
|
|
5
5
|
disclosureTrigger,
|
|
6
|
-
} from '../../Disclosure/disclosure.js'
|
|
6
|
+
} from '../../Disclosure/Disclosure/Old/disclosure.jsd/disclosure.js'
|
|
7
7
|
import Hidden from '../Hidden.svelte'
|
|
8
8
|
import TextInput from '../TextInput.svelte'
|
|
9
9
|
import { comboboxes } from './combobox-store.js'
|
|
@@ -42,19 +42,19 @@
|
|
|
42
42
|
|
|
43
43
|
let Box
|
|
44
44
|
$: Box = $comboboxes.find(c => c.id === listboxId)
|
|
45
|
-
</script>
|
|
45
|
+
</script> -->
|
|
46
46
|
|
|
47
47
|
<!-- This is what gets submitted -->
|
|
48
|
-
<Hidden
|
|
48
|
+
<!-- <Hidden
|
|
49
49
|
{name}
|
|
50
50
|
label="To be sent"
|
|
51
51
|
listbox-id={listboxId}
|
|
52
52
|
bind:ref={hiddenRef}
|
|
53
53
|
actions={[comboboxAssociatedInput]}
|
|
54
|
-
/>
|
|
54
|
+
/> -->
|
|
55
55
|
|
|
56
56
|
<!-- We cannot use type="time" because the appearance cannot be hijacked. To compensate, we added a hidden field that submits what an actual time input would submit. This TextInput is to give the appearance of a time input -->
|
|
57
|
-
<TextInput
|
|
57
|
+
<!-- <TextInput
|
|
58
58
|
type="text"
|
|
59
59
|
class="TimepickerInput {klass}"
|
|
60
60
|
name={name + '-displayed'}
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
],
|
|
71
71
|
]}
|
|
72
72
|
{...$$restProps}
|
|
73
|
-
/>
|
|
73
|
+
/> -->
|
|
74
74
|
|
|
75
75
|
<!-- Meh? How to include the button thingy? -->
|
|
76
76
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<!-- <script>
|
|
2
2
|
import { splitObject } from '@splendidlabz/utils'
|
|
3
3
|
import PopoverContent from '../../Disclosure/Popover/PopoverContent.svelte'
|
|
4
4
|
import Checkboxes from '../Checkboxes.svelte'
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
const showHours = opts.format.includes('HH')
|
|
45
45
|
const showMinutes = opts.format.includes('mm')
|
|
46
46
|
const showSeconds = opts.format.includes('ss')
|
|
47
|
-
</script>
|
|
47
|
+
</script> -->
|
|
48
48
|
|
|
49
|
-
<PopoverContent
|
|
49
|
+
<!-- <PopoverContent
|
|
50
50
|
{id}
|
|
51
51
|
options={opts}
|
|
52
52
|
class="TimepickerOptions ListboxPopover {klass}"
|
|
53
53
|
>
|
|
54
54
|
{#if mode === 'list' && selection === 'single'}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
This doesn't close the popover yet
|
|
56
|
+
Need some action to determine when to close the popover
|
|
57
57
|
<Radios
|
|
58
58
|
class="Timepicker {klass}"
|
|
59
59
|
legend="Time"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
{/if}
|
|
64
64
|
|
|
65
65
|
{#if mode === 'list' && selection === 'multiple'}
|
|
66
|
-
|
|
66
|
+
This doesn't close the popover yet
|
|
67
67
|
<Checkboxes class="Timepicker {klass}" legend="Time" checkboxes={timings}
|
|
68
68
|
></Checkboxes>
|
|
69
69
|
{/if}
|
|
@@ -97,4 +97,4 @@
|
|
|
97
97
|
{/if}
|
|
98
98
|
</ul>
|
|
99
99
|
{/if}
|
|
100
|
-
</PopoverContent>
|
|
100
|
+
</PopoverContent> -->
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
close as closeDisclosure,
|
|
13
13
|
open as openDisclosure,
|
|
14
|
-
} from '../../
|
|
14
|
+
} from '../../DisclosureOld/disclosure.js'
|
|
15
15
|
import {
|
|
16
16
|
getMatches,
|
|
17
17
|
getPropertyMatches,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from './autocomplete-matching.js'
|
|
21
21
|
import { initCombobox, updateCombobox } from './combobox-store.js'
|
|
22
22
|
|
|
23
|
-
import { getDisclosure } from '../../
|
|
23
|
+
import { getDisclosure } from '../../DisclosureOld/disclosure-store.js'
|
|
24
24
|
|
|
25
25
|
// Shifted focusTriggerOnClose to disclosureContent
|
|
26
26
|
export const DEFAULT_AUTOCOMPLETE_INPUT_OPTS = {
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
close as closeDisclosure,
|
|
12
12
|
open as openDisclosure,
|
|
13
|
-
} from '../../
|
|
13
|
+
} from '../../DisclosureOld/disclosure.js'
|
|
14
14
|
import { initCombobox, updateCombobox } from './combobox-store.js'
|
|
15
15
|
|
|
16
|
-
import { getDisclosure } from '../../Disclosure/disclosure-store.js'
|
|
17
16
|
import { omitEmpty } from '@splendidlabz/utils'
|
|
17
|
+
import { getDisclosure } from '../../DisclosureOld/disclosure-store.js'
|
|
18
18
|
|
|
19
19
|
// Shifted focusTriggerOnClose to disclosureContent
|
|
20
20
|
export const DEFAULT_COMBOBOX_INPUT_OPTIONS = {
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
/**
|
|
3
|
+
* Inline SVG renderer for files under `/src/svg` or `/src/svgs`.
|
|
4
|
+
*
|
|
5
|
+
* - Renders the raw SVG content via `import.meta.glob` lookups.
|
|
6
|
+
* - No slot support; `children` is intentionally dropped.
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @example
|
|
10
|
+
* <!-- Renders /src/svg/logo.svg -->
|
|
11
|
+
* <SVG icon="logo" class="w-6 h-6" />
|
|
12
|
+
* @example
|
|
13
|
+
* <!-- Use DOM parser when the SVG needs runtime DOM APIs -->
|
|
14
|
+
* <SVG icon="spinner" parser="dom" style={{ color: 'rebeccapurple' }} />
|
|
15
|
+
* @throws {Error} icon property is required
|
|
16
|
+
* @throws {Error} When the requested SVG file cannot be found
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} SVGProps
|
|
21
|
+
* @property {string} icon - Basename of the SVG file (without .svg)
|
|
22
|
+
* @property {object|string} [style] - Inline styles. Object is converted with `toStyleString`
|
|
23
|
+
* @property {"naive"|"dom"} [parser="naive"] - Parsing strategy
|
|
24
|
+
* @property {*} [children] - Ignored; component does not support slots
|
|
25
|
+
*/
|
|
2
26
|
import { toStyleString } from '@splendidlabz/utils'
|
|
3
27
|
import { onMount } from 'svelte'
|
|
4
28
|
import { domParser, naiveParser } from './parser.js'
|
|
29
|
+
/** @type {SVGProps} */
|
|
5
30
|
const {
|
|
6
31
|
icon,
|
|
7
32
|
style,
|
|
@@ -45,5 +70,26 @@
|
|
|
45
70
|
}
|
|
46
71
|
</script>
|
|
47
72
|
|
|
73
|
+
<!--
|
|
74
|
+
@component
|
|
75
|
+
Inline SVG renderer for files under `/src/svg` or `/src/svgs`.
|
|
76
|
+
|
|
77
|
+
- Props:
|
|
78
|
+
- icon (string, required): Basename of the SVG file (without .svg)
|
|
79
|
+
- style (object|string, optional): Inline styles; objects are converted with `toStyleString`
|
|
80
|
+
- parser ("naive"|"dom", optional, default "naive"): Parsing strategy
|
|
81
|
+
- Slots: none
|
|
82
|
+
- Events: none
|
|
83
|
+
- Errors:
|
|
84
|
+
- Throws if `icon` is missing
|
|
85
|
+
- Throws if the SVG file cannot be found
|
|
86
|
+
|
|
87
|
+
Usage:
|
|
88
|
+
```svelte
|
|
89
|
+
<SVG icon="logo" class="w-6 h-6" />
|
|
90
|
+
<SVG icon="spinner" parser="dom" style={{ color: 'rebeccapurple' }} />
|
|
91
|
+
```
|
|
92
|
+
-->
|
|
93
|
+
|
|
48
94
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
49
95
|
{@html svg}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
const {
|
|
3
|
+
id,
|
|
4
|
+
angle,
|
|
5
|
+
stops = 2, // Or an array with the actual stop percentages
|
|
6
|
+
} = $props()
|
|
7
|
+
|
|
8
|
+
const _stops = (Array.isArray(stops) ? stops : Array(stops).fill({})).map(
|
|
9
|
+
(stop, index) => ({
|
|
10
|
+
offset: stop.offset || `${(index * 100) / (stops - 1)}%`,
|
|
11
|
+
'stop-color': stop.color || `var(--gradient-stop-${index + 1})`,
|
|
12
|
+
}),
|
|
13
|
+
)
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<!-- Inspiration -->
|
|
17
|
+
<!-- https://fvsch.com/svg-gradient-fill -->
|
|
18
|
+
<svg
|
|
19
|
+
style="position:absolute; width:0; height:0; overflow:hidden"
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
focusable="false"
|
|
22
|
+
height="0"
|
|
23
|
+
width="0"
|
|
24
|
+
>
|
|
25
|
+
<defs>
|
|
26
|
+
<linearGradient
|
|
27
|
+
{id}
|
|
28
|
+
gradientTransform="rotate({angle} 0.5 0.5)"
|
|
29
|
+
x2="0"
|
|
30
|
+
y1="1"
|
|
31
|
+
>
|
|
32
|
+
{#each _stops as stop (stop.offset)}
|
|
33
|
+
<stop {...stop}></stop>
|
|
34
|
+
{/each}
|
|
35
|
+
</linearGradient>
|
|
36
|
+
</defs>
|
|
37
|
+
</svg>
|
package/components/SVG/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splendidlabz/svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"scripts": {
|
|
7
7
|
"lint": "eslint . --fix",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@floating-ui/dom": "^1.6.13",
|
|
23
23
|
"@iconify/svelte": "^4.2.0",
|
|
24
|
-
"@splendidlabz/styles": "4.
|
|
25
|
-
"@splendidlabz/utils": "1.
|
|
24
|
+
"@splendidlabz/styles": "4.3.1",
|
|
25
|
+
"@splendidlabz/utils": "1.9.0",
|
|
26
26
|
"autosuggest-highlight": "^3.3.4",
|
|
27
27
|
"lodash-es": "^4.17.21",
|
|
28
28
|
"node-html-parser": "^7.0.1"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
// TODO: Move to Utils/Dom
|
|
3
|
-
// Components to update before switching: Switcheroo, Masonry
|
|
4
|
-
// Can also use breakpointsObserver for Switcheroo instead.
|
|
5
|
-
import { notEmpty } from '@splendidlabz/utils'
|
|
6
|
-
|
|
7
|
-
export function resizeObserver(node, options) {
|
|
8
|
-
// We set the option here to prevent observer from being created unless necessary.
|
|
9
|
-
if (!options.observe) return
|
|
10
|
-
|
|
11
|
-
const observer = new ResizeObserver(observerFn)
|
|
12
|
-
|
|
13
|
-
function observerFn(entries) {
|
|
14
|
-
for (const entry of entries) {
|
|
15
|
-
if (options.callback) {
|
|
16
|
-
options.callback({ node, entry, observer })
|
|
17
|
-
} else {
|
|
18
|
-
node.dispatchEvent(
|
|
19
|
-
new CustomEvent('resize', {
|
|
20
|
-
detail: { node, entry, observer },
|
|
21
|
-
}),
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
observer.observe(node)
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
destroy() {
|
|
31
|
-
observer.unobserve(node)
|
|
32
|
-
},
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Need to change Switcheroo before we remove this.
|
|
37
|
-
export function createBreakpointArray(breakpoints) {
|
|
38
|
-
if (notEmpty(breakpoints)) {
|
|
39
|
-
return Object.entries(breakpoints).map(([key, value]) => {
|
|
40
|
-
return { breakpoint: parseFloat(key), value }
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
|
|
3
|
-
// TODO: Move to Utils/Dom
|
|
4
|
-
/**
|
|
5
|
-
* Scroll Observer
|
|
6
|
-
* @param {Number} threshold Float between 0 to 1. When to fire a threshold event.
|
|
7
|
-
* @param {Number} tolerance Float between 0 to 1. Tolerance for event firing.
|
|
8
|
-
*/
|
|
9
|
-
export function scrollObserver(
|
|
10
|
-
node,
|
|
11
|
-
{
|
|
12
|
-
threshold = 0, // Float between 0 to 1.
|
|
13
|
-
tolerance = 0.1, // Float between 0 to 1. Tolerance for event firing
|
|
14
|
-
} = {},
|
|
15
|
-
) {
|
|
16
|
-
let prevScrollTop = 0
|
|
17
|
-
|
|
18
|
-
function observe(event) {
|
|
19
|
-
const { documentElement } = document
|
|
20
|
-
const scrollTop = documentElement.scrollTop
|
|
21
|
-
const scrollDirection = scrollTop > prevScrollTop ? 'down' : 'up'
|
|
22
|
-
const scrollPercent =
|
|
23
|
-
scrollTop / (documentElement.scrollHeight - documentElement.clientHeight)
|
|
24
|
-
|
|
25
|
-
if (scrollDirection === 'down') {
|
|
26
|
-
node.dispatchEvent(new CustomEvent('scrolldown'))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (scrollDirection === 'up') {
|
|
30
|
-
node.dispatchEvent(new CustomEvent('scrollUp'))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (scrollPercent > threshold && scrollPercent < threshold + tolerance) {
|
|
34
|
-
node.dispatchEvent(new CustomEvent(`${scrollDirection}:threshold`))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
prevScrollTop = scrollTop
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
node.addEventListener('scroll', observe)
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
destroy() {
|
|
44
|
-
node.removeEventListener('scroll', observe)
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Icon from '../../Icon/Icon.svelte'
|
|
3
|
-
|
|
4
|
-
let { ref = $bindable(null), ...p } = $props()
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
class: klass = '',
|
|
8
|
-
icon = 'tabler:x',
|
|
9
|
-
iconClass = '',
|
|
10
|
-
target = null,
|
|
11
|
-
children,
|
|
12
|
-
...rest
|
|
13
|
-
} = p
|
|
14
|
-
|
|
15
|
-
const targetAction = target ? 'hide' : null
|
|
16
|
-
|
|
17
|
-
function closeDrawer() {
|
|
18
|
-
const popover =
|
|
19
|
-
document.querySelector(`[#"${target}"]`) || ref.closest('[popover]')
|
|
20
|
-
popover.hidePopover()
|
|
21
|
-
}
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<button
|
|
25
|
-
{...rest}
|
|
26
|
-
aria-label="Close"
|
|
27
|
-
class="button-icon {klass}"
|
|
28
|
-
popovertarget={target}
|
|
29
|
-
popovertargetaction={targetAction}
|
|
30
|
-
bind:this={ref}
|
|
31
|
-
onclick={closeDrawer}
|
|
32
|
-
>
|
|
33
|
-
{#if children}
|
|
34
|
-
{@render children()}
|
|
35
|
-
{:else}
|
|
36
|
-
<Icon class={iconClass} {icon} />
|
|
37
|
-
{/if}
|
|
38
|
-
</button>
|