@svelte-atoms/core 1.0.0-alpha.23 → 1.0.0-alpha.25

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.
Files changed (56) hide show
  1. package/README.md +645 -645
  2. package/dist/components/accordion/accordion-root.svelte.d.ts +2 -2
  3. package/dist/components/alert/alert-actions.svelte.d.ts +1 -0
  4. package/dist/components/alert/alert-close-button.svelte.d.ts +1 -0
  5. package/dist/components/alert/alert-content.svelte.d.ts +1 -0
  6. package/dist/components/atom/html-atom.svelte +151 -4
  7. package/dist/components/atom/html-atom.svelte.d.ts +4 -2
  8. package/dist/components/atom/types.d.ts +7 -0
  9. package/dist/components/button/button.stories.svelte +57 -17
  10. package/dist/components/button/button.stories.svelte.d.ts +6 -14
  11. package/dist/components/checkbox/checkbox.svelte.d.ts +1 -1
  12. package/dist/components/combobox/combobox-root.svelte.d.ts +2 -2
  13. package/dist/components/datagrid/datagrid.stories.svelte +75 -75
  14. package/dist/components/drawer/drawer-backdrop.svelte.d.ts +1 -0
  15. package/dist/components/icon/icon.svelte.d.ts +1 -0
  16. package/dist/components/input/input-placeholder.svelte +56 -56
  17. package/dist/components/input/input-placeholder.svelte.d.ts +1 -0
  18. package/dist/components/input/input-root.svelte +79 -79
  19. package/dist/components/input/input-root.svelte.d.ts +1 -0
  20. package/dist/components/input/input-value.svelte +113 -113
  21. package/dist/components/input/input-value.svelte.d.ts +1 -1
  22. package/dist/components/input/input.stories.svelte +38 -38
  23. package/dist/components/label/label.svelte.d.ts +1 -0
  24. package/dist/components/layer/layer-inner.svelte.d.ts +1 -0
  25. package/dist/components/layer/layer-root.svelte.d.ts +1 -0
  26. package/dist/components/popover/popover-arrow.svelte.d.ts +1 -0
  27. package/dist/components/portal/portal-inner.svelte.d.ts +1 -0
  28. package/dist/components/portal/portal-root.svelte.d.ts +1 -0
  29. package/dist/components/portal/teleport.svelte.d.ts +1 -0
  30. package/dist/components/radio/radio.svelte.d.ts +2 -2
  31. package/dist/components/root/root.svelte +121 -103
  32. package/dist/components/root/root.svelte.d.ts +1 -0
  33. package/dist/components/stack/stack-root.svelte.d.ts +1 -0
  34. package/dist/components/toast/toast-description.svelte.d.ts +1 -0
  35. package/dist/components/toast/toast-root.svelte.d.ts +1 -0
  36. package/dist/components/toast/toast-title.svelte.d.ts +1 -0
  37. package/dist/components/tree/tree-header.svelte.d.ts +1 -0
  38. package/dist/context/preset.svelte.d.ts +3 -0
  39. package/dist/runes/index.d.ts +3 -0
  40. package/dist/runes/index.js +3 -0
  41. package/dist/runes/reduced-motion.svelte.d.ts +23 -0
  42. package/dist/runes/reduced-motion.svelte.js +41 -0
  43. package/dist/utils/index.d.ts +1 -0
  44. package/dist/utils/index.js +1 -0
  45. package/dist/utils/variant.d.ts +213 -0
  46. package/dist/utils/variant.js +137 -0
  47. package/llm/composition.md +395 -0
  48. package/llm/crafting.md +838 -0
  49. package/llm/motion.md +970 -0
  50. package/llm/philosophy.md +23 -0
  51. package/llm/preset-variant-integration.md +516 -0
  52. package/llm/preset.md +383 -0
  53. package/llm/styling.md +216 -0
  54. package/llm/usage.md +46 -0
  55. package/llm/variants.md +712 -0
  56. package/package.json +2 -1
@@ -19,7 +19,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
19
19
  exports: {
20
20
  getBond: () => AccordionBond;
21
21
  };
22
- bindings: "values" | "data" | "value";
22
+ bindings: "values" | "value" | "data";
23
23
  slots: {};
24
24
  events: {};
25
25
  };
@@ -27,7 +27,7 @@ declare class __sveltets_Render<E extends keyof HTMLElementTagNameMap = 'div', B
27
27
  props(): ReturnType<typeof $$render<E, B>>['props'];
28
28
  events(): ReturnType<typeof $$render<E, B>>['events'];
29
29
  slots(): ReturnType<typeof $$render<E, B>>['slots'];
30
- bindings(): "values" | "data" | "value";
30
+ bindings(): "values" | "value" | "data";
31
31
  exports(): {
32
32
  getBond: () => AccordionBond;
33
33
  };
@@ -24,6 +24,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
24
24
  bond?: import("../..").Bond;
25
25
  base?: B | undefined;
26
26
  preset?: import("../..").ModuleName | (string & {});
27
+ variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
27
28
  } & {
28
29
  children?: Snippet<[{
29
30
  alert: AlertBond;
@@ -24,6 +24,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
24
24
  bond?: import("../..").Bond;
25
25
  base?: B | undefined;
26
26
  preset?: import("../..").ModuleName | (string & {});
27
+ variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
27
28
  } & {
28
29
  children?: Snippet<[{
29
30
  alert: AlertBond;
@@ -24,6 +24,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
24
24
  bond?: import("../..").Bond;
25
25
  base?: B | undefined;
26
26
  preset?: import("../..").ModuleName | (string & {});
27
+ variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
27
28
  } & {
28
29
  children?: Snippet<[{
29
30
  alert: AlertBond;
@@ -3,9 +3,15 @@
3
3
  import type { Base, ComponentBase, HtmlAtomProps, SnippetBase } from './types';
4
4
  import { RootBond } from '../root';
5
5
  import { HtmlElement } from '../element';
6
- import { cn, toClassValue, type ClassValue } from '../../utils';
6
+ import {
7
+ cn,
8
+ toClassValue,
9
+ type ClassValue,
10
+ type VariantDefinition
11
+ } from '../../utils';
7
12
  import { getPreset } from '../../context';
8
13
  import type { PresetModuleName } from '../../context/preset.svelte';
14
+ import type { Bond } from '../../shared';
9
15
 
10
16
  type Element = HTMLElementTagNameMap[E];
11
17
 
@@ -17,6 +23,7 @@
17
23
  base = undefined,
18
24
  preset: presetKey = undefined,
19
25
  bond = undefined,
26
+ variants = undefined,
20
27
  children = undefined,
21
28
  ...restProps
22
29
  }: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
@@ -25,13 +32,85 @@
25
32
  presetKey ? getPreset(presetKey as PresetModuleName)?.apply?.(bond, [bond]) : undefined
26
33
  );
27
34
 
28
- const _klass = $derived(compilePresetPlaceholder(klass));
35
+ const presetProps = $derived(preset?.variants);
36
+
37
+ // Resolve local variants - either VariantDefinition or function
38
+ const localVariants = $derived.by(() => {
39
+ if (!variants) return undefined;
40
+
41
+ // If it's a function, call it directly
42
+ if (typeof variants === 'function') {
43
+ return variants(bond as Bond, restProps);
44
+ }
45
+
46
+ // Otherwise it's a VariantDefinition, resolve it
47
+ return resolveVariants(variants, bond as Bond, restProps);
48
+ });
49
+
50
+ // Merge preset variants with local variants
51
+ const mergedVariants = $derived.by(() => {
52
+ // No variants at all
53
+ if (!presetProps && !localVariants) return undefined;
54
+
55
+ // Only preset variants (raw object from preset)
56
+ if (presetProps && !localVariants) {
57
+ // Convert preset variants to VariantDefinition-like structure
58
+ const variantDef = {
59
+ class: preset?.class,
60
+ variants: presetProps,
61
+ compounds: preset?.compounds ?? [],
62
+ defaults: preset?.defaults ?? {}
63
+ };
64
+ return resolveVariants(variantDef, bond as Bond, restProps);
65
+ }
66
+
67
+ // Only local variants
68
+ if (!presetProps && localVariants) {
69
+ return localVariants;
70
+ }
71
+
72
+ // Both exist - merge them
73
+ // When both preset and local variants exist, we need to merge the resolved props
74
+ const presetVariantDef = {
75
+ class: preset?.class,
76
+ variants: presetProps,
77
+ compounds: preset?.compounds ?? [],
78
+ defaults: preset?.defaults ?? {}
79
+ };
80
+
81
+ const presetResolved = resolveVariants(presetVariantDef, bond as Bond, restProps);
82
+
83
+ // Merge the resolved variant props
84
+ // Local variant classes and attributes override preset
85
+ const presetClasses = Array.isArray(presetResolved.class)
86
+ ? presetResolved.class
87
+ : [presetResolved.class];
88
+ const localClasses = Array.isArray(localVariants?.class)
89
+ ? localVariants.class
90
+ : [localVariants?.class];
91
+
92
+ return {
93
+ class: [...presetClasses, ...localClasses].filter(Boolean),
94
+ ...presetResolved,
95
+ ...localVariants
96
+ };
97
+ });
98
+
99
+ const _klass = $derived([compilePresetPlaceholder(klass), mergedVariants?.class ?? '']);
29
100
 
30
101
  const _base = $derived(base ?? preset?.base);
31
102
  const _as = $derived(as ?? preset?.as);
32
103
  const _restProps = $derived.by(() => {
33
- const { class: klass, base, as, ...restPresetProps } = preset ?? {};
34
- return { ...restPresetProps, ...restProps };
104
+ const {
105
+ class: klassPreset,
106
+ base,
107
+ as,
108
+ variants: presetProps,
109
+ ...restPresetProps
110
+ } = preset ?? {};
111
+ const { class: variantClass, ...variantsRestProps } = mergedVariants ?? {};
112
+
113
+ return { ...restPresetProps, ...variantsRestProps, ...restProps };
35
114
  });
36
115
 
37
116
  const isSnippet = $derived(typeof _base === 'function' && _base.length === 1 && !_base.prototype);
@@ -59,6 +138,74 @@
59
138
 
60
139
  return compiled;
61
140
  }
141
+
142
+ /**
143
+ * Resolve variant definition to props
144
+ */
145
+ function resolveVariants(
146
+ def: VariantDefinition<any>,
147
+ bond: Bond | null | undefined,
148
+ props: Record<string, any>
149
+ ): Record<string, any> {
150
+ const { variants: variantMap, compounds, defaults, class: baseClass } = def;
151
+
152
+ // Merge props with defaults
153
+ const finalProps = { ...defaults, ...props };
154
+
155
+ const classes: ClassValue[] = [];
156
+ const attributes: Record<string, any> = {};
157
+
158
+ // Add base class
159
+ if (baseClass) classes.push(baseClass);
160
+
161
+ // Add variant classes
162
+ if (variantMap) {
163
+ for (const [key, value] of Object.entries(finalProps)) {
164
+ const variantValue = variantMap[key]?.[value as string];
165
+ if (variantValue !== undefined) {
166
+ const resolved = typeof variantValue === 'function' ? variantValue(bond) : variantValue;
167
+
168
+ if (typeof resolved === 'string') {
169
+ classes.push(resolved);
170
+ } else if (typeof resolved === 'object' && resolved !== null) {
171
+ if ('class' in resolved) {
172
+ classes.push(resolved.class);
173
+ }
174
+ // Add other attributes
175
+ Object.entries(resolved).forEach(([k, v]) => {
176
+ if (k !== 'class') {
177
+ attributes[k] = v;
178
+ }
179
+ });
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
+ // Add compound variants
186
+ if (compounds) {
187
+ for (const compound of compounds) {
188
+ const { class: compoundClass, ...compoundProps } = compound;
189
+ const matches = Object.entries(compoundProps).every(
190
+ ([key, value]) => finalProps[key] === value
191
+ );
192
+ if (matches) {
193
+ if (compoundClass) classes.push(compoundClass);
194
+ // Add compound attributes
195
+ Object.entries(compound).forEach(([k, v]) => {
196
+ if (k !== 'class' && !Object.keys(compoundProps).includes(k)) {
197
+ attributes[k] = v;
198
+ }
199
+ });
200
+ }
201
+ }
202
+ }
203
+
204
+ return {
205
+ class: classes,
206
+ ...attributes
207
+ };
208
+ }
62
209
  </script>
63
210
 
64
211
  {#if isSnippet}
@@ -1,7 +1,8 @@
1
1
  import type { HTMLAttributes } from 'svelte/elements';
2
2
  import type { Base } from './types';
3
- import { type ClassValue } from '../../utils';
3
+ import { type ClassValue, type VariantDefinition } from '../../utils';
4
4
  import type { PresetModuleName } from '../../context/preset.svelte';
5
+ import type { Bond } from '../../shared';
5
6
  declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base>(): {
6
7
  props: Record<string, unknown> & {
7
8
  [key: string]: unknown;
@@ -16,9 +17,10 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
16
17
  ondestroy?: import("..").NodeFunction<E> | undefined;
17
18
  children?: import("svelte").Snippet;
18
19
  } & {
19
- bond?: import("../..").Bond;
20
+ bond?: Bond;
20
21
  base?: B | undefined;
21
22
  preset?: PresetModuleName | (string & {});
23
+ variants?: VariantDefinition<any> | ((bond: Bond, variantProps: Record<string, any>) => Record<string, any>);
22
24
  } & HTMLAttributes<HTMLElementTagNameMap[E]>;
23
25
  exports: {};
24
26
  bindings: "";
@@ -3,6 +3,7 @@ import { type HtmlElementTagName } from '../element';
3
3
  import type { HtmlElementProps, ElementType } from '../element/types';
4
4
  import type { PresetModuleName } from '../../context/preset.svelte';
5
5
  import type { Bond } from '../../shared';
6
+ import type { VariantDefinition } from '../../utils';
6
7
  export type ComponentBase = Component;
7
8
  export type SnippetBase = Snippet;
8
9
  export type Base<Args = any> = Args extends Record<string, any> ? ComponentBase : Args extends unknown[] ? SnippetBase : never;
@@ -10,5 +11,11 @@ export type HtmlAtomProps<E extends HtmlElementTagName = HtmlElementTagName, B e
10
11
  bond?: Bond;
11
12
  base?: B;
12
13
  preset?: PresetModuleName | (string & {});
14
+ /**
15
+ * Variant definition or function to resolve variants
16
+ * - VariantDefinition: Static variant config with base, variants, compoundVariants, defaultVariants
17
+ * - Function: Dynamic function that receives bond and props, returns props (legacy)
18
+ */
19
+ variants?: VariantDefinition<any> | ((bond: Bond, variantProps: Record<string, any>) => Record<string, any>);
13
20
  };
14
21
  export type { ElementType };
@@ -1,17 +1,57 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import Root from '../root/root.svelte';
4
- import ButtonCmp from './button.svelte';
5
-
6
- const { Story } = defineMeta({
7
- title: 'ATOMS/Button'
8
- });
9
- </script>
10
-
11
- <Story name="Button">
12
- <Root class="p-4">
13
- {#snippet children({ args })}
14
- <ButtonCmp>Clicke me</ButtonCmp>
15
- {/snippet}
16
- </Root>
17
- </Story>
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Root from '../root/root.svelte';
4
+ import ButtonCmp from './button.svelte';
5
+ import { defineVariants } from '../../utils/variant';
6
+
7
+ const { Story } = defineMeta({
8
+ title: 'ATOMS/Button'
9
+ });
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ const variants = defineVariants((bond) => ({
14
+ variants: {
15
+ variant: {
16
+ primary: {
17
+ class: 'bg-primary text-primary-foreground hover:bg-primary/80 active:bg-primary/90'
18
+ },
19
+ secondary: {
20
+ class:
21
+ 'bg-secondary text-secondary-foreground hover:bg-secondary/80 active:bg-secondary/90'
22
+ },
23
+ destructive: {
24
+ class:
25
+ 'bg-destructive text-destructive-foreground hover:bg-destructive/80 active:bg-destructive/90'
26
+ },
27
+ outline: {
28
+ class:
29
+ 'bg-transparent hover:bg-foreground/5 active:bg-foreground/10 border border-border text-foreground'
30
+ },
31
+ ghost: {
32
+ class: 'hover:bg-accent hover:text-accent-foreground'
33
+ }
34
+ }
35
+ },
36
+ compounds: [],
37
+ defaults: {
38
+ variant: 'destructive'
39
+ }
40
+ }));
41
+ </script>
42
+
43
+ <Story name="Button">
44
+ <Root class="p-4">
45
+ {#snippet children({ args })}
46
+ <ButtonCmp variant="primary">Clicke me</ButtonCmp>
47
+ {/snippet}
48
+ </Root>
49
+ </Story>
50
+
51
+ <Story name="Button - Local Variants">
52
+ <Root class="p-4">
53
+ {#snippet children({ args })}
54
+ <ButtonCmp {variants} {...args}>Clicke me</ButtonCmp>
55
+ {/snippet}
56
+ </Root>
57
+ </Story>
@@ -1,18 +1,5 @@
1
- export default Button;
2
- type Button = SvelteComponent<{
3
- [x: string]: never;
4
- }, {
5
- [evt: string]: CustomEvent<any>;
6
- }, {}> & {
7
- $$bindings?: string | undefined;
8
- };
9
- declare const Button: $$__sveltets_2_IsomorphicComponent<{
10
- [x: string]: never;
11
- }, {
12
- [evt: string]: CustomEvent<any>;
13
- }, {}, {}, string>;
14
1
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
- new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
16
3
  $$bindings?: Bindings;
17
4
  } & Exports;
18
5
  (internal: unknown, props: {
@@ -24,3 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
24
11
  };
25
12
  z_$$bindings?: Bindings;
26
13
  }
14
+ declare const Button: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type Button = InstanceType<typeof Button>;
18
+ export default Button;
@@ -2,6 +2,6 @@ import type { HTMLInputAttributes } from 'svelte/elements';
2
2
  import type { CheckboxProps } from './types';
3
3
  import './checkbox.css';
4
4
  type $$ComponentProps = CheckboxProps & Exclude<HTMLInputAttributes, 'type'>;
5
- declare const Checkbox: import("svelte").Component<$$ComponentProps, {}, "group" | "value" | "checked" | "indeterminate">;
5
+ declare const Checkbox: import("svelte").Component<$$ComponentProps, {}, "value" | "group" | "checked" | "indeterminate">;
6
6
  type Checkbox = ReturnType<typeof Checkbox>;
7
7
  export default Checkbox;
@@ -18,7 +18,7 @@ declare function $$render<D>(): {
18
18
  exports: {
19
19
  getBond: () => ComboboxBond<D>;
20
20
  };
21
- bindings: "values" | "text" | "value" | "open" | "query";
21
+ bindings: "values" | "value" | "text" | "open" | "query";
22
22
  slots: {};
23
23
  events: {};
24
24
  };
@@ -26,7 +26,7 @@ declare class __sveltets_Render<D> {
26
26
  props(): ReturnType<typeof $$render<D>>['props'];
27
27
  events(): ReturnType<typeof $$render<D>>['events'];
28
28
  slots(): ReturnType<typeof $$render<D>>['slots'];
29
- bindings(): "values" | "text" | "value" | "open" | "query";
29
+ bindings(): "values" | "value" | "text" | "open" | "query";
30
30
  exports(): {
31
31
  getBond: () => ComboboxBond<D>;
32
32
  };
@@ -1,75 +1,75 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import Root from '../root/root.svelte';
4
- import { DataGrid as DataGridCmp } from '.';
5
- import { Dropdown } from '../dropdown';
6
- import MoreVerticalIcon from '../../icons/icon-more-vert.svelte';
7
- import { Icon } from '../icon';
8
- import { container } from '../../runes/container.svelte';
9
-
10
- const { Story } = defineMeta({
11
- title: 'Atoms/DataGrid'
12
- });
13
- </script>
14
-
15
- <script>
16
- let values = $state([]);
17
-
18
- const datagridContainer = container();
19
- </script>
20
-
21
- <Story name="DataGrid">
22
- <Root>
23
- {#snippet children({ args })}
24
- <DataGridCmp.Root class="" {@attach datagridContainer.attach}>
25
- <DataGridCmp.Header>
26
- <DataGridCmp.Tr header>
27
- <DataGridCmp.Th width="auto">
28
- <DataGridCmp.Checkbox />
29
- </DataGridCmp.Th>
30
- <DataGridCmp.Th
31
- class="resize-x overflow-x-auto"
32
- width="auto"
33
- hidden={datagridContainer.current?.width
34
- ? datagridContainer.current.width < 1024
35
- : false}>ID</DataGridCmp.Th
36
- >
37
- <DataGridCmp.Th>Name</DataGridCmp.Th>
38
- <DataGridCmp.Th width="auto">Job</DataGridCmp.Th>
39
- <DataGridCmp.Th width="auto">Contact</DataGridCmp.Th>
40
- <DataGridCmp.Th width="auto"></DataGridCmp.Th>
41
- </DataGridCmp.Tr>
42
- </DataGridCmp.Header>
43
-
44
- <DataGridCmp.Body>
45
- {#each { length: 10 } as _, i (i)}
46
- <DataGridCmp.Tr>
47
- <DataGridCmp.Td>
48
- <DataGridCmp.Checkbox />
49
- </DataGridCmp.Td>
50
-
51
- <DataGridCmp.Td>{crypto.randomUUID()}</DataGridCmp.Td>
52
- <DataGridCmp.Td>John Doe</DataGridCmp.Td>
53
- <DataGridCmp.Td>Software Engineer</DataGridCmp.Td>
54
- <DataGridCmp.Td>+213659009944</DataGridCmp.Td>
55
-
56
- <DataGridCmp.Td base={Dropdown.Root} placement="bottom-end" offset={0}>
57
- <Dropdown.Trigger class="flex aspect-square items-center justify-center p-0">
58
- <Icon src={MoreVerticalIcon} />
59
- </Dropdown.Trigger>
60
- <Dropdown.List>
61
- <Dropdown.Item value="ar">Arabic</Dropdown.Item>
62
- <Dropdown.Item value="en">English</Dropdown.Item>
63
- <Dropdown.Item value="sp">Spanish</Dropdown.Item>
64
- <Dropdown.Item value="fr">Frensh</Dropdown.Item>
65
- </Dropdown.List>
66
- </DataGridCmp.Td>
67
- </DataGridCmp.Tr>
68
- {/each}
69
- </DataGridCmp.Body>
70
-
71
- <DataGridCmp.Footer></DataGridCmp.Footer>
72
- </DataGridCmp.Root>
73
- {/snippet}
74
- </Root>
75
- </Story>
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Root from '../root/root.svelte';
4
+ import { DataGrid as DataGridCmp } from '.';
5
+ import { Dropdown } from '../dropdown';
6
+ import MoreVerticalIcon from '../../icons/icon-more-vert.svelte';
7
+ import { Icon } from '../icon';
8
+ import { container } from '../../runes/container.svelte';
9
+
10
+ const { Story } = defineMeta({
11
+ title: 'Atoms/DataGrid'
12
+ });
13
+ </script>
14
+
15
+ <script>
16
+ let values = $state([]);
17
+
18
+ const datagridContainer = container();
19
+ </script>
20
+
21
+ <Story name="DataGrid">
22
+ <Root>
23
+ {#snippet children({ args })}
24
+ <DataGridCmp.Root class="" {@attach datagridContainer.attach}>
25
+ <DataGridCmp.Header>
26
+ <DataGridCmp.Tr header>
27
+ <DataGridCmp.Th width="auto">
28
+ <DataGridCmp.Checkbox />
29
+ </DataGridCmp.Th>
30
+ <DataGridCmp.Th
31
+ class="resize-x overflow-x-auto"
32
+ width="auto"
33
+ hidden={datagridContainer.current?.width
34
+ ? datagridContainer.current.width < 1024
35
+ : false}>ID</DataGridCmp.Th
36
+ >
37
+ <DataGridCmp.Th>Name</DataGridCmp.Th>
38
+ <DataGridCmp.Th width="auto">Job</DataGridCmp.Th>
39
+ <DataGridCmp.Th width="auto">Contact</DataGridCmp.Th>
40
+ <DataGridCmp.Th width="auto"></DataGridCmp.Th>
41
+ </DataGridCmp.Tr>
42
+ </DataGridCmp.Header>
43
+
44
+ <DataGridCmp.Body>
45
+ {#each { length: 10 } as _, i (i)}
46
+ <DataGridCmp.Tr>
47
+ <DataGridCmp.Td>
48
+ <DataGridCmp.Checkbox />
49
+ </DataGridCmp.Td>
50
+
51
+ <DataGridCmp.Td>{crypto.randomUUID()}</DataGridCmp.Td>
52
+ <DataGridCmp.Td>John Doe</DataGridCmp.Td>
53
+ <DataGridCmp.Td>Software Engineer</DataGridCmp.Td>
54
+ <DataGridCmp.Td>+213659009944</DataGridCmp.Td>
55
+
56
+ <DataGridCmp.Td base={Dropdown.Root} placement="bottom-end" offset={0}>
57
+ <Dropdown.Trigger class="flex aspect-square items-center justify-center p-0">
58
+ <Icon src={MoreVerticalIcon} />
59
+ </Dropdown.Trigger>
60
+ <Dropdown.List>
61
+ <Dropdown.Item value="ar">Arabic</Dropdown.Item>
62
+ <Dropdown.Item value="en">English</Dropdown.Item>
63
+ <Dropdown.Item value="sp">Spanish</Dropdown.Item>
64
+ <Dropdown.Item value="fr">Frensh</Dropdown.Item>
65
+ </Dropdown.List>
66
+ </DataGridCmp.Td>
67
+ </DataGridCmp.Tr>
68
+ {/each}
69
+ </DataGridCmp.Body>
70
+
71
+ <DataGridCmp.Footer></DataGridCmp.Footer>
72
+ </DataGridCmp.Root>
73
+ {/snippet}
74
+ </Root>
75
+ </Story>
@@ -21,6 +21,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
21
21
  bond?: import("../..").Bond;
22
22
  base?: B | undefined;
23
23
  preset?: import("../..").ModuleName | (string & {});
24
+ variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
24
25
  } & {
25
26
  as?: E | undefined;
26
27
  class?: string;
@@ -28,6 +28,7 @@ declare function $$render<Src extends Component = Component, E extends HtmlEleme
28
28
  bond?: import("../..").Bond;
29
29
  base?: B | undefined;
30
30
  preset?: import("../..").ModuleName | (string & {});
31
+ variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
31
32
  } & HTMLAttributes<HTMLDivElement>;
32
33
  exports: {};
33
34
  bindings: "";