@splendidlabz/svelte 4.4.0 → 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 +14 -0
- package/components/Disclosure/Disclosure/DisclosureContent.svelte +1 -1
- package/components/Disclosure/Disclosure/DisclosureTrigger.svelte +30 -3
- 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 -1
- 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/{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 +3 -0
- 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/package.json +3 -3
- package/components/Disclosure/DrawerNew/DrawerCloseButton.svelte +0 -21
- package/components/Disclosure/DrawerNew/DrawerContent.svelte +0 -75
- package/components/Disclosure/DrawerNew/DrawerTrigger.svelte +0 -18
- 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 -78
- 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/Disclosure → DisclosureOld}/Old/DisclosureContentOld.svelte +0 -0
- /package/components/{Disclosure/Disclosure → DisclosureOld}/Old/DisclosureTriggerOld.svelte +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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { splitObject } from '@splendidlabz/utils'
|
|
3
|
+
import { mergeOpts } from '../../../utils'
|
|
4
|
+
import {
|
|
5
|
+
TRANSITION_OPT_KEYS,
|
|
6
|
+
applyTransition,
|
|
7
|
+
} from '../../../utils/transitions.js'
|
|
8
|
+
import DisclosureContent from '../Disclosure/DisclosureContent.svelte'
|
|
9
|
+
import { MODAL_CONTENT_OPTS } from './modal.js'
|
|
10
|
+
|
|
11
|
+
let { ref = $bindable(null), ...p } = $props()
|
|
12
|
+
const opts = mergeOpts(MODAL_CONTENT_OPTS, p)
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
class: klass = '',
|
|
16
|
+
backdrop,
|
|
17
|
+
backdropClass,
|
|
18
|
+
blurBackdrop,
|
|
19
|
+
...rest
|
|
20
|
+
} = opts
|
|
21
|
+
|
|
22
|
+
const { picked: transitionOpts } = splitObject(rest, TRANSITION_OPT_KEYS)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
{#snippet modalBackdrop()}
|
|
26
|
+
<div
|
|
27
|
+
class="modal-backdrop {backdropClass} "
|
|
28
|
+
class:backdrop-blur={backdrop && blurBackdrop}
|
|
29
|
+
transition:applyTransition|global={{
|
|
30
|
+
...transitionOpts,
|
|
31
|
+
transition: 'fade',
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{@render modalContent()}
|
|
35
|
+
</div>
|
|
36
|
+
{/snippet}
|
|
37
|
+
|
|
38
|
+
{#snippet modalContent()}
|
|
39
|
+
<DisclosureContent class="modal-content {klass}" bind:ref {...rest} />
|
|
40
|
+
{/snippet}
|
|
41
|
+
|
|
42
|
+
{@render modalBackdrop()}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { splitObject } from '@splendidlabz/utils'
|
|
3
|
+
import { hasAccessibleName } from '@splendidlabz/utils/dom'
|
|
4
|
+
import * as easing from 'svelte/easing'
|
|
5
|
+
import { fade } from 'svelte/transition'
|
|
6
|
+
import Portal from '../../Portal.svelte'
|
|
7
|
+
import { disclosures } from '../disclosure-store.js'
|
|
8
|
+
import {
|
|
9
|
+
DISCLOSURE_CONTENT_OPT_KEYS,
|
|
10
|
+
disclosureContent,
|
|
11
|
+
} from '../Disclosure/Old/disclosure.jsd/disclosure.js'
|
|
12
|
+
import { FLOATING_CONTENT_OPT_KEYS, floatingContent } from './floating.js'
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_POPOVER_CONTENT_OPTS,
|
|
15
|
+
DEFAULT_POPOVER_TRANSITION_OPTS,
|
|
16
|
+
} from './popover.js'
|
|
17
|
+
|
|
18
|
+
let klass = ''
|
|
19
|
+
export { klass as class }
|
|
20
|
+
|
|
21
|
+
export let id
|
|
22
|
+
export let role = 'dialog'
|
|
23
|
+
export let ariaLabel = $$restProps['aria-label']
|
|
24
|
+
export let ariaLabelledBy = $$restProps['aria-labelledby']
|
|
25
|
+
export let ariaDescribedBy = $$restProps['aria-describedby']
|
|
26
|
+
export let options = {}
|
|
27
|
+
|
|
28
|
+
if (!hasAccessibleName(ariaLabel, ariaLabelledBy)) {
|
|
29
|
+
console.warn(
|
|
30
|
+
`PopoverContent (with id: ${id}) should have an accessible name. Please create one with aria-label or aria-labelledby.`,
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const opts = {
|
|
35
|
+
...DEFAULT_POPOVER_CONTENT_OPTS.disclosure,
|
|
36
|
+
...DEFAULT_POPOVER_CONTENT_OPTS.popover,
|
|
37
|
+
...DEFAULT_POPOVER_TRANSITION_OPTS,
|
|
38
|
+
...options,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { picked: disclosureOpts } = splitObject(
|
|
42
|
+
opts,
|
|
43
|
+
DISCLOSURE_CONTENT_OPT_KEYS,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
const { picked: floatingOpts } = splitObject(opts, FLOATING_CONTENT_OPT_KEYS)
|
|
47
|
+
const { picked: transitionOpts } = splitObject(
|
|
48
|
+
opts,
|
|
49
|
+
Object.keys(DEFAULT_POPOVER_TRANSITION_OPTS),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
transitionOpts.easing = easing[transitionOpts.easing]
|
|
53
|
+
|
|
54
|
+
const { portal } = opts
|
|
55
|
+
let d
|
|
56
|
+
$: d = $disclosures.find(d => d.id === id)
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
{#if d?.state.show}
|
|
60
|
+
{#if portal}
|
|
61
|
+
<Portal>
|
|
62
|
+
<div
|
|
63
|
+
{id}
|
|
64
|
+
{role}
|
|
65
|
+
tabindex="-1"
|
|
66
|
+
class={`PopoverContent ${klass}`}
|
|
67
|
+
use:floatingContent={floatingOpts}
|
|
68
|
+
use:disclosureContent={{ options: disclosureOpts }}
|
|
69
|
+
on:open
|
|
70
|
+
on:close
|
|
71
|
+
transition:fade={transitionOpts}
|
|
72
|
+
aria-label={ariaLabel}
|
|
73
|
+
aria-labelledby={ariaLabelledBy}
|
|
74
|
+
aria-describedby={ariaDescribedBy}
|
|
75
|
+
{...$$restProps}
|
|
76
|
+
>
|
|
77
|
+
<slot />
|
|
78
|
+
{#if floatingOpts.arrow}
|
|
79
|
+
<div class="PopoverArrow"></div>
|
|
80
|
+
{/if}
|
|
81
|
+
</div>
|
|
82
|
+
</Portal>
|
|
83
|
+
{:else}
|
|
84
|
+
<div
|
|
85
|
+
{id}
|
|
86
|
+
{role}
|
|
87
|
+
tabindex="-1"
|
|
88
|
+
class={`PopoverContent ${klass}`}
|
|
89
|
+
use:floatingContent={floatingOpts}
|
|
90
|
+
use:disclosureContent={{ options: disclosureOpts }}
|
|
91
|
+
on:open
|
|
92
|
+
on:close
|
|
93
|
+
transition:fade={transitionOpts}
|
|
94
|
+
aria-label={ariaLabel}
|
|
95
|
+
aria-labelledby={ariaLabelledBy}
|
|
96
|
+
aria-describedby={ariaDescribedBy}
|
|
97
|
+
{...$$restProps}
|
|
98
|
+
>
|
|
99
|
+
<slot />
|
|
100
|
+
{#if floatingOpts.arrow}
|
|
101
|
+
<div class="PopoverArrow"></div>
|
|
102
|
+
{/if}
|
|
103
|
+
</div>
|
|
104
|
+
{/if}
|
|
105
|
+
{/if}
|
|
106
|
+
|
|
107
|
+
<!-- transition:custom={transitionOptions} -->
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { isInvalidAriaPopup } from '@splendidlabz/utils/dom'
|
|
3
|
+
import { disclosureTrigger } from '../Disclosure/Old/disclosure.jsd/disclosure.js'
|
|
4
|
+
import { DEFAULT_POPOVER_TRIGGER_OPTS } from './popover.js'
|
|
5
|
+
|
|
6
|
+
let klass = ''
|
|
7
|
+
export { klass as class }
|
|
8
|
+
|
|
9
|
+
export let target
|
|
10
|
+
export let show = false
|
|
11
|
+
export let ariaPopup = $$restProps['aria-haspopup'] || 'dialog'
|
|
12
|
+
export let options = {}
|
|
13
|
+
|
|
14
|
+
// Prevent invalid aria-haspopup values
|
|
15
|
+
if (isInvalidAriaPopup(ariaPopup)) ariaPopup = undefined
|
|
16
|
+
|
|
17
|
+
const opts = {
|
|
18
|
+
...DEFAULT_POPOVER_TRIGGER_OPTS,
|
|
19
|
+
...options,
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<button
|
|
24
|
+
{target}
|
|
25
|
+
class="Button PopoverTrigger {klass}"
|
|
26
|
+
aria-haspopup={ariaPopup}
|
|
27
|
+
aria-details={target}
|
|
28
|
+
use:disclosureTrigger={{ state: { show }, options: opts }}
|
|
29
|
+
{...$$restProps}
|
|
30
|
+
on:click
|
|
31
|
+
>
|
|
32
|
+
<slot />
|
|
33
|
+
</button>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
arrow,
|
|
3
|
+
autoUpdate,
|
|
4
|
+
computePosition,
|
|
5
|
+
flip,
|
|
6
|
+
offset,
|
|
7
|
+
shift,
|
|
8
|
+
} from '@floating-ui/dom'
|
|
9
|
+
import { mix, splitUnit } from '@splendidlabz/utils'
|
|
10
|
+
import { em, rem } from '@splendidlabz/utils/dom'
|
|
11
|
+
|
|
12
|
+
// TODO: Add inline for tooltips
|
|
13
|
+
export const DEFAULT_FLOATING_CONTENT_OPTS = {
|
|
14
|
+
placement: 'top',
|
|
15
|
+
strategy: 'absolute',
|
|
16
|
+
offset: '0.5rem',
|
|
17
|
+
arrow: false,
|
|
18
|
+
arrowWidth: '0.6rem',
|
|
19
|
+
arrowDelta: 0,
|
|
20
|
+
inline: false,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const FLOATING_CONTENT_OPT_KEYS = Object.keys(
|
|
24
|
+
DEFAULT_FLOATING_CONTENT_OPTS,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
export function floatingContent(node, options) {
|
|
28
|
+
const floatingNode = node
|
|
29
|
+
const referenceNode = document.querySelector(`[target="${node.id}"]`)
|
|
30
|
+
let arrowNode
|
|
31
|
+
|
|
32
|
+
options = mix(DEFAULT_FLOATING_CONTENT_OPTS, options)
|
|
33
|
+
|
|
34
|
+
if (options.arrow) {
|
|
35
|
+
arrowNode = node.querySelector('.PopoverArrow')
|
|
36
|
+
arrowNode.style.width = calculateArrowWidth(options.arrowWidth) + 'px'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const offsetValue = calculateOffsetValue({ ...options, arrowNode })
|
|
40
|
+
|
|
41
|
+
options.middleware = [
|
|
42
|
+
offset(offsetValue),
|
|
43
|
+
// options.middleware.push(inline()), // Should be placed here. Padding option might be useful.
|
|
44
|
+
flip({ fallbackAxisSideDirection: 'start' }),
|
|
45
|
+
shift(),
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
if (options.arrow) {
|
|
49
|
+
options.middleware.push(arrow({ element: arrowNode }))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
autoUpdate(referenceNode, floatingNode, () => {
|
|
53
|
+
computePosition(referenceNode, floatingNode, options).then(
|
|
54
|
+
middlewareState => {
|
|
55
|
+
const { x, y } = middlewareState
|
|
56
|
+
// Position Popover
|
|
57
|
+
Object.assign(floatingNode.style, {
|
|
58
|
+
left: `${x}px`,
|
|
59
|
+
top: `${y}px`,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
if (options.arrow) {
|
|
63
|
+
const arrowPosStyle = calculateArrowPosition({
|
|
64
|
+
middlewareState,
|
|
65
|
+
floatingNode,
|
|
66
|
+
arrowNode,
|
|
67
|
+
arrowDelta: options.arrowDelta,
|
|
68
|
+
})
|
|
69
|
+
Object.assign(arrowNode.style, arrowPosStyle)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function calculateOffsetValue({ offset, arrow, arrowNode }) {
|
|
77
|
+
// SSR Ready
|
|
78
|
+
if (typeof window === 'undefined') return
|
|
79
|
+
if (!offset) offset = 0
|
|
80
|
+
|
|
81
|
+
const [value, unit] = splitUnit(offset)
|
|
82
|
+
|
|
83
|
+
let finalValue = 0
|
|
84
|
+
|
|
85
|
+
if (unit === 'rem') finalValue = value * rem()
|
|
86
|
+
if (unit === 'em') finalValue = value * em()
|
|
87
|
+
if (unit === 'px') finalValue = value
|
|
88
|
+
if (!unit) finalValue = value // Default to px offsets
|
|
89
|
+
|
|
90
|
+
if (!arrow) return finalValue
|
|
91
|
+
|
|
92
|
+
// Arrow Offset compensation
|
|
93
|
+
const arrowWidth = arrowNode.offsetWidth
|
|
94
|
+
const half = arrowWidth / 2
|
|
95
|
+
const arrowOffsetCompensation = Math.floor(Math.sqrt(half * half * 2))
|
|
96
|
+
|
|
97
|
+
return finalValue + arrowOffsetCompensation
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function calculateArrowWidth(givenWidth) {
|
|
101
|
+
const remValue = rem()
|
|
102
|
+
const [value, unit] = splitUnit(givenWidth)
|
|
103
|
+
let finalValue = 0
|
|
104
|
+
|
|
105
|
+
if (unit === 'rem') finalValue = value * remValue
|
|
106
|
+
if (unit === 'px') finalValue = value
|
|
107
|
+
if (!unit) finalValue = value // Default to px offsets
|
|
108
|
+
|
|
109
|
+
return finalValue
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function calculateArrowPosition({
|
|
113
|
+
middlewareState,
|
|
114
|
+
floatingNode,
|
|
115
|
+
arrowNode,
|
|
116
|
+
arrowDelta,
|
|
117
|
+
}) {
|
|
118
|
+
const { placement, middlewareData } = middlewareState
|
|
119
|
+
|
|
120
|
+
let x = middlewareData.arrow?.x
|
|
121
|
+
let y = middlewareData.arrow?.y
|
|
122
|
+
|
|
123
|
+
const staticSide = {
|
|
124
|
+
top: 'bottom',
|
|
125
|
+
right: 'left',
|
|
126
|
+
bottom: 'top',
|
|
127
|
+
left: 'right',
|
|
128
|
+
}[placement.split('-')[0]]
|
|
129
|
+
|
|
130
|
+
// Calculates arrow direction
|
|
131
|
+
let rotate = 45
|
|
132
|
+
// prettier-ignore
|
|
133
|
+
switch (staticSide) {
|
|
134
|
+
case 'top': rotate = 45; break;
|
|
135
|
+
case 'right': rotate = 135; break;
|
|
136
|
+
case 'bottom': rotate = 225; break;
|
|
137
|
+
case 'left': rotate = 315; break;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Calculates maximum X and Y on cross-axis
|
|
141
|
+
const { width, height } = floatingNode.getBoundingClientRect()
|
|
142
|
+
const borderRadius = parseFloat(getComputedStyle(floatingNode).borderRadius)
|
|
143
|
+
const borderWidth = parseFloat(getComputedStyle(floatingNode).borderWidth)
|
|
144
|
+
const arrowWidth = arrowNode.offsetWidth
|
|
145
|
+
|
|
146
|
+
if (x || x === 0) {
|
|
147
|
+
const startEdge = borderRadius
|
|
148
|
+
const endEdge = width - borderRadius - arrowWidth
|
|
149
|
+
|
|
150
|
+
if (x <= startEdge) x = startEdge
|
|
151
|
+
if (x >= endEdge) x = endEdge
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (y || y === 0) {
|
|
155
|
+
const startEdge = borderRadius
|
|
156
|
+
const endEdge = height - borderRadius - arrowWidth
|
|
157
|
+
|
|
158
|
+
if (y <= startEdge) y = startEdge
|
|
159
|
+
if (y >= endEdge) y = endEdge
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Centers the arrow on the static side
|
|
163
|
+
const staticSideOffset = Math.round((arrowNode.offsetWidth + borderWidth) / 2)
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
left: x != null ? `${x}px` : '',
|
|
167
|
+
top: y != null ? `${y}px` : '',
|
|
168
|
+
[staticSide]: `-${staticSideOffset + arrowDelta}px`,
|
|
169
|
+
transform: `rotate(${rotate}deg)`,
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<script>
|
|
4
4
|
import { disclosures, initDisclosure } from '../disclosure-store.js'
|
|
5
|
-
import { disclosureTrigger } from '../disclosure.js'
|
|
5
|
+
import { disclosureTrigger } from '../Disclosure/Old/disclosure.jsd/disclosure.js'
|
|
6
6
|
import { defaultTooltipTriggerOpts } from './tooltip.js'
|
|
7
7
|
|
|
8
8
|
// let klass
|
|
@@ -88,6 +88,7 @@ export function disclosureTrigger(node, props = {}) {
|
|
|
88
88
|
|
|
89
89
|
const d = initDisclosure(disclosureInfo)
|
|
90
90
|
node.setAttribute('aria-expanded', d.state.show)
|
|
91
|
+
node.setAttribute('data-show', d.state.show)
|
|
91
92
|
|
|
92
93
|
const listeners = [
|
|
93
94
|
{
|
|
@@ -346,6 +347,7 @@ export function open(d) {
|
|
|
346
347
|
d.state.show = true
|
|
347
348
|
const { trigger } = d.nodes
|
|
348
349
|
trigger.setAttribute('aria-expanded', d.state.show)
|
|
350
|
+
trigger.setAttribute('data-show', d.state.show)
|
|
349
351
|
|
|
350
352
|
if (d.options.closeOthers) closeOthersExcept(d.id)
|
|
351
353
|
|
|
@@ -364,6 +366,7 @@ export function close(d, { shouldFocusTrigger = false } = {}) {
|
|
|
364
366
|
|
|
365
367
|
const { trigger } = d.nodes
|
|
366
368
|
trigger.setAttribute('aria-expanded', d.state.show)
|
|
369
|
+
trigger.setAttribute('data-show', d.state.show)
|
|
367
370
|
revertInert(d)
|
|
368
371
|
|
|
369
372
|
updateDisclosure(d)
|
|
@@ -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 = {
|
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.3.
|
|
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,21 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getEntry } from '../../../actions/sync.svelte.js'
|
|
3
|
-
import ModalClose from '../ModalNew/ModalClose.svelte'
|
|
4
|
-
import PopoverClose from '../PopoverNew/PopoverClose.svelte'
|
|
5
|
-
|
|
6
|
-
const { class: klass = '', target, ...p } = $props()
|
|
7
|
-
|
|
8
|
-
let sync = $derived(getEntry(target))
|
|
9
|
-
let type = $derived(sync?.type)
|
|
10
|
-
|
|
11
|
-
const propsToPass = {
|
|
12
|
-
target,
|
|
13
|
-
class: `drawer-close-button ${klass}`,
|
|
14
|
-
}
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
{#if type === 'popover'}
|
|
18
|
-
<PopoverClose {...propsToPass} {...p} />
|
|
19
|
-
{:else}
|
|
20
|
-
<ModalClose {...propsToPass} {...p} />
|
|
21
|
-
{/if}
|