@splendidlabz/svelte 4.2.0 → 4.3.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 +20 -0
- package/components/Breadcrumbs/Breadcrumbs.svelte +16 -17
- package/components/Breadcrumbs/CrumbCustom.svelte +5 -6
- package/components/Form/Combobox/TimepickerOptions.svelte +4 -3
- package/components/Form/index.js +0 -1
- package/components/{PushToLocalStorage.svelte → LocalStorage/LocalStoragePush.svelte} +2 -1
- package/components/LocalStorage/LocalStorageRemove.svelte +15 -0
- package/components/LocalStorage/index.js +4 -0
- package/index.js +1 -1
- package/package.json +3 -3
- package/components/Form/CustomSelect.svelte +0 -205
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @splendidlabz/svelte
|
|
2
2
|
|
|
3
|
+
## 4.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @splendidlabz/utils@1.8.1
|
|
9
|
+
- @splendidlabz/styles@4.2.2
|
|
10
|
+
|
|
11
|
+
## 4.3.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- Several updates
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @splendidlabz/utils@1.8.0
|
|
21
|
+
- @splendidlabz/styles@4.2.1
|
|
22
|
+
|
|
3
23
|
## 4.2.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -4,16 +4,15 @@
|
|
|
4
4
|
import Icon from '../Icon/Icon.svelte'
|
|
5
5
|
import Crumb from './Crumb.svelte'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
let { pathname = $bindable(''), ...p } = $props()
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
10
|
class: klass = '',
|
|
11
|
-
pathname = '',
|
|
12
11
|
|
|
13
12
|
// Slots
|
|
13
|
+
children,
|
|
14
14
|
before,
|
|
15
15
|
after,
|
|
16
|
-
children,
|
|
17
16
|
...rest
|
|
18
17
|
} = p
|
|
19
18
|
|
|
@@ -26,20 +25,18 @@
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
const opts = mergeOpts(defaultOptions, rest)
|
|
29
|
-
|
|
30
28
|
const { startingDepth, ariaCurrentType, labelCase } = opts
|
|
31
|
-
|
|
32
|
-
let
|
|
29
|
+
|
|
30
|
+
let trailingSlash = $derived(hasTrailingSlash(pathname))
|
|
31
|
+
let crumbs = $derived(
|
|
32
|
+
constructCrumbs(getURLArray(pathname), { trailingSlash }).slice(
|
|
33
|
+
startingDepth,
|
|
34
|
+
),
|
|
35
|
+
)
|
|
33
36
|
|
|
34
37
|
onMount(_ => {
|
|
35
38
|
if (typeof window === 'undefined') return
|
|
36
|
-
if (!pathname)
|
|
37
|
-
const { pathname } = window.location
|
|
38
|
-
const trailingSlash = hasTrailingSlash(pathname)
|
|
39
|
-
crumbs = constructCrumbs(getURLArray(pathname), { trailingSlash }).slice(
|
|
40
|
-
startingDepth,
|
|
41
|
-
)
|
|
42
|
-
}
|
|
39
|
+
if (!pathname) pathname = window.location.pathname
|
|
43
40
|
})
|
|
44
41
|
|
|
45
42
|
// Supporting functions
|
|
@@ -70,10 +67,12 @@
|
|
|
70
67
|
<nav class={`breadcrumbs ${klass}`} aria-label="Breadcrumbs">
|
|
71
68
|
<ul>
|
|
72
69
|
{#if before}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
|
|
70
|
+
<li class="crumb">
|
|
71
|
+
{@render before?.()}
|
|
72
|
+
<span class="crumb-divider">
|
|
73
|
+
<Icon icon={opts.divider} />
|
|
74
|
+
</span>
|
|
75
|
+
</li>
|
|
77
76
|
{/if}
|
|
78
77
|
|
|
79
78
|
{#if children}
|
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
class: klass = '',
|
|
6
6
|
divider = 'tabler:chevron-right',
|
|
7
7
|
children,
|
|
8
|
+
...rest
|
|
8
9
|
} = $props()
|
|
9
10
|
</script>
|
|
10
11
|
|
|
11
|
-
<li class="crumb {klass}">
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
{/if}
|
|
15
|
-
<div class="crumb-divider">
|
|
12
|
+
<li {...rest} class="crumb {klass}">
|
|
13
|
+
{@render children?.()}
|
|
14
|
+
<span class="crumb-divider">
|
|
16
15
|
<Icon icon={divider} />
|
|
17
|
-
</
|
|
16
|
+
</span>
|
|
18
17
|
</li>
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
disabled: timing.blocked,
|
|
41
41
|
}))
|
|
42
42
|
|
|
43
|
+
// console.log(timings)
|
|
43
44
|
const showHours = opts.format.includes('HH')
|
|
44
45
|
const showMinutes = opts.format.includes('mm')
|
|
45
46
|
const showSeconds = opts.format.includes('ss')
|
|
@@ -47,23 +48,23 @@
|
|
|
47
48
|
|
|
48
49
|
<PopoverContent
|
|
49
50
|
{id}
|
|
50
|
-
class="TimepickerOptions ListboxPopover {klass}"
|
|
51
51
|
options={opts}
|
|
52
|
+
class="TimepickerOptions ListboxPopover {klass}"
|
|
52
53
|
>
|
|
53
54
|
{#if mode === 'list' && selection === 'single'}
|
|
54
55
|
<!-- This doesn't close the popover yet -->
|
|
55
56
|
<!-- Need some action to determine when to close the popover -->
|
|
56
57
|
<Radios
|
|
57
|
-
name="time"
|
|
58
58
|
class="Timepicker {klass}"
|
|
59
59
|
legend="Time"
|
|
60
|
+
name="time"
|
|
60
61
|
radios={timings}
|
|
61
62
|
></Radios>
|
|
62
63
|
{/if}
|
|
63
64
|
|
|
64
65
|
{#if mode === 'list' && selection === 'multiple'}
|
|
65
66
|
<!-- This doesn't close the popover yet -->
|
|
66
|
-
<Checkboxes class="Timepicker {klass}" checkboxes={timings}
|
|
67
|
+
<Checkboxes class="Timepicker {klass}" legend="Time" checkboxes={timings}
|
|
67
68
|
></Checkboxes>
|
|
68
69
|
{/if}
|
|
69
70
|
|
package/components/Form/index.js
CHANGED
|
@@ -3,7 +3,6 @@ export { default as ButtonGroup } from './ButtonGroup.svelte'
|
|
|
3
3
|
export { default as Checkbox } from './Checkbox.svelte'
|
|
4
4
|
export { default as Checkboxes } from './Checkboxes.svelte'
|
|
5
5
|
export * from './Combobox/index.js'
|
|
6
|
-
export { default as CustomSelect } from './CustomSelect.svelte'
|
|
7
6
|
export { default as Form } from './Form.svelte'
|
|
8
7
|
export { default as Hidden } from './Hidden.svelte'
|
|
9
8
|
export { default as HiddenInput } from './HiddenInput.svelte'
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
9
|
import { localStore } from '@splendidlabz/utils/dom'
|
|
10
|
+
import { onMount } from 'svelte'
|
|
10
11
|
|
|
11
12
|
const { name, value } = $props()
|
|
12
13
|
if (!name) throw new Error('name is required')
|
|
13
14
|
|
|
14
|
-
store
|
|
15
|
+
onMount(store)
|
|
15
16
|
|
|
16
17
|
function store() {
|
|
17
18
|
if (typeof window === 'undefined') return
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { localStore } from '@splendidlabz/utils/dom'
|
|
3
|
+
import { onMount } from 'svelte'
|
|
4
|
+
|
|
5
|
+
const { name } = $props()
|
|
6
|
+
if (!name) throw new Error('name is required')
|
|
7
|
+
|
|
8
|
+
onMount(store)
|
|
9
|
+
|
|
10
|
+
function store() {
|
|
11
|
+
if (typeof window === 'undefined') return
|
|
12
|
+
if (!name) return
|
|
13
|
+
localStore.remove(name)
|
|
14
|
+
}
|
|
15
|
+
</script>
|
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from './components/Highlight/index.js'
|
|
|
18
18
|
export * from './components/InteractiveRegion/index.js'
|
|
19
19
|
export * from './components/Link/index.js'
|
|
20
20
|
export * from './components/List/index.js'
|
|
21
|
+
export * from './components/LocalStorage/index.js'
|
|
21
22
|
export * from './components/Masonry/index.js'
|
|
22
23
|
export * from './components/Populate/index.js'
|
|
23
24
|
export * from './components/Switcheroo/index.js'
|
|
@@ -34,7 +35,6 @@ export { default as Image } from './components/Image.svelte'
|
|
|
34
35
|
export { default as Markdown } from './components/Markdown/Markdown.svelte'
|
|
35
36
|
export { default as PerspectiveHover } from './components/PerspectiveHover/PerspectiveHover.svelte'
|
|
36
37
|
export { default as Portal } from './components/Portal.svelte'
|
|
37
|
-
export { default as PushToLocalStorage } from './components/PushToLocalStorage.svelte'
|
|
38
38
|
export { default as Spotlight } from './components/Spotlight/Spotlight.svelte'
|
|
39
39
|
export { default as Status } from './components/Status.svelte'
|
|
40
40
|
export { default as Video } from './components/Video.svelte'
|
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.3.1",
|
|
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.2.
|
|
25
|
-
"@splendidlabz/utils": "1.
|
|
24
|
+
"@splendidlabz/styles": "4.2.2",
|
|
25
|
+
"@splendidlabz/utils": "1.8.1",
|
|
26
26
|
"autosuggest-highlight": "^3.3.4",
|
|
27
27
|
"lodash-es": "^4.17.21",
|
|
28
28
|
"node-html-parser": "^7.0.1"
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/* eslint-disable no-labels */
|
|
3
|
-
import { toTitle } from '@splendidlabz/utils'
|
|
4
|
-
import { randomString } from '@splendidlabz/utils/dom'
|
|
5
|
-
import { Popover, PopoverTrigger } from '../Disclosure/index.js'
|
|
6
|
-
import Icon from '../Icon/Icon.svelte'
|
|
7
|
-
import HiddenInput from './HiddenInput.svelte'
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
name = '',
|
|
11
|
-
items = $bindable([]),
|
|
12
|
-
options = $bindable([]),
|
|
13
|
-
selected = $bindable(null),
|
|
14
|
-
ref = $bindable(null),
|
|
15
|
-
...p
|
|
16
|
-
} = $props()
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
// Classes
|
|
20
|
-
class: klass = '',
|
|
21
|
-
icon = null,
|
|
22
|
-
iconClass = null,
|
|
23
|
-
label = '',
|
|
24
|
-
labelClass,
|
|
25
|
-
labelVisible = true,
|
|
26
|
-
hint = null,
|
|
27
|
-
hintClass,
|
|
28
|
-
fieldClass = null,
|
|
29
|
-
|
|
30
|
-
// Options and props
|
|
31
|
-
id = randomString(8),
|
|
32
|
-
required = null,
|
|
33
|
-
readonly = null,
|
|
34
|
-
disabled = null,
|
|
35
|
-
multiple = null,
|
|
36
|
-
size = 0, // Number of lines to show, useful for multiselect, 0, but show 4 lines by default.
|
|
37
|
-
|
|
38
|
-
onchange = null,
|
|
39
|
-
...rest
|
|
40
|
-
} = p
|
|
41
|
-
|
|
42
|
-
if (!options.length && !items.length) {
|
|
43
|
-
console.error(
|
|
44
|
-
'Select requires either `options` or `items` to be passed in.',
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const isSingle = !multiple
|
|
49
|
-
const hintId = hint ? id + '-hint' : ''
|
|
50
|
-
const hintDescription = `${hintId}`.trim() || null
|
|
51
|
-
|
|
52
|
-
let selectedItem = $derived(items.find(item => item.value === selected))
|
|
53
|
-
|
|
54
|
-
// ========================================
|
|
55
|
-
// Some Checks & Normalizations
|
|
56
|
-
// ========================================
|
|
57
|
-
// Fixes multiple name and selected values
|
|
58
|
-
if (multiple) {
|
|
59
|
-
if (!name.endsWith('[]')) name = name += '[]'
|
|
60
|
-
if (!Array.isArray(selected)) selected = []
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Normalize items
|
|
64
|
-
if (options.length) items = options
|
|
65
|
-
items = items.map(option => {
|
|
66
|
-
if (typeof option === 'string') option = { value: option }
|
|
67
|
-
|
|
68
|
-
if (!option.label) option.label = toTitle(option.value)
|
|
69
|
-
|
|
70
|
-
if (isSingle) {
|
|
71
|
-
// Updates selected with selected options
|
|
72
|
-
if (option.selected) selected = option.value
|
|
73
|
-
|
|
74
|
-
// Updates options with selected values
|
|
75
|
-
if (option.value === selected) option.selected = true
|
|
76
|
-
else option.selected = false
|
|
77
|
-
} else {
|
|
78
|
-
// Updates selected with selected options
|
|
79
|
-
if (option.selected && !selected.includes(option.value))
|
|
80
|
-
selected.push(option.value)
|
|
81
|
-
|
|
82
|
-
// Updates options with selected values
|
|
83
|
-
if (selected.includes(option.value)) option.selected = true
|
|
84
|
-
else option.selected = false
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return option
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
// Preselect first item that is not disabled. (Single only)
|
|
91
|
-
setSelected: if (!multiple && !selected) {
|
|
92
|
-
const firstNotDisabled = items.findIndex(item => !item.disabled)
|
|
93
|
-
if (firstNotDisabled === -1) break setSelected
|
|
94
|
-
const s = items[firstNotDisabled] || items[0]
|
|
95
|
-
s.selected = true
|
|
96
|
-
selected = s.value
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Properties for the select element
|
|
100
|
-
const properties = {
|
|
101
|
-
...rest,
|
|
102
|
-
id,
|
|
103
|
-
name,
|
|
104
|
-
class: 'input ' + fieldClass,
|
|
105
|
-
disabled: disabled || readonly,
|
|
106
|
-
'aria-describedby': hintDescription,
|
|
107
|
-
onchange: handleChange,
|
|
108
|
-
required,
|
|
109
|
-
size,
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function handleChange() {
|
|
113
|
-
items.forEach(item => {
|
|
114
|
-
if (item.value === selected) item.selected = true
|
|
115
|
-
else item.selected = false
|
|
116
|
-
})
|
|
117
|
-
if (onchange) onchange()
|
|
118
|
-
}
|
|
119
|
-
</script>
|
|
120
|
-
|
|
121
|
-
{#snippet select()}
|
|
122
|
-
<select {...properties} bind:this={ref} bind:value={selected}>
|
|
123
|
-
{#each items as option (option.value)}
|
|
124
|
-
{@const { label: optionLabel, value, ...optionRest } = option}
|
|
125
|
-
<option {...optionRest} {value}>{optionLabel}</option>
|
|
126
|
-
{/each}
|
|
127
|
-
</select>
|
|
128
|
-
{/snippet}
|
|
129
|
-
|
|
130
|
-
<!-- Svelte requires multiple to be passed as a standard attribute for it to bind to an array value, hence the duplication here -->
|
|
131
|
-
{#snippet multiselect()}
|
|
132
|
-
<select
|
|
133
|
-
{...properties}
|
|
134
|
-
bind:this={ref}
|
|
135
|
-
aria-describedby={hintDescription}
|
|
136
|
-
multiple
|
|
137
|
-
bind:value={selected}
|
|
138
|
-
>
|
|
139
|
-
{#each items as option (option.value)}
|
|
140
|
-
{@const { label: optionLabel, value, ...optionRest } = option}
|
|
141
|
-
<option {...optionRest} {value}>{optionLabel}</option>
|
|
142
|
-
{/each}
|
|
143
|
-
</select>
|
|
144
|
-
{/snippet}
|
|
145
|
-
|
|
146
|
-
{#snippet selectIcon()}
|
|
147
|
-
{#if icon}
|
|
148
|
-
<Icon class={iconClass} {icon} />
|
|
149
|
-
{:else}
|
|
150
|
-
<svg class={iconClass} height="24" viewBox="0 0 24 24" width="24">
|
|
151
|
-
<path
|
|
152
|
-
d="M8 9L12 5L16 9M16 15L12 19L8 15"
|
|
153
|
-
stroke="currentcolor"
|
|
154
|
-
stroke-linecap="round"
|
|
155
|
-
stroke-linejoin="round"
|
|
156
|
-
stroke-width="2"
|
|
157
|
-
/>
|
|
158
|
-
</svg>
|
|
159
|
-
{/if}
|
|
160
|
-
{/snippet}
|
|
161
|
-
|
|
162
|
-
<div class="input-container select {klass}">
|
|
163
|
-
{#if label && labelVisible}
|
|
164
|
-
<label class="label input-meta {labelClass}" for={id}>{label}</label>
|
|
165
|
-
{/if}
|
|
166
|
-
{#if hint}
|
|
167
|
-
<div id={hintId} class="hint input-meta {hintClass}">{hint}</div>
|
|
168
|
-
{/if}
|
|
169
|
-
|
|
170
|
-
<div class="input-group items-center stack" class:disabled class:readonly>
|
|
171
|
-
<!-- Single Select -->
|
|
172
|
-
{#if isSingle}
|
|
173
|
-
{@render select()}
|
|
174
|
-
{#if readonly}
|
|
175
|
-
<HiddenInput {name} value={selected} />
|
|
176
|
-
{/if}
|
|
177
|
-
|
|
178
|
-
<div class="pos-right pointer-events-none z-[3]">
|
|
179
|
-
{@render selectIcon()}
|
|
180
|
-
</div>
|
|
181
|
-
{/if}
|
|
182
|
-
|
|
183
|
-
<!-- Multi Select -->
|
|
184
|
-
{#if multiple}
|
|
185
|
-
{@render multiselect()}
|
|
186
|
-
{#if readonly}
|
|
187
|
-
{#each selected as item (item)}
|
|
188
|
-
<HiddenInput {name} value={item} />
|
|
189
|
-
{/each}
|
|
190
|
-
{/if}
|
|
191
|
-
{/if}
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
|
|
195
|
-
<PopoverTrigger class="horizontal justify-between" target="meh">
|
|
196
|
-
<span> {selectedItem?.value} </span>
|
|
197
|
-
<span> {@render selectIcon()} </span>
|
|
198
|
-
</PopoverTrigger>
|
|
199
|
-
|
|
200
|
-
<Popover id="meh" offset="0.5em" placement="bottom-end" role="listbox">
|
|
201
|
-
{#each items as option (option.value)}
|
|
202
|
-
{@const { label: optionLabel, value, ...optionRest } = option}
|
|
203
|
-
<option {...optionRest} {value}>{optionLabel}</option>
|
|
204
|
-
{/each}
|
|
205
|
-
</Popover>
|