@sentropic/design-system-svelte 0.10.4 → 0.11.0

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.
@@ -12,7 +12,13 @@
12
12
  timestamp?: string;
13
13
  class?: string;
14
14
  avatar?: Snippet;
15
- children: Snippet;
15
+ /**
16
+ * Message body. Either provide children (canonical) or the `content`
17
+ * string prop (cross-framework parity with React/Vue). `content` is
18
+ * rendered only when no children are supplied.
19
+ */
20
+ children?: Snippet;
21
+ content?: string;
16
22
  footer?: Snippet;
17
23
  actions?: Snippet;
18
24
  };
@@ -24,6 +30,7 @@
24
30
  class: className,
25
31
  avatar,
26
32
  children,
33
+ content,
27
34
  footer,
28
35
  actions,
29
36
  ...rest
@@ -66,7 +73,7 @@
66
73
  <div class="st-chatMessage__body">
67
74
  <div class="st-chatMessage__bubble">
68
75
  <div class="st-chatMessage__content">
69
- {@render children()}
76
+ {#if children}{@render children()}{:else if content}{content}{/if}
70
77
  </div>
71
78
  {#if isStreaming()}
72
79
  <span class="st-chatMessage__pulse" aria-hidden="true"></span>
@@ -9,7 +9,13 @@ type ChatMessageProps = Omit<HTMLAttributes<HTMLElement>, "class" | "role"> & {
9
9
  timestamp?: string;
10
10
  class?: string;
11
11
  avatar?: Snippet;
12
- children: Snippet;
12
+ /**
13
+ * Message body. Either provide children (canonical) or the `content`
14
+ * string prop (cross-framework parity with React/Vue). `content` is
15
+ * rendered only when no children are supplied.
16
+ */
17
+ children?: Snippet;
18
+ content?: string;
13
19
  footer?: Snippet;
14
20
  actions?: Snippet;
15
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ChatMessage.svelte.d.ts","sourceRoot":"","sources":["../src/lib/ChatMessage.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AACvE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAClF,KAAK,uBAAuB,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D,KAAK,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,GAAG;IAC5E,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,iBAAiB,GAAG,uBAAuB,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AA0EJ,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"ChatMessage.svelte.d.ts","sourceRoot":"","sources":["../src/lib/ChatMessage.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AACvE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAClF,KAAK,uBAAuB,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D,KAAK,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,GAAG;IAC5E,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,iBAAiB,GAAG,uBAAuB,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AA2EJ,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -0,0 +1,118 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLAttributes } from "svelte/elements";
4
+
5
+ export type ColSpan = number | "auto";
6
+
7
+ export type ColProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
8
+ /** Number of 12-grid columns to span, or "auto" to size to content. */
9
+ span?: ColSpan;
10
+ /** Columns to offset (0..11) via margin-inline-start. */
11
+ offset?: number;
12
+ /** Responsive overrides applied at and above the breakpoint. */
13
+ sm?: ColSpan;
14
+ md?: ColSpan;
15
+ lg?: ColSpan;
16
+ as?: string;
17
+ class?: string;
18
+ children?: Snippet;
19
+ };
20
+
21
+ /** Width expression for a given span. Accounts for the shared row gutter so a
22
+ full 12 columns still fit on one line (gap-based layout). */
23
+ export function spanBasis(span: ColSpan | undefined): string | undefined {
24
+ if (span == null) return undefined;
25
+ if (span === "auto") return "auto";
26
+ const clamped = Math.max(1, Math.min(12, Math.round(span)));
27
+ const ratio = clamped / 12;
28
+ // Subtract this column's share of the inter-column gutters.
29
+ return `calc(${ratio * 100}% - var(--st-row-gutter, 0px) * ${(12 - clamped) / 12})`;
30
+ }
31
+
32
+ export function offsetMargin(offset: number | undefined): string | undefined {
33
+ if (!offset) return undefined;
34
+ const clamped = Math.max(0, Math.min(11, Math.round(offset)));
35
+ if (clamped === 0) return undefined;
36
+ const ratio = clamped / 12;
37
+ return `calc(${ratio * 100}% + var(--st-row-gutter, 0px) * ${ratio})`;
38
+ }
39
+ </script>
40
+
41
+ <script lang="ts">
42
+ let {
43
+ span = "auto",
44
+ offset = 0,
45
+ sm,
46
+ md,
47
+ lg,
48
+ as = "div",
49
+ class: className,
50
+ children,
51
+ ...rest
52
+ }: ColProps = $props();
53
+
54
+ const isAuto = $derived(span === "auto");
55
+ const classes = $derived(
56
+ [
57
+ "st-col",
58
+ isAuto && "st-col--auto",
59
+ sm != null && "st-col--has-sm",
60
+ md != null && "st-col--has-md",
61
+ lg != null && "st-col--has-lg",
62
+ className
63
+ ]
64
+ .filter(Boolean)
65
+ .join(" ")
66
+ );
67
+ </script>
68
+
69
+ <svelte:element
70
+ this={as}
71
+ {...rest}
72
+ class={classes}
73
+ style:flex-basis={spanBasis(span)}
74
+ style:max-inline-size={isAuto ? undefined : spanBasis(span)}
75
+ style:flex-grow={isAuto ? "1" : "0"}
76
+ style:margin-inline-start={offsetMargin(offset)}
77
+ style:--st-col-sm={spanBasis(sm)}
78
+ style:--st-col-md={spanBasis(md)}
79
+ style:--st-col-lg={spanBasis(lg)}
80
+ >
81
+ {@render children?.()}
82
+ </svelte:element>
83
+
84
+ <style>
85
+ .st-col {
86
+ box-sizing: border-box;
87
+ flex-shrink: 1;
88
+ min-width: 0;
89
+ }
90
+
91
+ .st-col--auto {
92
+ flex-basis: auto;
93
+ }
94
+
95
+ @media (min-width: 640px) {
96
+ .st-col--has-sm {
97
+ flex-basis: var(--st-col-sm);
98
+ max-inline-size: var(--st-col-sm);
99
+ flex-grow: 0;
100
+ }
101
+ }
102
+
103
+ @media (min-width: 768px) {
104
+ .st-col--has-md {
105
+ flex-basis: var(--st-col-md);
106
+ max-inline-size: var(--st-col-md);
107
+ flex-grow: 0;
108
+ }
109
+ }
110
+
111
+ @media (min-width: 1024px) {
112
+ .st-col--has-lg {
113
+ flex-basis: var(--st-col-lg);
114
+ max-inline-size: var(--st-col-lg);
115
+ flex-grow: 0;
116
+ }
117
+ }
118
+ </style>
@@ -0,0 +1,24 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ export type ColSpan = number | "auto";
4
+ export type ColProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
5
+ /** Number of 12-grid columns to span, or "auto" to size to content. */
6
+ span?: ColSpan;
7
+ /** Columns to offset (0..11) via margin-inline-start. */
8
+ offset?: number;
9
+ /** Responsive overrides applied at and above the breakpoint. */
10
+ sm?: ColSpan;
11
+ md?: ColSpan;
12
+ lg?: ColSpan;
13
+ as?: string;
14
+ class?: string;
15
+ children?: Snippet;
16
+ };
17
+ /** Width expression for a given span. Accounts for the shared row gutter so a
18
+ full 12 columns still fit on one line (gap-based layout). */
19
+ export declare function spanBasis(span: ColSpan | undefined): string | undefined;
20
+ export declare function offsetMargin(offset: number | undefined): string | undefined;
21
+ declare const Col: import("svelte").Component<ColProps, {}, "">;
22
+ type Col = ReturnType<typeof Col>;
23
+ export default Col;
24
+ //# sourceMappingURL=Col.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Col.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Col.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtC,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IAClE,uEAAuE;IACvE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;gEACgE;AAChE,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOvE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAM3E;AAwCH,QAAA,MAAM,GAAG,8CAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
@@ -0,0 +1,73 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLAttributes } from "svelte/elements";
4
+
5
+ export type ContainerSize = "sm" | "md" | "lg" | "xl" | "full";
6
+
7
+ export type ContainerProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
8
+ size?: ContainerSize;
9
+ /** Apply horizontal padding using the spacing scale. */
10
+ padding?: boolean;
11
+ as?: string;
12
+ class?: string;
13
+ children?: Snippet;
14
+ };
15
+ </script>
16
+
17
+ <script lang="ts">
18
+ let {
19
+ size = "lg",
20
+ padding = true,
21
+ as = "div",
22
+ class: className,
23
+ children,
24
+ ...rest
25
+ }: ContainerProps = $props();
26
+
27
+ const classes = $derived(
28
+ [
29
+ "st-container",
30
+ `st-container--${size}`,
31
+ padding && "st-container--padded",
32
+ className
33
+ ]
34
+ .filter(Boolean)
35
+ .join(" ")
36
+ );
37
+ </script>
38
+
39
+ <svelte:element this={as} {...rest} class={classes}>
40
+ {@render children?.()}
41
+ </svelte:element>
42
+
43
+ <style>
44
+ .st-container {
45
+ box-sizing: border-box;
46
+ inline-size: 100%;
47
+ margin-inline: auto;
48
+ }
49
+
50
+ .st-container--sm {
51
+ max-inline-size: var(--st-container-sm, 40rem);
52
+ }
53
+
54
+ .st-container--md {
55
+ max-inline-size: var(--st-container-md, 48rem);
56
+ }
57
+
58
+ .st-container--lg {
59
+ max-inline-size: var(--st-container-lg, 64rem);
60
+ }
61
+
62
+ .st-container--xl {
63
+ max-inline-size: var(--st-container-xl, 80rem);
64
+ }
65
+
66
+ .st-container--full {
67
+ max-inline-size: none;
68
+ }
69
+
70
+ .st-container--padded {
71
+ padding-inline: var(--st-spacing-4, 1rem);
72
+ }
73
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ export type ContainerSize = "sm" | "md" | "lg" | "xl" | "full";
4
+ export type ContainerProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
5
+ size?: ContainerSize;
6
+ /** Apply horizontal padding using the spacing scale. */
7
+ padding?: boolean;
8
+ as?: string;
9
+ class?: string;
10
+ children?: Snippet;
11
+ };
12
+ declare const Container: import("svelte").Component<ContainerProps, {}, "">;
13
+ type Container = ReturnType<typeof Container>;
14
+ export default Container;
15
+ //# sourceMappingURL=Container.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Container.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Container.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IACxE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAkCJ,QAAA,MAAM,SAAS,oDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -0,0 +1,129 @@
1
+ <script lang="ts" module>
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+
4
+ export type DividerOrientation = "horizontal" | "vertical";
5
+ export type DividerVariant = "solid" | "dashed";
6
+
7
+ export type DividerProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
8
+ orientation?: DividerOrientation;
9
+ /** Spacing scale step (0..12) applied as margin around the divider. */
10
+ spacing?: number;
11
+ /** Optional label centered on a horizontal divider line. */
12
+ label?: string;
13
+ variant?: DividerVariant;
14
+ class?: string;
15
+ };
16
+ </script>
17
+
18
+ <script lang="ts">
19
+ import { spacingToken } from "./Flex.svelte";
20
+
21
+ let {
22
+ orientation = "horizontal",
23
+ spacing,
24
+ label,
25
+ variant = "solid",
26
+ class: className,
27
+ ...rest
28
+ }: DividerProps = $props();
29
+
30
+ const isVertical = $derived(orientation === "vertical");
31
+ const hasLabel = $derived(!isVertical && label != null && label !== "");
32
+ const margin = $derived(spacingToken(spacing));
33
+
34
+ const classes = $derived(
35
+ [
36
+ "st-divider",
37
+ `st-divider--${orientation}`,
38
+ `st-divider--${variant}`,
39
+ hasLabel && "st-divider--labeled",
40
+ className
41
+ ]
42
+ .filter(Boolean)
43
+ .join(" ")
44
+ );
45
+ </script>
46
+
47
+ {#if hasLabel}
48
+ <div
49
+ {...rest}
50
+ class={classes}
51
+ role="separator"
52
+ aria-orientation="horizontal"
53
+ style:margin-block={margin}
54
+ >
55
+ <span class="st-divider__line" aria-hidden="true"></span>
56
+ <span class="st-divider__label">{label}</span>
57
+ <span class="st-divider__line" aria-hidden="true"></span>
58
+ </div>
59
+ {:else}
60
+ <div
61
+ {...rest}
62
+ class={classes}
63
+ role="separator"
64
+ aria-orientation={orientation}
65
+ style:margin-block={isVertical ? undefined : margin}
66
+ style:margin-inline={isVertical ? margin : undefined}
67
+ ></div>
68
+ {/if}
69
+
70
+ <style>
71
+ .st-divider {
72
+ border: 0;
73
+ box-sizing: border-box;
74
+ color: var(--st-semantic-border-subtle, #e2e8f0);
75
+ }
76
+
77
+ .st-divider--horizontal:not(.st-divider--labeled) {
78
+ block-size: 0;
79
+ border-block-start-width: 1px;
80
+ border-block-start-style: solid;
81
+ border-block-start-color: currentColor;
82
+ inline-size: 100%;
83
+ }
84
+
85
+ .st-divider--vertical {
86
+ align-self: stretch;
87
+ border-inline-start-width: 1px;
88
+ border-inline-start-style: solid;
89
+ border-inline-start-color: currentColor;
90
+ display: inline-block;
91
+ inline-size: 0;
92
+ min-block-size: 1em;
93
+ }
94
+
95
+ .st-divider--dashed.st-divider--horizontal:not(.st-divider--labeled) {
96
+ border-block-start-style: dashed;
97
+ }
98
+
99
+ .st-divider--dashed.st-divider--vertical {
100
+ border-inline-start-style: dashed;
101
+ }
102
+
103
+ .st-divider--labeled {
104
+ align-items: center;
105
+ display: flex;
106
+ gap: var(--st-spacing-3, 0.75rem);
107
+ inline-size: 100%;
108
+ }
109
+
110
+ .st-divider__line {
111
+ block-size: 0;
112
+ border-block-start-width: 1px;
113
+ border-block-start-style: solid;
114
+ border-block-start-color: currentColor;
115
+ flex: 1 1 0;
116
+ }
117
+
118
+ .st-divider--dashed .st-divider__line {
119
+ border-block-start-style: dashed;
120
+ }
121
+
122
+ .st-divider__label {
123
+ color: var(--st-semantic-text-secondary, inherit);
124
+ flex: 0 0 auto;
125
+ font-size: var(--st-font-size-sm, 0.875rem);
126
+ line-height: 1;
127
+ white-space: nowrap;
128
+ }
129
+ </style>
@@ -0,0 +1,16 @@
1
+ import type { HTMLAttributes } from "svelte/elements";
2
+ export type DividerOrientation = "horizontal" | "vertical";
3
+ export type DividerVariant = "solid" | "dashed";
4
+ export type DividerProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
5
+ orientation?: DividerOrientation;
6
+ /** Spacing scale step (0..12) applied as margin around the divider. */
7
+ spacing?: number;
8
+ /** Optional label centered on a horizontal divider line. */
9
+ label?: string;
10
+ variant?: DividerVariant;
11
+ class?: string;
12
+ };
13
+ declare const Divider: import("svelte").Component<DividerProps, {}, "">;
14
+ type Divider = ReturnType<typeof Divider>;
15
+ export default Divider;
16
+ //# sourceMappingURL=Divider.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Divider.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Divider.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,UAAU,CAAC;AAC3D,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkDJ,QAAA,MAAM,OAAO,kDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
@@ -0,0 +1,110 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLAttributes } from "svelte/elements";
4
+
5
+ export type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse";
6
+ export type FlexAlign = "start" | "center" | "end" | "stretch" | "baseline";
7
+ export type FlexJustify = "start" | "center" | "end" | "between" | "around" | "evenly";
8
+
9
+ export type FlexProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
10
+ direction?: FlexDirection;
11
+ /** Spacing scale step (0..12) mapped to `--st-spacing-*`. */
12
+ gap?: number;
13
+ align?: FlexAlign;
14
+ justify?: FlexJustify;
15
+ wrap?: boolean;
16
+ inline?: boolean;
17
+ as?: string;
18
+ class?: string;
19
+ children?: Snippet;
20
+ };
21
+
22
+ /** rem fallbacks for the Sent Tech spacing scale (steps 5/7/9/10/11 are
23
+ interpolated since no token exists, but the var() is still preferred). */
24
+ const SPACING_FALLBACK: Record<number, string> = {
25
+ 0: "0",
26
+ 1: "0.25rem",
27
+ 2: "0.5rem",
28
+ 3: "0.75rem",
29
+ 4: "1rem",
30
+ 5: "1.25rem",
31
+ 6: "1.5rem",
32
+ 7: "1.75rem",
33
+ 8: "2rem",
34
+ 9: "2.25rem",
35
+ 10: "2.5rem",
36
+ 11: "2.75rem",
37
+ 12: "3rem"
38
+ };
39
+
40
+ /** Resolve a spacing step to a `var(--st-spacing-N, fallback)` expression. */
41
+ export function spacingToken(step: number | undefined): string | undefined {
42
+ if (step == null) return undefined;
43
+ const clamped = Math.max(0, Math.min(12, Math.round(step)));
44
+ if (clamped === 0) return "0";
45
+ return `var(--st-spacing-${clamped}, ${SPACING_FALLBACK[clamped]})`;
46
+ }
47
+
48
+ const ALIGN: Record<FlexAlign, string> = {
49
+ start: "flex-start",
50
+ center: "center",
51
+ end: "flex-end",
52
+ stretch: "stretch",
53
+ baseline: "baseline"
54
+ };
55
+
56
+ const JUSTIFY: Record<FlexJustify, string> = {
57
+ start: "flex-start",
58
+ center: "center",
59
+ end: "flex-end",
60
+ between: "space-between",
61
+ around: "space-around",
62
+ evenly: "space-evenly"
63
+ };
64
+
65
+ export function alignValue(align: FlexAlign | undefined): string | undefined {
66
+ return align ? ALIGN[align] : undefined;
67
+ }
68
+
69
+ export function justifyValue(justify: FlexJustify | undefined): string | undefined {
70
+ return justify ? JUSTIFY[justify] : undefined;
71
+ }
72
+ </script>
73
+
74
+ <script lang="ts">
75
+ let {
76
+ direction = "row",
77
+ gap,
78
+ align,
79
+ justify,
80
+ wrap = false,
81
+ inline = false,
82
+ as = "div",
83
+ class: className,
84
+ children,
85
+ ...rest
86
+ }: FlexProps = $props();
87
+
88
+ const classes = $derived(["st-flex", className].filter(Boolean).join(" "));
89
+ </script>
90
+
91
+ <svelte:element
92
+ this={as}
93
+ {...rest}
94
+ class={classes}
95
+ style:display={inline ? "inline-flex" : "flex"}
96
+ style:flex-direction={direction}
97
+ style:flex-wrap={wrap ? "wrap" : "nowrap"}
98
+ style:align-items={alignValue(align)}
99
+ style:justify-content={justifyValue(justify)}
100
+ style:gap={spacingToken(gap)}
101
+ >
102
+ {@render children?.()}
103
+ </svelte:element>
104
+
105
+ <style>
106
+ .st-flex {
107
+ box-sizing: border-box;
108
+ min-width: 0;
109
+ }
110
+ </style>
@@ -0,0 +1,25 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ export type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse";
4
+ export type FlexAlign = "start" | "center" | "end" | "stretch" | "baseline";
5
+ export type FlexJustify = "start" | "center" | "end" | "between" | "around" | "evenly";
6
+ export type FlexProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
7
+ direction?: FlexDirection;
8
+ /** Spacing scale step (0..12) mapped to `--st-spacing-*`. */
9
+ gap?: number;
10
+ align?: FlexAlign;
11
+ justify?: FlexJustify;
12
+ wrap?: boolean;
13
+ inline?: boolean;
14
+ as?: string;
15
+ class?: string;
16
+ children?: Snippet;
17
+ };
18
+ /** Resolve a spacing step to a `var(--st-spacing-N, fallback)` expression. */
19
+ export declare function spacingToken(step: number | undefined): string | undefined;
20
+ export declare function alignValue(align: FlexAlign | undefined): string | undefined;
21
+ export declare function justifyValue(justify: FlexJustify | undefined): string | undefined;
22
+ declare const Flex: import("svelte").Component<FlexProps, {}, "">;
23
+ type Flex = ReturnType<typeof Flex>;
24
+ export default Flex;
25
+ //# sourceMappingURL=Flex.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flex.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Flex.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAChF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;AAC5E,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEvF,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IACnE,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAoBF,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKzE;AAmBD,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE3E;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEjF;AA6BH,QAAA,MAAM,IAAI,+CAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}