@svelte-atoms/core 1.0.0-alpha.30 → 1.0.0-alpha.32
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/LICENSE +21 -0
- package/README.md +176 -739
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.js +1 -0
- package/dist/components/accordion/accordion-root.svelte +65 -61
- package/dist/components/accordion/accordion.stories.svelte +70 -145
- package/dist/components/accordion/item/accordion-item-body.svelte +6 -4
- package/dist/components/accordion/item/accordion-item-header.svelte +2 -1
- package/dist/components/accordion/item/accordion-item-indicator.svelte +2 -1
- package/dist/components/accordion/item/accordion-item-root.svelte +2 -1
- package/dist/components/accordion/item/bond.svelte.d.ts +2 -0
- package/dist/components/accordion/item/index.d.ts +3 -0
- package/dist/components/accordion/item/index.js +3 -0
- package/dist/components/accordion/item/motion.svelte.d.ts +15 -0
- package/dist/components/accordion/item/motion.svelte.js +30 -0
- package/dist/components/accordion/item/types.d.ts +7 -24
- package/dist/components/alert/alert-close-button.svelte +32 -36
- package/dist/components/alert/alert-description.svelte +1 -1
- package/dist/components/alert/alert-description.svelte.d.ts +3 -6
- package/dist/components/alert/alert-root.svelte +3 -38
- package/dist/components/alert/alert-root.svelte.d.ts +2 -2
- package/dist/components/alert/alert.stories.svelte +400 -400
- package/dist/components/alert/bond.svelte.d.ts +0 -13
- package/dist/components/alert/bond.svelte.js +0 -32
- package/dist/components/alert/types.d.ts +8 -32
- package/dist/components/atom/html-atom.svelte +93 -261
- package/dist/components/atom/types.d.ts +3 -2
- package/dist/components/atom/utils.d.ts +37 -0
- package/dist/components/atom/utils.js +208 -0
- package/dist/components/avatar/avatar.stories.svelte +22 -22
- package/dist/components/badge/badge.stories.svelte +12 -12
- package/dist/components/badge/badge.svelte +19 -19
- package/dist/components/breadcrumb/breadcrumb-item.svelte +1 -1
- package/dist/components/breadcrumb/breadcrumb-separator.svelte +5 -1
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -16
- package/dist/components/button/button.stories.svelte +27 -27
- package/dist/components/calendar/calendar-day.svelte +9 -4
- package/dist/components/calendar/calendar.stories.svelte +26 -26
- package/dist/components/card/card-body.svelte +39 -39
- package/dist/components/card/card-footer.svelte +41 -41
- package/dist/components/card/card-root.svelte +91 -91
- package/dist/components/card/card.stories.svelte +133 -133
- package/dist/components/checkbox/checkbox.stories.svelte +22 -22
- package/dist/components/checkbox/checkbox.svelte +159 -155
- package/dist/components/collapsible/bond.svelte.js +2 -1
- package/dist/components/collapsible/collapsible-body.svelte +3 -2
- package/dist/components/collapsible/collapsible.stories.svelte +172 -172
- package/dist/components/collapsible/motion.svelte.d.ts +6 -0
- package/dist/components/collapsible/motion.svelte.js +15 -0
- package/dist/components/combobox/atoms.d.ts +3 -3
- package/dist/components/combobox/atoms.js +3 -3
- package/dist/components/combobox/bond.svelte.d.ts +6 -6
- package/dist/components/combobox/bond.svelte.js +3 -26
- package/dist/components/combobox/combobox-control.svelte +52 -52
- package/dist/components/combobox/{compobox-item.svelte → combobox-item.svelte} +62 -68
- package/dist/components/combobox/combobox-item.svelte.d.ts +12 -0
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/combobox/combobox.stories.svelte +50 -0
- package/dist/components/combobox/combobox.stories.svelte.d.ts +3 -0
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/container/container.stories.svelte +20 -20
- package/dist/components/container/container.svelte.d.ts +1 -1
- package/dist/components/datagrid/datagrid.stories.svelte +72 -72
- package/dist/components/datagrid/tr/bond.svelte.d.ts +4 -2
- package/dist/components/datagrid/tr/bond.svelte.js +9 -7
- package/dist/components/datagrid/tr/datagrid-tr.svelte +9 -7
- package/dist/components/date-picker/bond.svelte.d.ts +15 -5
- package/dist/components/date-picker/bond.svelte.js +5 -11
- package/dist/components/date-picker/date-picker-calendar.svelte +2 -2
- package/dist/components/date-picker/date-picker-root.svelte +95 -95
- package/dist/components/date-picker/date-picker.stories.svelte +35 -35
- package/dist/components/dialog/bond.svelte.d.ts +13 -3
- package/dist/components/dialog/bond.svelte.js +52 -6
- package/dist/components/dialog/dialog-content.svelte +2 -20
- package/dist/components/dialog/dialog-root.svelte +3 -22
- package/dist/components/dialog/dialog.stories.svelte +64 -64
- package/dist/components/dialog/motion.svelte.d.ts +13 -0
- package/dist/components/dialog/motion.svelte.js +44 -0
- package/dist/components/drawer/attachments.svelte.d.ts +1 -1
- package/dist/components/drawer/attachments.svelte.js +1 -3
- package/dist/components/drawer/bond.svelte.d.ts +30 -9
- package/dist/components/drawer/bond.svelte.js +80 -24
- package/dist/components/drawer/drawer-content.svelte +49 -57
- package/dist/components/drawer/drawer-root.svelte +5 -4
- package/dist/components/drawer/drawer.stories.svelte +141 -212
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/drawer/motion.d.ts +15 -0
- package/dist/components/drawer/motion.js +28 -0
- package/dist/components/dropdown/atoms.d.ts +1 -1
- package/dist/components/dropdown/atoms.js +1 -1
- package/dist/components/dropdown/bond.svelte.d.ts +22 -19
- package/dist/components/dropdown/bond.svelte.js +29 -53
- package/dist/components/dropdown/dropdown-root.svelte +7 -1
- package/dist/components/dropdown/dropdown-values.svelte +17 -17
- package/dist/components/dropdown/dropdown-values.svelte.d.ts +1 -2
- package/dist/components/dropdown/dropdown.stories.svelte +13 -10
- package/dist/components/dropdown/index.d.ts +2 -0
- package/dist/components/dropdown/index.js +1 -0
- package/dist/components/dropdown/item/attachments.svelte.d.ts +2 -2
- package/dist/components/dropdown/item/attachments.svelte.js +2 -2
- package/dist/components/dropdown/item/controller.svelte.d.ts +34 -0
- package/dist/components/dropdown/item/controller.svelte.js +82 -0
- package/dist/components/dropdown/item/dropdown-item.svelte +109 -102
- package/dist/components/dropdown/item/dropdown-item.svelte.d.ts +13 -28
- package/dist/components/dropdown/item/index.d.ts +3 -0
- package/dist/components/dropdown/item/index.js +3 -0
- package/dist/components/dropdown/item/types.d.ts +29 -0
- package/dist/components/dropdown/item/types.js +1 -0
- package/dist/components/form/form.stories.svelte +96 -96
- package/dist/components/image/image.stories.svelte +20 -20
- package/dist/components/input/input.stories.svelte +35 -35
- package/dist/components/label/label.stories.svelte +15 -15
- package/dist/components/lazy/lazy.stories.svelte +28 -28
- package/dist/components/link/link.stories.svelte +15 -15
- package/dist/components/list/list-item.svelte +2 -2
- package/dist/components/menu/atoms.d.ts +9 -3
- package/dist/components/menu/atoms.js +9 -3
- package/dist/components/menu/bond.svelte.d.ts +54 -0
- package/dist/components/menu/bond.svelte.js +132 -0
- package/dist/components/menu/index.d.ts +3 -1
- package/dist/components/menu/index.js +2 -1
- package/dist/components/menu/item/controller.svelte.d.ts +26 -0
- package/dist/components/menu/item/controller.svelte.js +69 -0
- package/dist/components/menu/item/index.d.ts +2 -0
- package/dist/components/menu/item/index.js +2 -0
- package/dist/components/menu/item/menu-item.svelte +103 -0
- package/dist/components/menu/item/menu-item.svelte.d.ts +31 -0
- package/dist/components/menu/item/types.d.ts +62 -0
- package/dist/components/menu/item/types.js +1 -0
- package/dist/components/menu/{menu-list.svelte → menu-content.svelte} +40 -40
- package/dist/components/menu/{menu-list.svelte.d.ts → menu-content.svelte.d.ts} +3 -3
- package/dist/components/menu/menu-root.svelte +15 -0
- package/dist/components/menu/menu-root.svelte.d.ts +8 -0
- package/dist/components/menu/menu.stories.svelte +5 -5
- package/dist/components/menu/types.d.ts +0 -7
- package/dist/components/popover/bond.svelte.d.ts +18 -8
- package/dist/components/popover/bond.svelte.js +76 -40
- package/dist/components/popover/motion.d.ts +6 -0
- package/dist/components/popover/motion.js +56 -0
- package/dist/components/popover/popover-arrow.svelte +111 -111
- package/dist/components/popover/popover-content.svelte +137 -175
- package/dist/components/popover/popover-indicator.svelte +44 -44
- package/dist/components/popover/popover-root.svelte +48 -48
- package/dist/components/popover/popover.stories.svelte +37 -49
- package/dist/components/popover/types.d.ts +9 -7
- package/dist/components/portal/active-portal.svelte +12 -5
- package/dist/components/portal/active-portal.svelte.d.ts +2 -9
- package/dist/components/portal/portal-root.svelte +1 -8
- package/dist/components/portal/portal-root.svelte.d.ts +4 -6
- package/dist/components/portal/teleport.svelte +1 -2
- package/dist/components/portal/teleport.svelte.d.ts +3 -4
- package/dist/components/qr-code/qr-code.stories.svelte +18 -18
- package/dist/components/radio/radio-group.stories.svelte +41 -41
- package/dist/components/radio/radio.stories.svelte +17 -17
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/radio/types.d.ts +98 -0
- package/dist/components/radio/types.js +2 -0
- package/dist/components/root/index.d.ts +1 -0
- package/dist/components/root/index.js +1 -0
- package/dist/components/root/l0-portal.svelte +8 -0
- package/dist/components/{radio/types.svelte.d.ts → root/l0-portal.svelte.d.ts} +3 -3
- package/dist/components/root/l1-portal.svelte +7 -0
- package/dist/components/root/l1-portal.svelte.d.ts +26 -0
- package/dist/components/root/root.css +119 -119
- package/dist/components/root/root.svelte +26 -44
- package/dist/components/root/root.svelte.d.ts +2 -6
- package/dist/components/root/toasts-portal.svelte +7 -0
- package/dist/components/root/toasts-portal.svelte.d.ts +26 -0
- package/dist/components/root/types.d.ts +17 -0
- package/dist/components/scrollable/scrollable-root.svelte.d.ts +2 -2
- package/dist/components/scrollable/scrollable.stories.svelte +116 -116
- package/dist/components/sidebar/index.d.ts +2 -0
- package/dist/components/sidebar/index.js +2 -0
- package/dist/components/sidebar/motion.svelte.d.ts +11 -0
- package/dist/components/sidebar/motion.svelte.js +16 -0
- package/dist/components/sidebar/sidebar-content.svelte +40 -50
- package/dist/components/sidebar/sidebar-root.svelte +39 -39
- package/dist/components/sidebar/sidebar.stories.svelte +43 -43
- package/dist/components/sidebar/types.d.ts +2 -12
- package/dist/components/tabs/tabs.stories.svelte +56 -56
- package/dist/components/textarea/atoms.d.ts +1 -0
- package/dist/components/textarea/atoms.js +1 -0
- package/dist/components/textarea/textarea-input.svelte +4 -1
- package/dist/components/textarea/textarea-root.svelte +2 -2
- package/dist/components/textarea/textarea-root.svelte.d.ts +2 -0
- package/dist/components/tooltip/tooltip-trigger.svelte +39 -39
- package/dist/components/tooltip/tooltip-trigger.svelte.d.ts +1 -0
- package/dist/components/tooltip/tooltip.stories.svelte +32 -32
- package/dist/components/tree/index.d.ts +1 -0
- package/dist/components/tree/index.js +1 -0
- package/dist/components/tree/motion.svelte.d.ts +6 -0
- package/dist/components/tree/motion.svelte.js +14 -0
- package/dist/components/tree/tree-body.svelte +4 -3
- package/dist/components/tree/tree.stories.svelte +142 -142
- package/dist/context/preset.svelte.d.ts +3 -1
- package/dist/icons/icon-copy.svelte +6 -0
- package/dist/icons/icon-copy.svelte.d.ts +26 -0
- package/dist/utils/dom.svelte.d.ts +2 -0
- package/dist/utils/dom.svelte.js +21 -0
- package/dist/utils/function.d.ts +1 -1
- package/dist/utils/promise.svelte.d.ts +5 -0
- package/dist/utils/promise.svelte.js +20 -0
- package/package.json +4 -3
- package/dist/components/combobox/compobox-item.svelte.d.ts +0 -34
- package/dist/components/combobox/compobox.stories.svelte +0 -51
- package/dist/components/combobox/compobox.stories.svelte.d.ts +0 -3
- package/dist/components/dropdown/item/bond.svelte.d.ts +0 -42
- package/dist/components/dropdown/item/bond.svelte.js +0 -99
- package/dist/components/menu/menu-item.svelte +0 -51
- package/dist/components/menu/menu-item.svelte.d.ts +0 -36
- package/dist/components/radio/types.svelte +0 -0
- package/llm/composition.md +0 -395
- package/llm/crafting.md +0 -838
- package/llm/motion.md +0 -970
- package/llm/philosophy.md +0 -23
- package/llm/preset-variant-integration.md +0 -516
- package/llm/preset.md +0 -383
- package/llm/styling.md +0 -216
- package/llm/usage.md +0 -46
- package/llm/variants.md +0 -1259
|
@@ -1,68 +1,62 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
bond
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
{bond}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
onmount={onmount?.bind(bond.state)}
|
|
64
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
65
|
-
{...restProps}
|
|
66
|
-
>
|
|
67
|
-
{@render children?.({ combobox: bond })}
|
|
68
|
-
</Item>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ComboboxBond } from './bond.svelte';
|
|
3
|
+
import { Item } from '../dropdown/atoms';
|
|
4
|
+
import { DropdownItemController } from '../dropdown/item/controller.svelte';
|
|
5
|
+
|
|
6
|
+
import { on } from '../../attachments';
|
|
7
|
+
|
|
8
|
+
const bond = ComboboxBond.get() as ComboboxBond<{}>;
|
|
9
|
+
|
|
10
|
+
if (!bond) {
|
|
11
|
+
throw new Error('Combobox atom was not found');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
class: klass = '',
|
|
16
|
+
children = undefined,
|
|
17
|
+
onmount = undefined,
|
|
18
|
+
ondestroy = undefined,
|
|
19
|
+
animate = undefined,
|
|
20
|
+
enter = undefined,
|
|
21
|
+
exit = undefined,
|
|
22
|
+
initial = undefined,
|
|
23
|
+
...restProps
|
|
24
|
+
} = $props();
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<Item
|
|
28
|
+
{@attach (node: HTMLElement) => {
|
|
29
|
+
const item = DropdownItemController.get();
|
|
30
|
+
|
|
31
|
+
return on('click', (ev) => {
|
|
32
|
+
ev.preventDefault();
|
|
33
|
+
|
|
34
|
+
const currentTarget = ev.currentTarget as HTMLElement | undefined;
|
|
35
|
+
|
|
36
|
+
const textElement = (currentTarget?.querySelector('data-text') ?? currentTarget) as
|
|
37
|
+
| HTMLElement
|
|
38
|
+
| undefined;
|
|
39
|
+
|
|
40
|
+
// Set selected item text
|
|
41
|
+
bond.state.props.text = textElement?.innerText ?? '';
|
|
42
|
+
// Clear input query
|
|
43
|
+
bond.state.props.query = '';
|
|
44
|
+
|
|
45
|
+
item?.toggle();
|
|
46
|
+
|
|
47
|
+
bond?.state.close();
|
|
48
|
+
})(node);
|
|
49
|
+
}}
|
|
50
|
+
{bond}
|
|
51
|
+
preset="combobox.item"
|
|
52
|
+
class={['border-border', '$preset', klass].filter(Boolean).join(' ')}
|
|
53
|
+
enter={enter?.bind(bond.state)}
|
|
54
|
+
exit={exit?.bind(bond.state)}
|
|
55
|
+
initial={initial?.bind(bond.state)}
|
|
56
|
+
animate={animate?.bind(bond.state)}
|
|
57
|
+
onmount={onmount?.bind(bond.state)}
|
|
58
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
59
|
+
{...restProps}
|
|
60
|
+
>
|
|
61
|
+
{@render children?.({ combobox: bond })}
|
|
62
|
+
</Item>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const ComboboxItem: import("svelte").Component<{
|
|
2
|
+
class?: string;
|
|
3
|
+
children?: any;
|
|
4
|
+
onmount?: any;
|
|
5
|
+
ondestroy?: any;
|
|
6
|
+
animate?: any;
|
|
7
|
+
enter?: any;
|
|
8
|
+
exit?: any;
|
|
9
|
+
initial?: any;
|
|
10
|
+
} & Record<string, any>, {}, "">;
|
|
11
|
+
type ComboboxItem = ReturnType<typeof ComboboxItem>;
|
|
12
|
+
export default ComboboxItem;
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
<script lang="ts" generics="D">
|
|
2
|
-
import type { ComboboxRootProps } from './types';
|
|
3
|
-
import { defineProperty, defineState } from '../../utils';
|
|
4
|
-
import { ComboboxBond, ComboboxBondState, type ComboboxBondProps } from './bond.svelte';
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
open = $bindable(false),
|
|
8
|
-
value = $bindable(),
|
|
9
|
-
values = $bindable(),
|
|
10
|
-
query = $bindable(),
|
|
11
|
-
text = $bindable(),
|
|
12
|
-
multiple = false,
|
|
13
|
-
disabled = false,
|
|
14
|
-
placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
15
|
-
placement = 'bottom-start',
|
|
16
|
-
offset = 1,
|
|
17
|
-
factory = _factory,
|
|
18
|
-
children = undefined,
|
|
19
|
-
...restProps
|
|
20
|
-
}: ComboboxRootProps = $props();
|
|
21
|
-
|
|
22
|
-
const bondProps = defineState<ComboboxBondProps>(
|
|
23
|
-
[
|
|
24
|
-
defineProperty(
|
|
25
|
-
'open',
|
|
26
|
-
() => open,
|
|
27
|
-
(v) => {
|
|
28
|
-
open = v;
|
|
29
|
-
}
|
|
30
|
-
),
|
|
31
|
-
defineProperty(
|
|
32
|
-
'values',
|
|
33
|
-
() => (multiple ? values : [value]),
|
|
34
|
-
(v) => {
|
|
35
|
-
values = v;
|
|
36
|
-
value = v[0];
|
|
37
|
-
}
|
|
38
|
-
),
|
|
39
|
-
defineProperty(
|
|
40
|
-
'query',
|
|
41
|
-
() => query,
|
|
42
|
-
(v) => (query = v)
|
|
43
|
-
),
|
|
44
|
-
defineProperty(
|
|
45
|
-
'text',
|
|
46
|
-
() => text,
|
|
47
|
-
(v) => (text = v)
|
|
48
|
-
)
|
|
49
|
-
],
|
|
50
|
-
() => ({ disabled, multiple, placements, offset, placement: 'bottom-start', ...restProps })
|
|
51
|
-
);
|
|
52
|
-
const bond = factory(bondProps).share();
|
|
53
|
-
|
|
54
|
-
function _factory(props: typeof bondProps) {
|
|
55
|
-
const bondState = new ComboboxBondState<D>(() => props);
|
|
56
|
-
|
|
57
|
-
return new ComboboxBond(bondState).share();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function getBond() {
|
|
61
|
-
return bond;
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
{@render children?.({ combobox: bond })}
|
|
1
|
+
<script lang="ts" generics="D">
|
|
2
|
+
import type { ComboboxRootProps } from './types';
|
|
3
|
+
import { defineProperty, defineState } from '../../utils';
|
|
4
|
+
import { ComboboxBond, ComboboxBondState, type ComboboxBondProps } from './bond.svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
open = $bindable(false),
|
|
8
|
+
value = $bindable(),
|
|
9
|
+
values = $bindable(),
|
|
10
|
+
query = $bindable(),
|
|
11
|
+
text = $bindable(),
|
|
12
|
+
multiple = false,
|
|
13
|
+
disabled = false,
|
|
14
|
+
placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
15
|
+
placement = 'bottom-start',
|
|
16
|
+
offset = 1,
|
|
17
|
+
factory = _factory,
|
|
18
|
+
children = undefined,
|
|
19
|
+
...restProps
|
|
20
|
+
}: ComboboxRootProps = $props();
|
|
21
|
+
|
|
22
|
+
const bondProps = defineState<ComboboxBondProps>(
|
|
23
|
+
[
|
|
24
|
+
defineProperty(
|
|
25
|
+
'open',
|
|
26
|
+
() => open,
|
|
27
|
+
(v) => {
|
|
28
|
+
open = v;
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
defineProperty(
|
|
32
|
+
'values',
|
|
33
|
+
() => (multiple ? values : [value]),
|
|
34
|
+
(v) => {
|
|
35
|
+
values = v;
|
|
36
|
+
value = v[0];
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
defineProperty(
|
|
40
|
+
'query',
|
|
41
|
+
() => query,
|
|
42
|
+
(v) => (query = v)
|
|
43
|
+
),
|
|
44
|
+
defineProperty(
|
|
45
|
+
'text',
|
|
46
|
+
() => text,
|
|
47
|
+
(v) => (text = v)
|
|
48
|
+
)
|
|
49
|
+
],
|
|
50
|
+
() => ({ disabled, multiple, placements, offset, placement: 'bottom-start', ...restProps })
|
|
51
|
+
);
|
|
52
|
+
const bond = factory(bondProps).share();
|
|
53
|
+
|
|
54
|
+
function _factory(props: typeof bondProps) {
|
|
55
|
+
const bondState = new ComboboxBondState<D>(() => props);
|
|
56
|
+
|
|
57
|
+
return new ComboboxBond(bondState).share();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getBond() {
|
|
61
|
+
return bond;
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
{@render children?.({ combobox: bond })}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Combobox as ACombobox } from '.';
|
|
4
|
+
import { Input } from '../input';
|
|
5
|
+
import { Divider } from '../divider';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Atoms/Combobox',
|
|
10
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
+
|
|
12
|
+
parameters: {
|
|
13
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
+
layout: 'fullscreen'
|
|
15
|
+
},
|
|
16
|
+
args: {}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
let open = $state(false);
|
|
22
|
+
let value = $state<string | undefined>('usd');
|
|
23
|
+
let query = $state('');
|
|
24
|
+
let array = $state([
|
|
25
|
+
{ value: 'usd', label: 'US Dollar' },
|
|
26
|
+
{ value: 'eur', label: 'Euro' },
|
|
27
|
+
{ value: 'gbp', label: 'British Pound' },
|
|
28
|
+
{ value: 'jpy', label: 'Japanese Yen' },
|
|
29
|
+
{ value: 'cny', label: 'Chinese Yuan' }
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
const filteredItems = $derived(
|
|
33
|
+
array.filter((item) => !query || item.label.toLowerCase().includes(query))
|
|
34
|
+
);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<Story name="Combobox" args={{}}>
|
|
38
|
+
<ACombobox.Root bind:open bind:value bind:query>
|
|
39
|
+
<ACombobox.Trigger base={Input.Root} class="h-10 min-w-sm">
|
|
40
|
+
<Input.Icon class="text-foreground/50">$</Input.Icon>
|
|
41
|
+
<Divider class="mx-1" vertical />
|
|
42
|
+
<ACombobox.Control class="px-1" placeholder="Select a language" />
|
|
43
|
+
</ACombobox.Trigger>
|
|
44
|
+
<ACombobox.List>
|
|
45
|
+
{#each filteredItems as item (item.value)}
|
|
46
|
+
<ACombobox.Item value={item.value}>{item.label}</ACombobox.Item>
|
|
47
|
+
{/each}
|
|
48
|
+
</ACombobox.List>
|
|
49
|
+
</ACombobox.Root>
|
|
50
|
+
</Story>
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import ContainerCmp from './container.svelte';
|
|
4
|
-
|
|
5
|
-
const { Story } = defineMeta({
|
|
6
|
-
title: 'ATOMS/Container'
|
|
7
|
-
});
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<Story name="Container">
|
|
11
|
-
<ContainerCmp class="flex w-full flex-col items-center gap-4">
|
|
12
|
-
<div class="flex w-full gap-4">
|
|
13
|
-
{#each { length: 5 } as _, i (i)}
|
|
14
|
-
<div class="bg-foreground h-80 flex-1 rounded-lg"></div>
|
|
15
|
-
{/each}
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<div class="bg-foreground h-80 w-[50cqw] rounded-lg"></div>
|
|
19
|
-
</ContainerCmp>
|
|
20
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import ContainerCmp from './container.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'ATOMS/Container'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Story name="Container">
|
|
11
|
+
<ContainerCmp class="flex w-full flex-col items-center gap-4">
|
|
12
|
+
<div class="flex w-full gap-4">
|
|
13
|
+
{#each { length: 5 } as _, i (i)}
|
|
14
|
+
<div class="bg-foreground h-80 flex-1 rounded-lg"></div>
|
|
15
|
+
{/each}
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="bg-foreground h-80 w-[50cqw] rounded-lg"></div>
|
|
19
|
+
</ContainerCmp>
|
|
20
|
+
</Story>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ContainerProps } from './types';
|
|
2
|
-
declare const Container: import("svelte").Component<ContainerProps, {}, "
|
|
2
|
+
declare const Container: import("svelte").Component<ContainerProps, {}, "clientHeight" | "clientWidth">;
|
|
3
3
|
type Container = ReturnType<typeof Container>;
|
|
4
4
|
export default Container;
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { DataGrid as DataGridCmp } from '.';
|
|
4
|
-
import { Dropdown } from '../dropdown';
|
|
5
|
-
import MoreVerticalIcon from '../../icons/icon-more-vert.svelte';
|
|
6
|
-
import { Icon } from '../icon';
|
|
7
|
-
import { container } from '../../runes/container.svelte';
|
|
8
|
-
|
|
9
|
-
const { Story } = defineMeta({
|
|
10
|
-
title: 'Atoms/DataGrid'
|
|
11
|
-
});
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<script>
|
|
15
|
-
let values = $state([]);
|
|
16
|
-
|
|
17
|
-
const datagridContainer = container();
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<Story name="DataGrid">
|
|
21
|
-
{#snippet children({ args })}
|
|
22
|
-
<DataGridCmp.Root class="" {@attach datagridContainer.attach}>
|
|
23
|
-
<DataGridCmp.Header>
|
|
24
|
-
<DataGridCmp.Tr header>
|
|
25
|
-
<DataGridCmp.Th width="auto">
|
|
26
|
-
<DataGridCmp.Checkbox />
|
|
27
|
-
</DataGridCmp.Th>
|
|
28
|
-
<DataGridCmp.Th
|
|
29
|
-
class="resize-x overflow-x-auto"
|
|
30
|
-
width="auto"
|
|
31
|
-
hidden={datagridContainer.current?.width
|
|
32
|
-
? datagridContainer.current.width < 1024
|
|
33
|
-
: false}>ID</DataGridCmp.Th
|
|
34
|
-
>
|
|
35
|
-
<DataGridCmp.Th>Name</DataGridCmp.Th>
|
|
36
|
-
<DataGridCmp.Th width="auto">Job</DataGridCmp.Th>
|
|
37
|
-
<DataGridCmp.Th width="auto">Contact</DataGridCmp.Th>
|
|
38
|
-
<DataGridCmp.Th width="auto"></DataGridCmp.Th>
|
|
39
|
-
</DataGridCmp.Tr>
|
|
40
|
-
</DataGridCmp.Header>
|
|
41
|
-
|
|
42
|
-
<DataGridCmp.Body>
|
|
43
|
-
{#each { length: 10 } as _, i (i)}
|
|
44
|
-
<DataGridCmp.Tr>
|
|
45
|
-
<DataGridCmp.Td>
|
|
46
|
-
<DataGridCmp.Checkbox />
|
|
47
|
-
</DataGridCmp.Td>
|
|
48
|
-
|
|
49
|
-
<DataGridCmp.Td>{crypto.randomUUID()}</DataGridCmp.Td>
|
|
50
|
-
<DataGridCmp.Td>John Doe</DataGridCmp.Td>
|
|
51
|
-
<DataGridCmp.Td>Software Engineer</DataGridCmp.Td>
|
|
52
|
-
<DataGridCmp.Td>+213659009944</DataGridCmp.Td>
|
|
53
|
-
|
|
54
|
-
<DataGridCmp.Td base={Dropdown.Root} placement="bottom-end" offset={0}>
|
|
55
|
-
<Dropdown.Trigger class="flex aspect-square items-center justify-center p-0">
|
|
56
|
-
<Icon src={MoreVerticalIcon} />
|
|
57
|
-
</Dropdown.Trigger>
|
|
58
|
-
<Dropdown.List>
|
|
59
|
-
<Dropdown.Item value="ar">Arabic</Dropdown.Item>
|
|
60
|
-
<Dropdown.Item value="en">English</Dropdown.Item>
|
|
61
|
-
<Dropdown.Item value="sp">Spanish</Dropdown.Item>
|
|
62
|
-
<Dropdown.Item value="fr">Frensh</Dropdown.Item>
|
|
63
|
-
</Dropdown.List>
|
|
64
|
-
</DataGridCmp.Td>
|
|
65
|
-
</DataGridCmp.Tr>
|
|
66
|
-
{/each}
|
|
67
|
-
</DataGridCmp.Body>
|
|
68
|
-
|
|
69
|
-
<DataGridCmp.Footer></DataGridCmp.Footer>
|
|
70
|
-
</DataGridCmp.Root>
|
|
71
|
-
{/snippet}
|
|
72
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { DataGrid as DataGridCmp } from '.';
|
|
4
|
+
import { Dropdown } from '../dropdown';
|
|
5
|
+
import MoreVerticalIcon from '../../icons/icon-more-vert.svelte';
|
|
6
|
+
import { Icon } from '../icon';
|
|
7
|
+
import { container } from '../../runes/container.svelte';
|
|
8
|
+
|
|
9
|
+
const { Story } = defineMeta({
|
|
10
|
+
title: 'Atoms/DataGrid'
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
let values = $state([]);
|
|
16
|
+
|
|
17
|
+
const datagridContainer = container();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Story name="DataGrid">
|
|
21
|
+
{#snippet children({ args })}
|
|
22
|
+
<DataGridCmp.Root class="" {@attach datagridContainer.attach}>
|
|
23
|
+
<DataGridCmp.Header>
|
|
24
|
+
<DataGridCmp.Tr header>
|
|
25
|
+
<DataGridCmp.Th width="auto">
|
|
26
|
+
<DataGridCmp.Checkbox />
|
|
27
|
+
</DataGridCmp.Th>
|
|
28
|
+
<DataGridCmp.Th
|
|
29
|
+
class="resize-x overflow-x-auto"
|
|
30
|
+
width="auto"
|
|
31
|
+
hidden={datagridContainer.current?.width
|
|
32
|
+
? datagridContainer.current.width < 1024
|
|
33
|
+
: false}>ID</DataGridCmp.Th
|
|
34
|
+
>
|
|
35
|
+
<DataGridCmp.Th>Name</DataGridCmp.Th>
|
|
36
|
+
<DataGridCmp.Th width="auto">Job</DataGridCmp.Th>
|
|
37
|
+
<DataGridCmp.Th width="auto">Contact</DataGridCmp.Th>
|
|
38
|
+
<DataGridCmp.Th width="auto"></DataGridCmp.Th>
|
|
39
|
+
</DataGridCmp.Tr>
|
|
40
|
+
</DataGridCmp.Header>
|
|
41
|
+
|
|
42
|
+
<DataGridCmp.Body>
|
|
43
|
+
{#each { length: 10 } as _, i (i)}
|
|
44
|
+
<DataGridCmp.Tr>
|
|
45
|
+
<DataGridCmp.Td>
|
|
46
|
+
<DataGridCmp.Checkbox />
|
|
47
|
+
</DataGridCmp.Td>
|
|
48
|
+
|
|
49
|
+
<DataGridCmp.Td>{crypto.randomUUID()}</DataGridCmp.Td>
|
|
50
|
+
<DataGridCmp.Td>John Doe</DataGridCmp.Td>
|
|
51
|
+
<DataGridCmp.Td>Software Engineer</DataGridCmp.Td>
|
|
52
|
+
<DataGridCmp.Td>+213659009944</DataGridCmp.Td>
|
|
53
|
+
|
|
54
|
+
<DataGridCmp.Td base={Dropdown.Root} placement="bottom-end" offset={0}>
|
|
55
|
+
<Dropdown.Trigger class="flex aspect-square items-center justify-center p-0">
|
|
56
|
+
<Icon src={MoreVerticalIcon} />
|
|
57
|
+
</Dropdown.Trigger>
|
|
58
|
+
<Dropdown.List>
|
|
59
|
+
<Dropdown.Item value="ar">Arabic</Dropdown.Item>
|
|
60
|
+
<Dropdown.Item value="en">English</Dropdown.Item>
|
|
61
|
+
<Dropdown.Item value="sp">Spanish</Dropdown.Item>
|
|
62
|
+
<Dropdown.Item value="fr">Frensh</Dropdown.Item>
|
|
63
|
+
</Dropdown.List>
|
|
64
|
+
</DataGridCmp.Td>
|
|
65
|
+
</DataGridCmp.Tr>
|
|
66
|
+
{/each}
|
|
67
|
+
</DataGridCmp.Body>
|
|
68
|
+
|
|
69
|
+
<DataGridCmp.Footer></DataGridCmp.Footer>
|
|
70
|
+
</DataGridCmp.Root>
|
|
71
|
+
{/snippet}
|
|
72
|
+
</Story>
|
|
@@ -15,7 +15,8 @@ export declare class DataGridTrBond<T, Props extends DataGridTrBondProps<T> = Da
|
|
|
15
15
|
share(): this;
|
|
16
16
|
mount(): () => void;
|
|
17
17
|
unmount(): void;
|
|
18
|
-
root(
|
|
18
|
+
root(): {
|
|
19
|
+
[x: symbol]: (node: HTMLElement) => void;
|
|
19
20
|
'data-kind': string;
|
|
20
21
|
'data-header': string | undefined;
|
|
21
22
|
'data-selected': string | undefined;
|
|
@@ -24,12 +25,13 @@ export declare class DataGridTrBond<T, Props extends DataGridTrBondProps<T> = Da
|
|
|
24
25
|
static set(bond: DataGridTrBond): DataGridTrBond;
|
|
25
26
|
}
|
|
26
27
|
export declare class DataGridTrBondState<T, Props extends DataGridTrBondProps<T> = DataGridTrBondProps<T>> extends BondState<Props> {
|
|
28
|
+
#private;
|
|
27
29
|
static CONTEXT_KEY: string;
|
|
28
30
|
constructor(props: () => Props);
|
|
29
31
|
get id(): string;
|
|
30
32
|
get isSelected(): boolean | undefined;
|
|
31
33
|
get isHeader(): boolean;
|
|
32
|
-
get datagrid(): import("..").DataGridBondState<unknown
|
|
34
|
+
get datagrid(): import("..").DataGridBondState<unknown> | undefined;
|
|
33
35
|
select(): void;
|
|
34
36
|
unselect(): void;
|
|
35
37
|
}
|
|
@@ -2,6 +2,7 @@ import { getContext, setContext } from 'svelte';
|
|
|
2
2
|
import { createAttachmentKey } from 'svelte/attachments';
|
|
3
3
|
import { Bond, BondState } from '../../../shared/bond.svelte';
|
|
4
4
|
import { DataGridBond } from '../bond.svelte';
|
|
5
|
+
import { getDatagridHeaderContext } from '../context';
|
|
5
6
|
const DATAGRID_TR_ELEMENTS_KIND = {
|
|
6
7
|
root: 'datagrid-tr'
|
|
7
8
|
};
|
|
@@ -26,12 +27,11 @@ export class DataGridTrBond extends Bond {
|
|
|
26
27
|
unmount() {
|
|
27
28
|
return this.datagrid.state.unmountRow(this.state.id);
|
|
28
29
|
}
|
|
29
|
-
root(
|
|
30
|
+
root() {
|
|
30
31
|
return {
|
|
31
32
|
'data-kind': DATAGRID_TR_ELEMENTS_KIND.root,
|
|
32
33
|
'data-header': this.state.isHeader ? 'true' : undefined,
|
|
33
34
|
'data-selected': this.state.isSelected ? 'true' : undefined,
|
|
34
|
-
...props,
|
|
35
35
|
[createAttachmentKey()]: (node) => {
|
|
36
36
|
this.elements.root = node;
|
|
37
37
|
}
|
|
@@ -46,6 +46,8 @@ export class DataGridTrBond extends Bond {
|
|
|
46
46
|
}
|
|
47
47
|
export class DataGridTrBondState extends BondState {
|
|
48
48
|
static CONTEXT_KEY = '@atoms/context/datagrid/tr';
|
|
49
|
+
#datagrid = DataGridBond.get();
|
|
50
|
+
#isHeader = $state(!!getDatagridHeaderContext());
|
|
49
51
|
constructor(props) {
|
|
50
52
|
super(props);
|
|
51
53
|
}
|
|
@@ -53,18 +55,18 @@ export class DataGridTrBondState extends BondState {
|
|
|
53
55
|
return this.props.value || super.id;
|
|
54
56
|
}
|
|
55
57
|
get isSelected() {
|
|
56
|
-
return this.datagrid
|
|
58
|
+
return this.datagrid?.props.values?.some((id) => id === this.id);
|
|
57
59
|
}
|
|
58
60
|
get isHeader() {
|
|
59
|
-
return this
|
|
61
|
+
return this.#isHeader;
|
|
60
62
|
}
|
|
61
63
|
get datagrid() {
|
|
62
|
-
return
|
|
64
|
+
return this.#datagrid?.state;
|
|
63
65
|
}
|
|
64
66
|
select() {
|
|
65
|
-
this.datagrid
|
|
67
|
+
this.datagrid?.select([this.id]);
|
|
66
68
|
}
|
|
67
69
|
unselect() {
|
|
68
|
-
this.datagrid
|
|
70
|
+
this.datagrid?.unselect([this.id]);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -6,12 +6,10 @@
|
|
|
6
6
|
import type { HtmlElementTagName } from '../../element';
|
|
7
7
|
import { DataGridTrBond, DataGridTrBondState, type DataGridTrBondProps } from './bond.svelte';
|
|
8
8
|
import type { DatagridTrProps } from '../types';
|
|
9
|
-
import {
|
|
9
|
+
import { type DatagridContext } from '../context';
|
|
10
10
|
|
|
11
11
|
import './datagrid-tr.css';
|
|
12
12
|
|
|
13
|
-
const context_header = getDatagridHeaderContext();
|
|
14
|
-
|
|
15
13
|
let {
|
|
16
14
|
class: klass = '',
|
|
17
15
|
value = nanoid(),
|
|
@@ -37,9 +35,14 @@
|
|
|
37
35
|
]);
|
|
38
36
|
const bond = factory(bondProps).share();
|
|
39
37
|
|
|
40
|
-
const isHeader = $derived(
|
|
38
|
+
const isHeader = $derived(bond?.state.isHeader ?? false);
|
|
41
39
|
const isSelected = $derived(bond.state.isSelected);
|
|
42
40
|
|
|
41
|
+
const headerProps = $derived({
|
|
42
|
+
...bond.root(),
|
|
43
|
+
...restProps
|
|
44
|
+
});
|
|
45
|
+
|
|
43
46
|
const unmount = untrack(() => {
|
|
44
47
|
if (!isHeader) {
|
|
45
48
|
return bond.mount();
|
|
@@ -67,8 +70,7 @@
|
|
|
67
70
|
preset="datagrid.tr"
|
|
68
71
|
class={[
|
|
69
72
|
'datagrid-tr border-border items-center border-b bg-transparent',
|
|
70
|
-
!isHeader &&
|
|
71
|
-
'hover:bg-foreground/2 active:bg-foreground/4 transition-colors duration-100 last:border-b-0',
|
|
73
|
+
!isHeader && 'hover:bg-foreground/2 active:bg-foreground/4 transition-colors duration-100',
|
|
72
74
|
isHeader && 'header-tr',
|
|
73
75
|
isSelected && 'bg-primary/2 hover:bg-primary/4 active:bg-primary/6',
|
|
74
76
|
'$preset',
|
|
@@ -82,7 +84,7 @@
|
|
|
82
84
|
onmount={onmount?.bind(bond.state)}
|
|
83
85
|
ondestroy={ondestroy?.bind(bond.state)}
|
|
84
86
|
onclick={onclick_}
|
|
85
|
-
{...
|
|
87
|
+
{...headerProps}
|
|
86
88
|
>
|
|
87
89
|
{@render children?.({ tr: bond as unknown as DatagridContext<T> })}
|
|
88
90
|
</HtmlAtom>
|