@splendidlabz/svelte 4.4.0 → 4.5.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/CHANGELOG.md +29 -0
- package/components/Accordion/Accordion.svelte +3 -2
- 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 +16 -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 +1 -2
- package/components/Disclosure/Modal/ModalCloseButton.svelte +39 -4
- package/components/Disclosure/Modal/ModalContent.svelte +122 -32
- package/components/Disclosure/Modal/ModalTrigger.svelte +63 -6
- package/components/Disclosure/Popover/PopoverCloseButton.svelte +28 -19
- 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 +1 -1
- 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/ModalCloseButton.svelte +7 -0
- 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/Popover/PopoverCloseButton.svelte +32 -0
- 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/ModalClose.svelte +0 -42
- 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/PopoverClose.svelte +0 -38
- 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/{PopoverNew → Popover}/Popover.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/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
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
arrow as arrowFn,
|
|
3
|
-
autoUpdate,
|
|
4
|
-
computePosition,
|
|
5
|
-
flip,
|
|
6
|
-
offset as offsetFn,
|
|
7
|
-
shift,
|
|
8
|
-
} from '@floating-ui/dom'
|
|
9
|
-
import { mix, splitUnit, toRadians } from '@splendidlabz/utils'
|
|
10
|
-
import { getCSSVar, setCSSVar, toPx } from '@splendidlabz/utils/dom'
|
|
11
|
-
|
|
12
|
-
// TODO: Add inline for tooltips
|
|
13
|
-
export const FLOATING_OPTS = {
|
|
14
|
-
placement: 'top',
|
|
15
|
-
strategy: 'absolute',
|
|
16
|
-
offset: '0',
|
|
17
|
-
arrow: false,
|
|
18
|
-
arrowHeight: 0,
|
|
19
|
-
arrowRadius: '5px',
|
|
20
|
-
boxStyle: 'standard', // standard, fancy
|
|
21
|
-
useReferenceBoundaries: false,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const FLOATING_OPTS_KEYS = Object.keys(FLOATING_OPTS)
|
|
25
|
-
|
|
26
|
-
export function initFloating(options) {
|
|
27
|
-
options = mix(FLOATING_OPTS, options)
|
|
28
|
-
const {
|
|
29
|
-
referenceNode,
|
|
30
|
-
floatingNode,
|
|
31
|
-
boxStyle,
|
|
32
|
-
arrow,
|
|
33
|
-
strategy,
|
|
34
|
-
placement,
|
|
35
|
-
arrowRadius,
|
|
36
|
-
offset: offsetValue,
|
|
37
|
-
} = options
|
|
38
|
-
let _cleanup = null
|
|
39
|
-
|
|
40
|
-
// Determine box style and apply styles as necessary.
|
|
41
|
-
applyBoxStyles(options)
|
|
42
|
-
|
|
43
|
-
// Get necessary values
|
|
44
|
-
const borderWidth = toPx(
|
|
45
|
-
getCSSVar(floatingNode, 'border-width'),
|
|
46
|
-
floatingNode,
|
|
47
|
-
)
|
|
48
|
-
const borderRadius = toPx(
|
|
49
|
-
getCSSVar(floatingNode, 'border-radius'),
|
|
50
|
-
floatingNode,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
// Create arrow node — used for both styles
|
|
54
|
-
const arrowNode = document.createElement('div')
|
|
55
|
-
const arrowClass = 'popover-content-arrow'
|
|
56
|
-
const arrowHeight = resolveArrowHeight(options)
|
|
57
|
-
const arrowWidth = getArrowWidth({ ...options, arrowHeight })
|
|
58
|
-
|
|
59
|
-
const arrowProps = {
|
|
60
|
-
arrow,
|
|
61
|
-
arrowNode,
|
|
62
|
-
arrowWidth,
|
|
63
|
-
arrowHeight,
|
|
64
|
-
arrowRadius,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
applyArrowStyles({ boxStyle, ...arrowProps })
|
|
68
|
-
arrowNode.classList.add(arrowClass)
|
|
69
|
-
if (arrow) floatingNode.appendChild(arrowNode)
|
|
70
|
-
|
|
71
|
-
// Calculate offset
|
|
72
|
-
const offset = calculateOffset({
|
|
73
|
-
floatingNode,
|
|
74
|
-
boxStyle,
|
|
75
|
-
arrow,
|
|
76
|
-
borderWidth,
|
|
77
|
-
offsetValue,
|
|
78
|
-
arrowHeight,
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
// Create floating options
|
|
82
|
-
const floatingOpts = {
|
|
83
|
-
strategy,
|
|
84
|
-
placement,
|
|
85
|
-
middleware: [
|
|
86
|
-
offsetFn(offset),
|
|
87
|
-
flip({ fallbackAxisSideDirection: 'start' }),
|
|
88
|
-
shift(),
|
|
89
|
-
arrow && arrowFn({ element: arrowNode }),
|
|
90
|
-
],
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
// Update floating position.
|
|
95
|
-
// Run when mounting.
|
|
96
|
-
update() {
|
|
97
|
-
_cleanup = autoUpdate(referenceNode, floatingNode, _ => {
|
|
98
|
-
computePosition(referenceNode, floatingNode, floatingOpts).then(
|
|
99
|
-
middlewareState => {
|
|
100
|
-
const { x, y } = middlewareState
|
|
101
|
-
|
|
102
|
-
// Position Popover
|
|
103
|
-
Object.assign(floatingNode.style, {
|
|
104
|
-
left: `${x}px`,
|
|
105
|
-
top: `${y}px`,
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
if (!arrow) return
|
|
109
|
-
|
|
110
|
-
// Position arrow
|
|
111
|
-
positionArrow({
|
|
112
|
-
...options,
|
|
113
|
-
...arrowProps,
|
|
114
|
-
borderWidth,
|
|
115
|
-
borderRadius,
|
|
116
|
-
middlewareState,
|
|
117
|
-
})
|
|
118
|
-
},
|
|
119
|
-
)
|
|
120
|
-
})
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
// Cleanup autoupdate.
|
|
124
|
-
// Run when dismounting.
|
|
125
|
-
cleanup() {
|
|
126
|
-
if (_cleanup) _cleanup()
|
|
127
|
-
},
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function applyBoxStyles({
|
|
132
|
-
referenceNode,
|
|
133
|
-
floatingNode,
|
|
134
|
-
strategy,
|
|
135
|
-
boxStyle,
|
|
136
|
-
placement,
|
|
137
|
-
arrow,
|
|
138
|
-
useReferenceBoundaries,
|
|
139
|
-
}) {
|
|
140
|
-
floatingNode.style.position = strategy
|
|
141
|
-
floatingNode.style.overflow = 'visible' // Users can specify max-height on the popover content to enable scrolling.
|
|
142
|
-
|
|
143
|
-
if (useReferenceBoundaries) {
|
|
144
|
-
const { width, height } = referenceNode.getBoundingClientRect()
|
|
145
|
-
|
|
146
|
-
if (['top', 'bottom'].includes(placement)) {
|
|
147
|
-
floatingNode.style.width = `${width}px`
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (['left', 'right'].includes(placement)) {
|
|
151
|
-
floatingNode.style.height = `${height}px`
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (boxStyle === 'fancy') {
|
|
156
|
-
if (!arrow) floatingNode.classList.add('fancybox')
|
|
157
|
-
else {
|
|
158
|
-
const side = getArrowSide(placement)
|
|
159
|
-
floatingNode.classList.add('fancybox-arrow', `arrow-${side}`)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function resolveArrowHeight({ floatingNode, arrow, arrowHeight, boxStyle }) {
|
|
165
|
-
if (!arrow) return 0
|
|
166
|
-
if (boxStyle === 'standard') return toPx(arrowHeight, floatingNode)
|
|
167
|
-
|
|
168
|
-
// Fancy box style
|
|
169
|
-
if (arrowHeight) {
|
|
170
|
-
const h = toPx(arrowHeight, floatingNode)
|
|
171
|
-
setCSSVar(floatingNode, '--h', `${h}px`)
|
|
172
|
-
return h
|
|
173
|
-
} else {
|
|
174
|
-
const h = getCSSVar(floatingNode, '--h')
|
|
175
|
-
return toPx(h, floatingNode)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function getArrowWidth({ boxStyle, floatingNode, arrowHeight }) {
|
|
180
|
-
// Standard box is a square, so it must use the same value for both width and height
|
|
181
|
-
if (boxStyle === 'standard') return arrowHeight
|
|
182
|
-
|
|
183
|
-
// Fancy box can have different width and height values depending on the angle used. Downside is the arrow will never be rounded.
|
|
184
|
-
|
|
185
|
-
let [angle, unit] = splitUnit(getCSSVar(floatingNode, '--a'))
|
|
186
|
-
if (unit === 'deg') angle = toRadians(angle)
|
|
187
|
-
return Math.tan(angle / 2) * arrowHeight * 2
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function getArrowSide(placement) {
|
|
191
|
-
const side = {
|
|
192
|
-
top: 'bottom',
|
|
193
|
-
right: 'left',
|
|
194
|
-
bottom: 'top',
|
|
195
|
-
left: 'right',
|
|
196
|
-
}[placement.split('-')[0]]
|
|
197
|
-
return side
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function applyArrowStyles({
|
|
201
|
-
arrowNode,
|
|
202
|
-
arrowWidth,
|
|
203
|
-
arrowHeight,
|
|
204
|
-
arrowRadius,
|
|
205
|
-
boxStyle,
|
|
206
|
-
}) {
|
|
207
|
-
// Need to check which borders and radius to remove
|
|
208
|
-
const styles = {
|
|
209
|
-
width: `${arrowWidth}px`,
|
|
210
|
-
height: `${arrowHeight}px`,
|
|
211
|
-
position: 'absolute',
|
|
212
|
-
borderRadius: '0',
|
|
213
|
-
borderTopRightRadius: arrowRadius,
|
|
214
|
-
borderWidth: 'inherit',
|
|
215
|
-
borderColor: 'inherit',
|
|
216
|
-
borderLeftWidth: '0',
|
|
217
|
-
borderBottomWidth: '0',
|
|
218
|
-
background: 'inherit',
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (boxStyle === 'fancy') {
|
|
222
|
-
Object.assign(styles, { opacity: '0' })
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
Object.assign(arrowNode.style, styles)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function calculateOffset({
|
|
229
|
-
floatingNode,
|
|
230
|
-
boxStyle,
|
|
231
|
-
offsetValue,
|
|
232
|
-
borderWidth,
|
|
233
|
-
arrow,
|
|
234
|
-
arrowHeight,
|
|
235
|
-
}) {
|
|
236
|
-
let offset = toPx(offsetValue, floatingNode)
|
|
237
|
-
if (!arrow) return offset
|
|
238
|
-
|
|
239
|
-
if (boxStyle === 'standard') {
|
|
240
|
-
const arrowHypotenuse = Math.sqrt(arrowHeight ** 2 + borderWidth ** 2)
|
|
241
|
-
offset += Math.floor(arrowHypotenuse / 2)
|
|
242
|
-
}
|
|
243
|
-
if (boxStyle === 'fancy') offset += arrowHeight
|
|
244
|
-
return offset
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function positionArrow({
|
|
248
|
-
floatingNode,
|
|
249
|
-
middlewareState,
|
|
250
|
-
arrowNode,
|
|
251
|
-
arrowWidth,
|
|
252
|
-
arrowHeight,
|
|
253
|
-
borderWidth,
|
|
254
|
-
borderRadius,
|
|
255
|
-
boxStyle,
|
|
256
|
-
}) {
|
|
257
|
-
const { placement } = middlewareState
|
|
258
|
-
const { x, y } = middlewareState.middlewareData.arrow
|
|
259
|
-
const { width, height } = floatingNode.getBoundingClientRect()
|
|
260
|
-
|
|
261
|
-
// Do nothing if popover is not opened yet
|
|
262
|
-
if (!(width || height)) return
|
|
263
|
-
// Do nothing if no arrow data
|
|
264
|
-
if (!(x || y)) return
|
|
265
|
-
|
|
266
|
-
const side = getArrowSide(placement)
|
|
267
|
-
|
|
268
|
-
if (boxStyle === 'standard') {
|
|
269
|
-
// Rotate arrow box
|
|
270
|
-
let rotate = 45
|
|
271
|
-
// prettier-ignore
|
|
272
|
-
switch (side) {
|
|
273
|
-
case 'top': rotate = -45; break;
|
|
274
|
-
case 'right': rotate = 45; break;
|
|
275
|
-
case 'bottom': rotate = 135; break;
|
|
276
|
-
case 'left': rotate = 225; break;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const adjusted = { x, y }
|
|
280
|
-
const safetySpace = 3
|
|
281
|
-
|
|
282
|
-
if (x || x === 0) {
|
|
283
|
-
const startEdge = borderRadius + safetySpace
|
|
284
|
-
const endEdge = width - borderRadius - arrowWidth - safetySpace
|
|
285
|
-
|
|
286
|
-
if (x <= startEdge) adjusted.x = startEdge
|
|
287
|
-
if (x >= endEdge) adjusted.x = endEdge
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (y || y === 0) {
|
|
291
|
-
const startEdge = borderRadius + safetySpace
|
|
292
|
-
const endEdge = height - borderRadius - arrowWidth - safetySpace
|
|
293
|
-
|
|
294
|
-
if (y <= startEdge) adjusted.y = startEdge
|
|
295
|
-
if (y >= endEdge) adjusted.y = endEdge
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const arrowCrossOffset = Math.ceil((arrowHeight + borderWidth) / 2)
|
|
299
|
-
|
|
300
|
-
// prettier-ignore
|
|
301
|
-
Object.assign(arrowNode.style, {
|
|
302
|
-
left: x ? `${adjusted.x}px` : '',
|
|
303
|
-
top: y ? `${adjusted.y}px` : '',
|
|
304
|
-
[side]: `-${arrowCrossOffset}px`,
|
|
305
|
-
transform: `rotate(${rotate}deg)`,
|
|
306
|
-
})
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (boxStyle === 'fancy') {
|
|
310
|
-
if (x) arrowNode.style.left = `${x}px`
|
|
311
|
-
if (y) arrowNode.style.top = `${y}px`
|
|
312
|
-
|
|
313
|
-
let arrowCenter, arrowPosition
|
|
314
|
-
if (x) {
|
|
315
|
-
arrowCenter = x + arrowWidth / 2
|
|
316
|
-
arrowPosition = ((arrowCenter + borderWidth) / width) * 100
|
|
317
|
-
}
|
|
318
|
-
if (y) {
|
|
319
|
-
arrowCenter = y + arrowWidth / 2
|
|
320
|
-
arrowPosition = ((arrowCenter + borderWidth) / height) * 100
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
floatingNode.classList.remove(
|
|
324
|
-
'arrow-top',
|
|
325
|
-
'arrow-right',
|
|
326
|
-
'arrow-bottom',
|
|
327
|
-
'arrow-left',
|
|
328
|
-
)
|
|
329
|
-
floatingNode.classList.add(`arrow-${side}`)
|
|
330
|
-
setCSSVar(floatingNode, '--arrow-position', `${arrowPosition}%`)
|
|
331
|
-
}
|
|
332
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
// Temp File for reference purposes
|
|
2
|
-
// Ignore the content here.
|
|
3
|
-
|
|
4
|
-
// Store version
|
|
5
|
-
// import { get, writable } from 'svelte/store'
|
|
6
|
-
// imp ort { isEmpty } from '@splendidlabz/utils'
|
|
7
|
-
// export const disclosures = writable([])
|
|
8
|
-
// const { update } = disclosures
|
|
9
|
-
|
|
10
|
-
// export function initDisclosure(id, options = {}, initialState = {}) {
|
|
11
|
-
// let d = getDisclosure(id)
|
|
12
|
-
// if (!d) {
|
|
13
|
-
// createDisclosure(id)
|
|
14
|
-
// d = getDisclosure(id)
|
|
15
|
-
// }
|
|
16
|
-
|
|
17
|
-
// // Update comment here later
|
|
18
|
-
// // Upon getting the id, initialize the rest of the values
|
|
19
|
-
// // Need to make sure values don't get replaced?
|
|
20
|
-
// d.options = Object.assign({}, d.options, options)
|
|
21
|
-
// if (!isEmpty(initialState)) d.state = initialState
|
|
22
|
-
|
|
23
|
-
// return d
|
|
24
|
-
// }
|
|
25
|
-
|
|
26
|
-
// export function getDisclosure(id) {
|
|
27
|
-
// return get(disclosures).find(disclosure => disclosure.id === id)
|
|
28
|
-
// }
|
|
29
|
-
|
|
30
|
-
// export function createDisclosure(id) {
|
|
31
|
-
// update(disclosures => {
|
|
32
|
-
// const d = { id, options: {}, state: {}, nodes: {} }
|
|
33
|
-
// return [...disclosures, d]
|
|
34
|
-
// })
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
// export function updateDisclosure(id, state) {
|
|
38
|
-
// update(disclosures => {
|
|
39
|
-
// const d = disclosures.find(d => d.id === id)
|
|
40
|
-
// d.state = state
|
|
41
|
-
// return [...disclosures, d]
|
|
42
|
-
// })
|
|
43
|
-
// }
|
|
44
|
-
|
|
45
|
-
// export function closeOthers(id) {
|
|
46
|
-
// update(disclosures => {
|
|
47
|
-
// return disclosures.map(d => {
|
|
48
|
-
// if (d.id !== id) d.state.show = false
|
|
49
|
-
// return d
|
|
50
|
-
// })
|
|
51
|
-
// })
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
// export const disclosures = writable({
|
|
55
|
-
// instances: [],
|
|
56
|
-
|
|
57
|
-
// init(id, options = {}, initialState = {}) {
|
|
58
|
-
// let d = this.getInstance(id)
|
|
59
|
-
// if (!d) d = this.createInstance(id)
|
|
60
|
-
|
|
61
|
-
// // Update comment here later
|
|
62
|
-
// // Upon getting the id, initialize the rest of the values
|
|
63
|
-
// // Need to make sure values don't get replaced?
|
|
64
|
-
|
|
65
|
-
// if (!isEmpty(options)) d.options = Object.assign(d.options, options)
|
|
66
|
-
// if (!isEmpty(initialState)) d.state = initialState
|
|
67
|
-
|
|
68
|
-
// return d
|
|
69
|
-
// },
|
|
70
|
-
|
|
71
|
-
// getInstance(id) {
|
|
72
|
-
// return this.instances.find(instance => instance.id === id)
|
|
73
|
-
// },
|
|
74
|
-
|
|
75
|
-
// createInstance(id) {
|
|
76
|
-
// const d = $state({ id, options: {}, state: {}, nodes: {} })
|
|
77
|
-
|
|
78
|
-
// this.instances.push(d)
|
|
79
|
-
// return this.getInstance(id)
|
|
80
|
-
// },
|
|
81
|
-
// })
|
|
82
|
-
|
|
83
|
-
// Multiple, local scoped
|
|
84
|
-
// export const disclosures = $state({
|
|
85
|
-
// instances: [],
|
|
86
|
-
|
|
87
|
-
// init(id, options = {}, initialState = {}) {
|
|
88
|
-
// let d = this.getInstance(id)
|
|
89
|
-
// if (!d) d = this.createInstance(id)
|
|
90
|
-
|
|
91
|
-
// // Update comment here later
|
|
92
|
-
// // Upon getting the id, initialize the rest of the values
|
|
93
|
-
// // Need to make sure values don't get replaced?
|
|
94
|
-
|
|
95
|
-
// if (!isEmpty(options)) d.options = Object.assign(d.options, options)
|
|
96
|
-
// if (!isEmpty(initialState)) d.state = initialState
|
|
97
|
-
|
|
98
|
-
// return d
|
|
99
|
-
// },
|
|
100
|
-
|
|
101
|
-
// getInstance(id) {
|
|
102
|
-
// return this.instances.find(instance => instance.id === id)
|
|
103
|
-
// },
|
|
104
|
-
|
|
105
|
-
// createInstance(id) {
|
|
106
|
-
// const d = $state({ id, options: {}, state: {}, nodes: {} })
|
|
107
|
-
|
|
108
|
-
// this.instances.push(d)
|
|
109
|
-
// return this.getInstance(id)
|
|
110
|
-
// },
|
|
111
|
-
// })
|
|
112
|
-
|
|
113
|
-
// Single but global
|
|
114
|
-
// export const d = $state({
|
|
115
|
-
// show: false,
|
|
116
|
-
// })
|
|
117
|
-
|
|
118
|
-
// export function getShow() {
|
|
119
|
-
// return d.show
|
|
120
|
-
// }
|
|
121
|
-
|
|
122
|
-
// export function toggle() {
|
|
123
|
-
// d.show = !d.show
|
|
124
|
-
// }
|
|
125
|
-
|
|
126
|
-
// Single
|
|
127
|
-
// export function createDisclosure() {
|
|
128
|
-
// let show = $state(false)
|
|
129
|
-
|
|
130
|
-
// return {
|
|
131
|
-
// get show() {
|
|
132
|
-
// return show
|
|
133
|
-
// },
|
|
134
|
-
// toggle() {
|
|
135
|
-
// show = !show
|
|
136
|
-
// },
|
|
137
|
-
// }
|
|
138
|
-
// }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|