@rokkit/ui 1.0.0-next.124 → 1.0.0-next.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +198 -101
- package/package.json +52 -34
- package/src/components/BreadCrumbs.svelte +82 -0
- package/src/components/Button.svelte +87 -0
- package/src/components/ButtonGroup.svelte +18 -0
- package/src/components/Card.svelte +61 -0
- package/src/components/Carousel.svelte +169 -0
- package/src/components/Code.svelte +185 -0
- package/src/components/Connector.svelte +46 -0
- package/src/components/FloatingAction.svelte +331 -0
- package/src/components/FloatingNavigation.svelte +228 -0
- package/src/components/ItemContent.svelte +24 -0
- package/src/components/List.svelte +476 -0
- package/src/components/Menu.svelte +421 -0
- package/src/components/MultiSelect.svelte +521 -0
- package/src/components/PaletteManager.svelte +354 -0
- package/src/components/Pill.svelte +78 -0
- package/src/components/ProgressBar.svelte +31 -0
- package/src/components/Range.svelte +325 -0
- package/src/components/Rating.svelte +91 -0
- package/src/components/Reveal.svelte +58 -0
- package/src/components/SearchFilter.svelte +80 -0
- package/src/components/Select.svelte +585 -0
- package/src/{Shine.svelte → components/Shine.svelte} +29 -21
- package/src/components/Stepper.svelte +169 -0
- package/src/components/Switch.svelte +75 -0
- package/src/components/Table.svelte +243 -0
- package/src/components/Tabs.svelte +268 -0
- package/src/components/Tilt.svelte +68 -0
- package/src/components/Timeline.svelte +61 -0
- package/src/components/Toggle.svelte +157 -0
- package/src/components/Toolbar.svelte +307 -0
- package/src/components/ToolbarGroup.svelte +17 -0
- package/src/components/Tree.svelte +613 -0
- package/src/components/index.ts +33 -0
- package/src/index.ts +41 -0
- package/src/types/button.ts +83 -0
- package/src/types/code.ts +46 -0
- package/src/types/floating-action.ts +118 -0
- package/src/types/floating-navigation.ts +68 -0
- package/src/types/index.ts +53 -0
- package/src/types/item-proxy.ts +358 -0
- package/src/types/list.ts +196 -0
- package/src/types/menu.ts +195 -0
- package/src/types/palette.ts +143 -0
- package/src/types/range.ts +51 -0
- package/src/types/search-filter.ts +67 -0
- package/src/types/select.ts +206 -0
- package/src/types/switch.ts +64 -0
- package/src/types/table.ts +210 -0
- package/src/types/tabs.ts +124 -0
- package/src/types/timeline.ts +51 -0
- package/src/types/toggle.ts +109 -0
- package/src/types/toolbar.ts +164 -0
- package/src/types/tree.ts +259 -0
- package/src/utils/palette.ts +582 -0
- package/src/utils/shiki.ts +122 -0
- package/dist/constants.d.ts +0 -2
- package/dist/index.d.ts +0 -41
- package/dist/lib/fields.d.ts +0 -16
- package/dist/lib/form.d.ts +0 -95
- package/dist/lib/index.d.ts +0 -6
- package/dist/lib/layout.d.ts +0 -7
- package/dist/lib/nested.d.ts +0 -48
- package/dist/lib/schema.d.ts +0 -7
- package/dist/lib/select.d.ts +0 -8
- package/dist/lib/tree.d.ts +0 -9
- package/dist/tree/List.spec.svelte.d.ts +0 -1
- package/dist/tree/Node.spec.svelte.d.ts +0 -1
- package/dist/tree/Root.spec.svelte.d.ts +0 -1
- package/dist/types.d.ts +0 -5
- package/dist/wrappers/index.d.ts +0 -3
- package/src/Accordion.svelte +0 -118
- package/src/BreadCrumbs.svelte +0 -32
- package/src/Button.svelte +0 -57
- package/src/Calendar.svelte +0 -93
- package/src/Card.svelte +0 -45
- package/src/Carousel.svelte +0 -49
- package/src/CheckBox.svelte +0 -56
- package/src/Connector.svelte +0 -40
- package/src/DropDown.svelte +0 -68
- package/src/DropSearch.svelte +0 -37
- package/src/Fillable.svelte +0 -19
- package/src/GraphPaper.svelte +0 -43
- package/src/Icon.svelte +0 -81
- package/src/Item.svelte +0 -25
- package/src/Link.svelte +0 -21
- package/src/List.svelte +0 -89
- package/src/ListBody.svelte +0 -43
- package/src/Message.svelte +0 -11
- package/src/MultiSelect.svelte +0 -48
- package/src/NestedList.svelte +0 -78
- package/src/NestedPaginator.svelte +0 -63
- package/src/Node.svelte +0 -76
- package/src/Overlay.svelte +0 -21
- package/src/PageNavigator.svelte +0 -94
- package/src/PickOne.svelte +0 -60
- package/src/Pill.svelte +0 -41
- package/src/ProgressBar.svelte +0 -21
- package/src/ProgressDots.svelte +0 -53
- package/src/RadioGroup.svelte +0 -52
- package/src/Range.svelte +0 -45
- package/src/RangeMinMax.svelte +0 -124
- package/src/RangeSlider.svelte +0 -79
- package/src/RangeTick.svelte +0 -28
- package/src/Rating.svelte +0 -95
- package/src/ResponsiveGrid.svelte +0 -88
- package/src/Scrollable.svelte +0 -7
- package/src/Select.svelte +0 -114
- package/src/Separator.svelte +0 -1
- package/src/Slider.svelte +0 -14
- package/src/SlidingColumns.svelte +0 -50
- package/src/Stage.svelte +0 -41
- package/src/Stepper.svelte +0 -66
- package/src/Summary.svelte +0 -22
- package/src/Switch.svelte +0 -106
- package/src/TableCell.svelte +0 -51
- package/src/TableHeaderCell.svelte +0 -54
- package/src/Tabs.svelte +0 -176
- package/src/Tilt.svelte +0 -66
- package/src/Toggle.svelte +0 -58
- package/src/ToggleThemeMode.svelte +0 -23
- package/src/Tree.svelte +0 -80
- package/src/TreeTable.svelte +0 -171
- package/src/ValidationReport.svelte +0 -23
- package/src/constants.js +0 -4
- package/src/index.js +0 -48
- package/src/lib/fields.js +0 -118
- package/src/lib/form.js +0 -72
- package/src/lib/index.js +0 -13
- package/src/lib/layout.js +0 -63
- package/src/lib/nested.js +0 -192
- package/src/lib/schema.js +0 -32
- package/src/lib/select.js +0 -38
- package/src/lib/tree.js +0 -22
- package/src/tree/List.spec.svelte.js +0 -84
- package/src/tree/List.svelte +0 -78
- package/src/tree/Node.spec.svelte.js +0 -104
- package/src/tree/Node.svelte +0 -80
- package/src/tree/Root.spec.svelte.js +0 -63
- package/src/tree/Root.svelte +0 -81
- package/src/types.js +0 -9
- package/src/wrappers/Category.svelte +0 -27
- package/src/wrappers/Section.svelte +0 -16
- package/src/wrappers/Wrapper.svelte +0 -12
- package/src/wrappers/index.js +0 -3
package/src/Switch.svelte
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { equals } from 'ramda'
|
|
3
|
-
import { keyboard } from '@rokkit/actions'
|
|
4
|
-
import { Proxy } from '@rokkit/states'
|
|
5
|
-
import Item from './Item.svelte'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} Props
|
|
9
|
-
* @property {string} [class]
|
|
10
|
-
* @property {any} value
|
|
11
|
-
* @property {import('@rokkit/core').FieldMapping} fields
|
|
12
|
-
* @property {Array<any>} [options]
|
|
13
|
-
* @property {boolean} [compact]
|
|
14
|
-
* @property {boolean} [disabled]
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/** @type {Props} */
|
|
18
|
-
let {
|
|
19
|
-
class: classes = '',
|
|
20
|
-
value = $bindable(),
|
|
21
|
-
description = 'Toggle Switch',
|
|
22
|
-
options = [false, true],
|
|
23
|
-
fields,
|
|
24
|
-
compact = false,
|
|
25
|
-
disabled = false,
|
|
26
|
-
onchange,
|
|
27
|
-
child,
|
|
28
|
-
...extra
|
|
29
|
-
} = $props()
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Toggles the value of the switch
|
|
33
|
-
* @param {number} direction - The direction to toggle the switch
|
|
34
|
-
*/
|
|
35
|
-
function toggle(direction = 1) {
|
|
36
|
-
let nextIndex
|
|
37
|
-
const index = options.indexOf(value)
|
|
38
|
-
if (index === -1) {
|
|
39
|
-
nextIndex = direction === -1 ? options.length - 1 : 0
|
|
40
|
-
} else {
|
|
41
|
-
nextIndex = (index + direction + options.length) % options.length
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
value = options[nextIndex]
|
|
45
|
-
onchange(value)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param event
|
|
51
|
-
*/
|
|
52
|
-
function handleClick(event) {
|
|
53
|
-
const index = event.target.closest('[data-path]').dataset.path
|
|
54
|
-
value = options[index]
|
|
55
|
-
onchange(value)
|
|
56
|
-
}
|
|
57
|
-
const keyMapping = {
|
|
58
|
-
next: ['ArrowRight', 'ArrowDown', ' ', 'Enter'],
|
|
59
|
-
prev: ['ArrowLeft', 'ArrowUp']
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let childSnippet = $derived(child ? child : defaultChild)
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
{#snippet defaultChild(proxy)}
|
|
66
|
-
<Item {proxy} />
|
|
67
|
-
{/snippet}
|
|
68
|
-
|
|
69
|
-
{#if !Array.isArray(options) || options.length < 2}
|
|
70
|
-
<div data-error>Items should be an array with at least two items.</div>
|
|
71
|
-
{:else}
|
|
72
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
73
|
-
<div
|
|
74
|
-
class={classes}
|
|
75
|
-
data-switch-root
|
|
76
|
-
data-switch-off={options.length === 2 && equals(value, options[0])}
|
|
77
|
-
data-switch-on={options.length === 2 && equals(value, options[1])}
|
|
78
|
-
data-switch-compact={compact}
|
|
79
|
-
aria-label={description}
|
|
80
|
-
aria-orientation="horizontal"
|
|
81
|
-
aria-disabled={disabled}
|
|
82
|
-
tabindex="0"
|
|
83
|
-
role="listbox"
|
|
84
|
-
use:keyboard={keyMapping}
|
|
85
|
-
onnext={() => toggle()}
|
|
86
|
-
onprev={() => toggle(-1)}
|
|
87
|
-
onclick={handleClick}
|
|
88
|
-
>
|
|
89
|
-
{#each options as item, index (index)}
|
|
90
|
-
{@const proxy = new Proxy(item, fields)}
|
|
91
|
-
<div
|
|
92
|
-
data-switch-item
|
|
93
|
-
class="relative"
|
|
94
|
-
role="option"
|
|
95
|
-
aria-selected={equals(item, value)}
|
|
96
|
-
data-path={index}
|
|
97
|
-
>
|
|
98
|
-
{#if equals(item, value)}
|
|
99
|
-
<div data-switch-mark class="absolute bottom-0 left-0 right-0 top-0"></div>
|
|
100
|
-
{/if}
|
|
101
|
-
|
|
102
|
-
{@render childSnippet?.(proxy)}
|
|
103
|
-
</div>
|
|
104
|
-
{/each}
|
|
105
|
-
</div>
|
|
106
|
-
{/if}
|
package/src/TableCell.svelte
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { identity } from 'ramda'
|
|
3
|
-
import { defaultMapping } from './constants'
|
|
4
|
-
import Connector from './Connector.svelte'
|
|
5
|
-
import Icon from './Icon.svelte'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} Props
|
|
9
|
-
* @property {string} [class]
|
|
10
|
-
* @property {any} value
|
|
11
|
-
* @property {any} [fields]
|
|
12
|
-
* @property {any} [formatter]
|
|
13
|
-
* @property {any} [using]
|
|
14
|
-
* @property {any} [levels]
|
|
15
|
-
* @property {boolean} [isParent]
|
|
16
|
-
* @property {boolean} [isExpanded]
|
|
17
|
-
* @property {number} [depth]
|
|
18
|
-
* @property {any} [path]
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/** @type {Props} */
|
|
22
|
-
let {
|
|
23
|
-
class: classes = '',
|
|
24
|
-
value = $bindable(),
|
|
25
|
-
mapping = defaultMapping,
|
|
26
|
-
formatter = identity,
|
|
27
|
-
levels = [],
|
|
28
|
-
isParent = false,
|
|
29
|
-
isExpanded = false,
|
|
30
|
-
depth = 0,
|
|
31
|
-
path = null
|
|
32
|
-
} = $props()
|
|
33
|
-
|
|
34
|
-
const Template = $derived(mapping.get('component', value))
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<td class={classes}>
|
|
38
|
-
<rk-cell>
|
|
39
|
-
{#if path}
|
|
40
|
-
{#each levels.slice(0, -1) as level (level)}
|
|
41
|
-
<Connector type="empty" />
|
|
42
|
-
{/each}
|
|
43
|
-
{#if isParent}
|
|
44
|
-
<Icon name={isExpanded ? 'node-opened' : 'node-closed'} class="small cursor-pointer" />
|
|
45
|
-
{:else if depth > 0}
|
|
46
|
-
<Connector type="empty" />
|
|
47
|
-
{/if}
|
|
48
|
-
{/if}
|
|
49
|
-
<Template bind:value {mapping} {formatter} />
|
|
50
|
-
</rk-cell>
|
|
51
|
-
</td>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { noop } from '@rokkit/core'
|
|
3
|
-
import Icon from './Icon.svelte'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} Props
|
|
7
|
-
* @property {string} [class]
|
|
8
|
-
* @property {string} name
|
|
9
|
-
* @property {string|null} label
|
|
10
|
-
* @property {boolean} [sortable]
|
|
11
|
-
* @property {boolean} [hidden]
|
|
12
|
-
* @property {string} [order]
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** @type {Props} */
|
|
16
|
-
let {
|
|
17
|
-
class: className = '',
|
|
18
|
-
name,
|
|
19
|
-
label,
|
|
20
|
-
sortable = false,
|
|
21
|
-
hidden = false,
|
|
22
|
-
order = $bindable('none'),
|
|
23
|
-
onsort = noop
|
|
24
|
-
} = $props()
|
|
25
|
-
|
|
26
|
-
const handleSort = (event) => {
|
|
27
|
-
if (!sortable) return
|
|
28
|
-
event.stopPropagation()
|
|
29
|
-
order = order === 'none' ? 'ascending' : order === 'ascending' ? 'descending' : 'none'
|
|
30
|
-
const extend = event.getModifierState('Shift') || event.getModifierState('Control')
|
|
31
|
-
onsort({ name, extend, order })
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let title = $derived(label ?? name)
|
|
35
|
-
let description = $derived(sortable ? `sort by ${title}` : title)
|
|
36
|
-
let icon = $derived(`sort-${order}`)
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
{#if !hidden}
|
|
40
|
-
<th
|
|
41
|
-
scope="col"
|
|
42
|
-
onclick={handleSort}
|
|
43
|
-
data-sortable={sortable}
|
|
44
|
-
aria-label={description}
|
|
45
|
-
class={className}
|
|
46
|
-
>
|
|
47
|
-
<rk-cell>
|
|
48
|
-
{title}
|
|
49
|
-
{#if sortable}
|
|
50
|
-
<Icon name={icon} class="small" label="change the sort order" />
|
|
51
|
-
{/if}
|
|
52
|
-
</rk-cell>
|
|
53
|
-
</th>
|
|
54
|
-
{/if}
|
package/src/Tabs.svelte
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { createEmitter, getKeyFromPath, defaultStateIcons } from '@rokkit/core'
|
|
3
|
-
import { navigator } from '@rokkit/actions'
|
|
4
|
-
import { ListController } from '@rokkit/states'
|
|
5
|
-
import { Proxy } from '@rokkit/states'
|
|
6
|
-
import { has, equals, pick } from 'ramda'
|
|
7
|
-
import Icon from './Icon.svelte'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {Object} FieldMapping
|
|
11
|
-
* @property {string} [id] - Field to use for item ID
|
|
12
|
-
* @property {string} [label] - Field to use for item label/text
|
|
13
|
-
* @property {string} [value] - Field to use for item value
|
|
14
|
-
* @property {string} [content] - Field to use for tab content
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @typedef {Object} TabProps
|
|
19
|
-
* @property {string} [class] - Additional CSS class names
|
|
20
|
-
* @property {string} [name] - Name for accessibility
|
|
21
|
-
* @property {any[]} [options] - Array of tab options to display
|
|
22
|
-
* @property {FieldMapping} [fields] - Field mappings for extracting data
|
|
23
|
-
* @property {'horizontal'|'vertical'} [orientation] - Orientation of the tab bar
|
|
24
|
-
* @property {'before' | 'after' } [position] - Position of the tab bar
|
|
25
|
-
* @property {'start'|'center'|'end'} [align] - Alignment of the tab bar
|
|
26
|
-
* @property {any} [value] - Selected tab value (bindable)
|
|
27
|
-
* @property {number} [tabindex] - Tab index for keyboard navigation
|
|
28
|
-
* @property {boolean} [editable] - Whether tabs can be added/removed
|
|
29
|
-
* @property {string} [placeholder] - Placeholder text for input field
|
|
30
|
-
* @property {import('svelte').Snippet} [tabItem] - Snippet for rendering tab headers
|
|
31
|
-
* @property {import('svelte').Snippet} [tabPanel] - Snippet for rendering tab content
|
|
32
|
-
* @property {import('svelte').Snippet} [empty] - Snippet for rendering empty state
|
|
33
|
-
* @property {Function} [onselect] - Callback when tab is selected
|
|
34
|
-
* @property {Function} [onchange] - Callback when tab changes
|
|
35
|
-
* @property {Function} [onmove] - Callback when focus moves
|
|
36
|
-
* @property {Function} [onadd] - Callback when tab is added
|
|
37
|
-
* @property {Function} [onremove] - Callback when tab is removed
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/** @type {TabProps} */
|
|
41
|
-
let {
|
|
42
|
-
class: classes = '',
|
|
43
|
-
name = 'tabs',
|
|
44
|
-
options = $bindable([]),
|
|
45
|
-
fields = {},
|
|
46
|
-
value = $bindable(),
|
|
47
|
-
orientation = 'horizontal',
|
|
48
|
-
align = 'start',
|
|
49
|
-
position = 'before',
|
|
50
|
-
tabindex = 0,
|
|
51
|
-
editable = false,
|
|
52
|
-
tabItem,
|
|
53
|
-
tabPanel,
|
|
54
|
-
empty,
|
|
55
|
-
placeholder = 'Select a tab to view its content.',
|
|
56
|
-
icons,
|
|
57
|
-
onselect,
|
|
58
|
-
onchange,
|
|
59
|
-
onmove,
|
|
60
|
-
onadd,
|
|
61
|
-
onremove,
|
|
62
|
-
...restProps
|
|
63
|
-
} = $props()
|
|
64
|
-
|
|
65
|
-
/** @type {Proxy[]} */
|
|
66
|
-
let proxyItems = $derived(options.map((item) => new Proxy(item, fields)))
|
|
67
|
-
let tabItemSnippet = $derived(tabItem ?? defaultItem)
|
|
68
|
-
let tabPanelSnippet = $derived(tabPanel ?? defaultPanel)
|
|
69
|
-
let emptyMessage = $derived(empty ?? defaultEmpty)
|
|
70
|
-
|
|
71
|
-
function handleAction(event) {
|
|
72
|
-
const { name, data } = event.detail
|
|
73
|
-
|
|
74
|
-
if (has(name, emitter)) {
|
|
75
|
-
value = data.value
|
|
76
|
-
emitter[name](data)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function handleAdd() {
|
|
81
|
-
onadd?.()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function handleRemove(item) {
|
|
85
|
-
onremove?.(item)
|
|
86
|
-
}
|
|
87
|
-
let tabIcons = $derived({ ...pick(['add', 'close'], defaultStateIcons.action), ...icons })
|
|
88
|
-
let emitter = createEmitter({ onchange, onmove, onselect }, ['select', 'change', 'move'])
|
|
89
|
-
let wrapper = new ListController(options, value, fields)
|
|
90
|
-
|
|
91
|
-
$effect(() => wrapper.update(options))
|
|
92
|
-
</script>
|
|
93
|
-
|
|
94
|
-
{#snippet defaultItem(item)}
|
|
95
|
-
{item.get('text') || item.get('label') || item.get('name')}
|
|
96
|
-
{/snippet}
|
|
97
|
-
|
|
98
|
-
{#snippet defaultPanel(item)}
|
|
99
|
-
<div data-tabs-content>
|
|
100
|
-
{item.get('content')}
|
|
101
|
-
</div>
|
|
102
|
-
{/snippet}
|
|
103
|
-
|
|
104
|
-
{#snippet defaultEmpty()}
|
|
105
|
-
No tabs available.
|
|
106
|
-
{/snippet}
|
|
107
|
-
|
|
108
|
-
<div
|
|
109
|
-
{...restProps}
|
|
110
|
-
data-tabs-root
|
|
111
|
-
data-orientation={orientation}
|
|
112
|
-
data-position={position}
|
|
113
|
-
data-align={align}
|
|
114
|
-
class={classes}
|
|
115
|
-
role="tablist"
|
|
116
|
-
aria-label={name}
|
|
117
|
-
use:navigator={{ wrapper, orientation }}
|
|
118
|
-
{tabindex}
|
|
119
|
-
onaction={handleAction}
|
|
120
|
-
>
|
|
121
|
-
{#if proxyItems.length === 0}
|
|
122
|
-
<div data-tabs-empty>
|
|
123
|
-
{@render emptyMessage()}
|
|
124
|
-
</div>
|
|
125
|
-
{:else if wrapper.focusedKey === null && value === null}
|
|
126
|
-
<div data-tabs-placeholder>
|
|
127
|
-
{placeholder}
|
|
128
|
-
</div>
|
|
129
|
-
{/if}
|
|
130
|
-
<div data-tabs-list>
|
|
131
|
-
{#each proxyItems as item, index (index)}
|
|
132
|
-
{@const key = getKeyFromPath([index])}
|
|
133
|
-
{@const isSelected = equals(item.value, value)}
|
|
134
|
-
{@const isFocused = wrapper.focusedKey === key}
|
|
135
|
-
<button
|
|
136
|
-
data-tabs-trigger
|
|
137
|
-
data-path={getKeyFromPath([index])}
|
|
138
|
-
role="tab"
|
|
139
|
-
aria-selected={isSelected}
|
|
140
|
-
aria-controls="tab-panel-{index}"
|
|
141
|
-
class:selected={isSelected}
|
|
142
|
-
class:focused={isFocused}
|
|
143
|
-
tabindex="0"
|
|
144
|
-
id={`tab-${index}`}
|
|
145
|
-
>
|
|
146
|
-
{@render tabItemSnippet(item)}
|
|
147
|
-
{#if editable}
|
|
148
|
-
<Icon
|
|
149
|
-
data-icon-remove
|
|
150
|
-
name={tabIcons.close}
|
|
151
|
-
role="button"
|
|
152
|
-
onclick={() => handleRemove(item.value)}
|
|
153
|
-
/>
|
|
154
|
-
{/if}
|
|
155
|
-
</button>
|
|
156
|
-
{/each}
|
|
157
|
-
{#if editable}
|
|
158
|
-
<Icon data-icon-add name={tabIcons.add} role="button" onclick={handleAdd} />
|
|
159
|
-
{/if}
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
|
-
<!-- Tab Panels -->
|
|
163
|
-
{#each proxyItems as item, index (index)}
|
|
164
|
-
{@const isVisible = equals(item.value, value)}
|
|
165
|
-
|
|
166
|
-
<div
|
|
167
|
-
data-tabs-panel
|
|
168
|
-
role="tabpanel"
|
|
169
|
-
id="tab-panel-{index}"
|
|
170
|
-
aria-labelledby="tab-{index}"
|
|
171
|
-
data-panel-active={isVisible}
|
|
172
|
-
>
|
|
173
|
-
{@render tabPanelSnippet(item)}
|
|
174
|
-
</div>
|
|
175
|
-
{/each}
|
|
176
|
-
</div>
|
package/src/Tilt.svelte
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { scaleLinear } from 'd3-scale'
|
|
3
|
-
import { clsx } from 'clsx'
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
maxRotation = 10,
|
|
7
|
-
setBrightness = false,
|
|
8
|
-
perspective = 600,
|
|
9
|
-
class: classNames = undefined,
|
|
10
|
-
children
|
|
11
|
-
} = $props()
|
|
12
|
-
|
|
13
|
-
let width = $state(0)
|
|
14
|
-
let height = $state(0)
|
|
15
|
-
|
|
16
|
-
let rotateX = $state(0)
|
|
17
|
-
let rotateY = $state(0)
|
|
18
|
-
let brightness = $state(1)
|
|
19
|
-
|
|
20
|
-
let scaleX = $derived(scaleLinear().domain([0, height]).range([-maxRotation, maxRotation]))
|
|
21
|
-
let scaleY = $derived(scaleLinear().domain([0, width]).range([maxRotation, -maxRotation]))
|
|
22
|
-
let scaleBrightness = $derived(scaleLinear().domain([0, height]).range([2.0, 1.0]))
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {MouseEvent} e
|
|
27
|
-
*/
|
|
28
|
-
function onMouseMove(e) {
|
|
29
|
-
rotateY = scaleY(e.offsetX)
|
|
30
|
-
rotateX = scaleX(e.offsetY)
|
|
31
|
-
|
|
32
|
-
if (setBrightness) {
|
|
33
|
-
brightness = scaleBrightness(e.offsetY)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
function onMouseLeave() {
|
|
41
|
-
rotateX = 0
|
|
42
|
-
rotateY = 0
|
|
43
|
-
brightness = 1
|
|
44
|
-
}
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
48
|
-
<div
|
|
49
|
-
data-tilt-root
|
|
50
|
-
style:--perspective="{perspective}px"
|
|
51
|
-
style:--rotateX="{rotateX}deg"
|
|
52
|
-
style:--rotateY="{rotateY}deg"
|
|
53
|
-
style:--brightness={brightness}
|
|
54
|
-
class={clsx(
|
|
55
|
-
'[perspective:var(--perspective)]',
|
|
56
|
-
'[&>*]:[transform:rotateX(var(--rotateX))_rotateY(var(--rotateY))]',
|
|
57
|
-
'[&>*]:brightness-[var(--brightness)]',
|
|
58
|
-
classNames
|
|
59
|
-
)}
|
|
60
|
-
bind:clientWidth={width}
|
|
61
|
-
bind:clientHeight={height}
|
|
62
|
-
onmousemove={onMouseMove}
|
|
63
|
-
onmouseleave={onMouseLeave}
|
|
64
|
-
>
|
|
65
|
-
{@render children?.()}
|
|
66
|
-
</div>
|
package/src/Toggle.svelte
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { keyboard } from '@rokkit/actions'
|
|
3
|
-
import Item from './Item.svelte'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} Props
|
|
7
|
-
* @property {any} value
|
|
8
|
-
* @property {string} [class]
|
|
9
|
-
* @property {boolean} [disabled] = false
|
|
10
|
-
* @property {Array<any>} [options]
|
|
11
|
-
* @property {FieldMapper} [mapping]
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** @type {Props} */
|
|
15
|
-
let {
|
|
16
|
-
class: classes = '',
|
|
17
|
-
value = $bindable(null),
|
|
18
|
-
options = [false, true],
|
|
19
|
-
fields,
|
|
20
|
-
disabled = false,
|
|
21
|
-
square = false,
|
|
22
|
-
label = 'toggle',
|
|
23
|
-
onchange
|
|
24
|
-
} = $props()
|
|
25
|
-
|
|
26
|
-
const keyMappings = {
|
|
27
|
-
next: ['ArrowRight', 'ArrowDown'], // button handles space an denter by emitting click event
|
|
28
|
-
prev: ['ArrowLeft', 'ArrowUp']
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function toggle(direction = 1) {
|
|
32
|
-
if (disabled) return
|
|
33
|
-
|
|
34
|
-
let nextIndex
|
|
35
|
-
const index = options.indexOf(value)
|
|
36
|
-
|
|
37
|
-
if (index == -1) {
|
|
38
|
-
nextIndex = direction == -1 ? options.length - 1 : 0
|
|
39
|
-
} else {
|
|
40
|
-
nextIndex = (index + direction + options.length) % options.length
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
value = options[nextIndex]
|
|
44
|
-
onchange?.(value)
|
|
45
|
-
}
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<div data-toggle-root data-disabled={disabled} data-square={square} class={classes}>
|
|
49
|
-
<button
|
|
50
|
-
use:keyboard={keyMappings}
|
|
51
|
-
onnext={() => toggle()}
|
|
52
|
-
onprev={() => toggle(-1)}
|
|
53
|
-
onclick={() => toggle()}
|
|
54
|
-
aria-label={label}
|
|
55
|
-
>
|
|
56
|
-
<Item {value} {fields} />
|
|
57
|
-
</button>
|
|
58
|
-
</div>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { defaultStateIcons } from '@rokkit/core'
|
|
3
|
-
import { vibe } from '@rokkit/states'
|
|
4
|
-
import Toggle from './Toggle.svelte'
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
icons = defaultStateIcons.mode,
|
|
8
|
-
labels = ['Light Mode', 'Dark Mode'],
|
|
9
|
-
square = false
|
|
10
|
-
} = $props()
|
|
11
|
-
|
|
12
|
-
const options = $state([
|
|
13
|
-
{ label: labels[0], value: 'light', icon: icons.light },
|
|
14
|
-
{ label: labels[1], value: 'dark', icon: icons.dark }
|
|
15
|
-
])
|
|
16
|
-
let value = $derived(options.find((x) => x.value === vibe.mode))
|
|
17
|
-
|
|
18
|
-
function update(e) {
|
|
19
|
-
vibe.mode = e.value
|
|
20
|
-
}
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Toggle {value} {options} onchange={update} {square} />
|
package/src/Tree.svelte
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { createEmitter, defaultFields } from '@rokkit/core'
|
|
3
|
-
import { navigator } from '@rokkit/actions'
|
|
4
|
-
import NestedList from './NestedList.svelte'
|
|
5
|
-
import { NestedController } from '@rokkit/states'
|
|
6
|
-
import { omit, has } from 'ramda'
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} Props
|
|
9
|
-
* @property {string} [class]
|
|
10
|
-
* @property {Array<any>} [items]
|
|
11
|
-
* @property {any} [value]
|
|
12
|
-
* @property {import('@rokkit/core').FieldMapping} [mapping]
|
|
13
|
-
* @property {import('./types').NodeStateIcons|Object} [icons]
|
|
14
|
-
* @property {boolean} [autoCloseSiblings=false]
|
|
15
|
-
* @property {boolean} [multiselect=false]
|
|
16
|
-
* @property {Function} [header]
|
|
17
|
-
* @property {Function} [footer]
|
|
18
|
-
* @property {Function} [empty]
|
|
19
|
-
* @property {Function} [stub]
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/** @type {Props & { [key: string]: any }} */
|
|
23
|
-
let {
|
|
24
|
-
class: classes = 'h-full overflow-scroll flex flex-col',
|
|
25
|
-
items = $bindable([]),
|
|
26
|
-
value = $bindable(null),
|
|
27
|
-
fields,
|
|
28
|
-
icons = {},
|
|
29
|
-
autoCloseSiblings = false,
|
|
30
|
-
multiselect = false,
|
|
31
|
-
header,
|
|
32
|
-
footer,
|
|
33
|
-
empty,
|
|
34
|
-
stub,
|
|
35
|
-
...events
|
|
36
|
-
} = $props()
|
|
37
|
-
|
|
38
|
-
let emitter = createEmitter(events, ['select', 'move', 'toggle'])
|
|
39
|
-
let wrapper = new NestedController(items, value, fields, { autoCloseSiblings, multiselect })
|
|
40
|
-
let snippets = omit(['onselect', 'onmove', 'ontoggle'], events)
|
|
41
|
-
let derivedFields = $derived({ ...defaultFields, ...fields })
|
|
42
|
-
|
|
43
|
-
function handleAction(event) {
|
|
44
|
-
const { name, data } = event.detail
|
|
45
|
-
if (name === 'select') value = data.value
|
|
46
|
-
if (has([name], emitter)) emitter[name](data)
|
|
47
|
-
}
|
|
48
|
-
</script>
|
|
49
|
-
|
|
50
|
-
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
51
|
-
<rk-tree
|
|
52
|
-
tabindex="0"
|
|
53
|
-
class={classes}
|
|
54
|
-
use:navigator={{ wrapper, nested: true }}
|
|
55
|
-
onaction={handleAction}
|
|
56
|
-
>
|
|
57
|
-
{#if header}
|
|
58
|
-
<rk-header>{@render header()}</rk-header>
|
|
59
|
-
{/if}
|
|
60
|
-
{#if items.length === 0}
|
|
61
|
-
{#if empty}
|
|
62
|
-
{@render empty()}
|
|
63
|
-
{:else}
|
|
64
|
-
<div class="m-auto p-4 text-center text-gray-500">No data available</div>
|
|
65
|
-
{/if}
|
|
66
|
-
{/if}
|
|
67
|
-
<NestedList
|
|
68
|
-
{items}
|
|
69
|
-
fields={derivedFields}
|
|
70
|
-
{value}
|
|
71
|
-
{icons}
|
|
72
|
-
focusedKey={wrapper.currentKey}
|
|
73
|
-
selectedKeys={wrapper.selectedKeys}
|
|
74
|
-
{stub}
|
|
75
|
-
{snippets}
|
|
76
|
-
/>
|
|
77
|
-
{#if footer}
|
|
78
|
-
<rk-footer>{@render footer()}</rk-footer>
|
|
79
|
-
{/if}
|
|
80
|
-
</rk-tree>
|