svelte-ant-design 0.6.0 → 0.8.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.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Ant Design.
18
18
 
19
19
  ## Status
20
20
 
21
- Version `0.6.0`. Available components: `Button`, `Checkbox` (with `CheckboxGroup`), `Input` (with `InputTextArea`, `InputPassword`, `InputSearch` and `InputOTP`), `Select` (with `SelectOption` and `SelectOptGroup`), `Switch`, `Tooltip`. More components are planned.
21
+ Version `0.8.0`. Available components: `Button`, `Checkbox` (with `CheckboxGroup`), `Grid` (`Row`, `Col` and `Breakpoints`), `Input` (with `InputTextArea`, `InputPassword`, `InputSearch` and `InputOTP`), `Radio` (with `RadioButton` and `RadioGroup`), `Select` (with `SelectOption` and `SelectOptGroup`), `Switch`, `Tooltip`. More components are planned.
22
22
 
23
23
  ## Browser support
24
24
 
@@ -59,13 +59,17 @@ Vite in `tests/packaging`; other bundlers are not covered.
59
59
 
60
60
  See the [Button](https://prostreyd.github.io/ant-design-svelte/components/button/),
61
61
  [Checkbox](https://prostreyd.github.io/ant-design-svelte/components/checkbox/),
62
+ [Grid](https://prostreyd.github.io/ant-design-svelte/components/grid/),
62
63
  [Input](https://prostreyd.github.io/ant-design-svelte/components/input/),
64
+ [Radio](https://prostreyd.github.io/ant-design-svelte/components/radio/),
63
65
  [Select](https://prostreyd.github.io/ant-design-svelte/components/select/),
64
66
  [Switch](https://prostreyd.github.io/ant-design-svelte/components/switch/) and
65
67
  [Tooltip](https://prostreyd.github.io/ant-design-svelte/components/tooltip/) pages of the documentation site for
66
68
  examples and the API tables, or [`src/lib/Button/README.md`](./src/lib/Button/README.md),
67
69
  [`src/lib/Checkbox/README.md`](./src/lib/Checkbox/README.md),
70
+ [`src/lib/Grid/README.md`](./src/lib/Grid/README.md),
68
71
  [`src/lib/Input/README.md`](./src/lib/Input/README.md),
72
+ [`src/lib/Radio/README.md`](./src/lib/Radio/README.md),
69
73
  [`src/lib/Select/README.md`](./src/lib/Select/README.md),
70
74
  [`src/lib/Switch/README.md`](./src/lib/Switch/README.md) and
71
75
  [`src/lib/Tooltip/README.md`](./src/lib/Tooltip/README.md) in the repository.
@@ -0,0 +1,43 @@
1
+ import type { Breakpoint } from './types.js';
2
+ export type BreakpointsOptions = {
3
+ /**
4
+ * The breakpoint to report where the screen cannot be asked (on the server). The flags are those of a screen exactly
5
+ * as wide as this breakpoint starts. Default `'xs'`.
6
+ */
7
+ fallback?: Breakpoint;
8
+ };
9
+ /**
10
+ * Which breakpoints the screen matches now, as plain properties that a template or a `$derived` can read:
11
+ *
12
+ * ```svelte
13
+ * <script>
14
+ * const screens = new Breakpoints();
15
+ * </script>
16
+ * {#if screens.md}...{/if}
17
+ * ```
18
+ *
19
+ * `xs` is true below 576 px; every other flag is true from its minimum width up (so at 1000 px `sm`, `md` and `lg` are
20
+ * true), and `current` is the largest one that matches. The values are read from the screen when the object is created,
21
+ * so they are right on the first render in a browser. On the server they follow `options.fallback`. The listeners exist
22
+ * only while something reactive reads the values.
23
+ */
24
+ export declare class Breakpoints {
25
+ #private;
26
+ constructor(options?: BreakpointsOptions);
27
+ /** Below 576 px. */
28
+ get xs(): boolean;
29
+ /** From 576 px up. */
30
+ get sm(): boolean;
31
+ /** From 768 px up. */
32
+ get md(): boolean;
33
+ /** From 992 px up. */
34
+ get lg(): boolean;
35
+ /** From 1200 px up. */
36
+ get xl(): boolean;
37
+ /** From 1600 px up. */
38
+ get xxl(): boolean;
39
+ /** From 1920 px up. */
40
+ get xxxl(): boolean;
41
+ /** The largest breakpoint that matches (`'xs'` below 576 px). */
42
+ get current(): Breakpoint;
43
+ }
@@ -0,0 +1,99 @@
1
+ import { createSubscriber } from 'svelte/reactivity';
2
+ import { resolveOption } from '../internal/options.js';
3
+ import { BREAKPOINT_NAMES, BREAKPOINTS } from './constants.js';
4
+ /**
5
+ * The media query of each breakpoint. `xs` is the complement of `sm` (below 576 px), the others are "from their
6
+ * minimum width up", so at any width `xs` is true or `sm` is, never both and never neither, even at 575.5 px.
7
+ */
8
+ const QUERIES = Object.freeze({
9
+ xs: `not all and (min-width: ${BREAKPOINTS.sm}px)`,
10
+ sm: `(min-width: ${BREAKPOINTS.sm}px)`,
11
+ md: `(min-width: ${BREAKPOINTS.md}px)`,
12
+ lg: `(min-width: ${BREAKPOINTS.lg}px)`,
13
+ xl: `(min-width: ${BREAKPOINTS.xl}px)`,
14
+ xxl: `(min-width: ${BREAKPOINTS.xxl}px)`,
15
+ xxxl: `(min-width: ${BREAKPOINTS.xxxl}px)`
16
+ });
17
+ /** Whether a screen exactly `width` px wide matches the breakpoint. */
18
+ function matchesWidth(breakpoint, width) {
19
+ return breakpoint === 'xs' ? width < BREAKPOINTS.sm : width >= BREAKPOINTS[breakpoint];
20
+ }
21
+ /**
22
+ * Which breakpoints the screen matches now, as plain properties that a template or a `$derived` can read:
23
+ *
24
+ * ```svelte
25
+ * <script>
26
+ * const screens = new Breakpoints();
27
+ * </script>
28
+ * {#if screens.md}...{/if}
29
+ * ```
30
+ *
31
+ * `xs` is true below 576 px; every other flag is true from its minimum width up (so at 1000 px `sm`, `md` and `lg` are
32
+ * true), and `current` is the largest one that matches. The values are read from the screen when the object is created,
33
+ * so they are right on the first render in a browser. On the server they follow `options.fallback`. The listeners exist
34
+ * only while something reactive reads the values.
35
+ */
36
+ export class Breakpoints {
37
+ #fallback;
38
+ #lists;
39
+ #subscribe;
40
+ constructor(options = {}) {
41
+ this.#fallback = resolveOption('Breakpoints', 'fallback', options.fallback ?? 'xs', BREAKPOINT_NAMES, 'xs');
42
+ this.#lists =
43
+ typeof window !== 'undefined' && typeof window.matchMedia === 'function'
44
+ ? Object.fromEntries(BREAKPOINT_NAMES.map((name) => [name, window.matchMedia(QUERIES[name])]))
45
+ : undefined;
46
+ this.#subscribe = createSubscriber((update) => {
47
+ const lists = this.#lists;
48
+ if (!lists)
49
+ return;
50
+ for (const name of BREAKPOINT_NAMES)
51
+ lists[name].addEventListener('change', update);
52
+ return () => {
53
+ for (const name of BREAKPOINT_NAMES)
54
+ lists[name].removeEventListener('change', update);
55
+ };
56
+ });
57
+ }
58
+ #matches(breakpoint) {
59
+ this.#subscribe();
60
+ const list = this.#lists?.[breakpoint];
61
+ return list ? list.matches : matchesWidth(breakpoint, BREAKPOINTS[this.#fallback]);
62
+ }
63
+ /** Below 576 px. */
64
+ get xs() {
65
+ return this.#matches('xs');
66
+ }
67
+ /** From 576 px up. */
68
+ get sm() {
69
+ return this.#matches('sm');
70
+ }
71
+ /** From 768 px up. */
72
+ get md() {
73
+ return this.#matches('md');
74
+ }
75
+ /** From 992 px up. */
76
+ get lg() {
77
+ return this.#matches('lg');
78
+ }
79
+ /** From 1200 px up. */
80
+ get xl() {
81
+ return this.#matches('xl');
82
+ }
83
+ /** From 1600 px up. */
84
+ get xxl() {
85
+ return this.#matches('xxl');
86
+ }
87
+ /** From 1920 px up. */
88
+ get xxxl() {
89
+ return this.#matches('xxxl');
90
+ }
91
+ /** The largest breakpoint that matches (`'xs'` below 576 px). */
92
+ get current() {
93
+ let current = 'xs';
94
+ for (const name of BREAKPOINT_NAMES)
95
+ if (name !== 'xs' && this.#matches(name))
96
+ current = name;
97
+ return current;
98
+ }
99
+ }
@@ -0,0 +1,300 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import { classList, styleText } from '../internal/semantic.js';
5
+ import { colVars } from './layout.js';
6
+ import type { ColSize } from './types.js';
7
+
8
+ type ColProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'style'> & {
9
+ /** How many of the 24 columns to take. `0` hides the column. Unset: the column keeps its content width. */
10
+ span?: number;
11
+ /** Empty columns before this one. */
12
+ offset?: number;
13
+ /** Columns to shift it towards the inline end, visually only (the DOM order does not change). */
14
+ push?: number;
15
+ /** Columns to shift it towards the inline start, visually only (the DOM order does not change). */
16
+ pull?: number;
17
+ /** The flex `order`, visually only (the DOM order does not change). */
18
+ order?: number;
19
+ /** A raw flex value: a number `n` is `n n auto`; a string is used as written (digits only: `n 1 0px`). */
20
+ flex?: string | number;
21
+ /** From 0 px up (the base of all widths). A number is a `span`. */
22
+ xs?: number | ColSize;
23
+ /** From 576 px up. A number is a `span`. */
24
+ sm?: number | ColSize;
25
+ /** From 768 px up. A number is a `span`. */
26
+ md?: number | ColSize;
27
+ /** From 992 px up. A number is a `span`. */
28
+ lg?: number | ColSize;
29
+ /** From 1200 px up. A number is a `span`. */
30
+ xl?: number | ColSize;
31
+ /** From 1600 px up. A number is a `span`. */
32
+ xxl?: number | ColSize;
33
+ /** From 1920 px up. A number is a `span`. */
34
+ xxxl?: number | ColSize;
35
+ /** Additional CSS class appended to the component classes. */
36
+ class?: string;
37
+ /** Inline style of the root; it is written after the component's own, so it wins on the same property. */
38
+ style?: string;
39
+ /** The content of the column. */
40
+ children?: Snippet;
41
+ };
42
+
43
+ let {
44
+ span,
45
+ offset,
46
+ push,
47
+ pull,
48
+ order,
49
+ flex,
50
+ xs,
51
+ sm,
52
+ md,
53
+ lg,
54
+ xl,
55
+ xxl,
56
+ xxxl,
57
+ class: customClass,
58
+ style,
59
+ children,
60
+ ...rest
61
+ }: ColProps = $props();
62
+
63
+ // Each given value is checked here (outside its contract it throws in development and is ignored in production)
64
+ // and written as a custom property; the `@media` rules below pick the one that fits the screen.
65
+ const vars = $derived(
66
+ colVars({ span, offset, push, pull, order, flex }, { xs, sm, md, lg, xl, xxl, xxxl })
67
+ );
68
+ const classes = $derived(classList('ads-col', customClass));
69
+ const inlineStyle = $derived(styleText(vars, style));
70
+ </script>
71
+
72
+ <div {...rest} class={classes} style={inlineStyle}>
73
+ {@render children?.()}
74
+ </div>
75
+
76
+ <style>
77
+ /*
78
+ * The component writes the values it was given as `--ads-col-<name>-<breakpoint>` (see layout.ts). A value that was
79
+ * not given stays "invalid" in the chains below, and a declaration that uses an invalid variable is dropped when the
80
+ * style is computed, so a column without `span` keeps its content width (`flex: 0 1 auto`). The `@media` rules at
81
+ * the end switch the resolved variables. The gutter `--_row-gx` comes from the Row the column stands in.
82
+ *
83
+ * Custom properties inherit, so the public ones are reset here: a Col inside a Col must not take the span of the outer
84
+ * one. An inline value, which the component writes, wins over this reset.
85
+ */
86
+ .ads-col {
87
+ --ads-col-span-xs: initial;
88
+ --ads-col-span-sm: initial;
89
+ --ads-col-span-md: initial;
90
+ --ads-col-span-lg: initial;
91
+ --ads-col-span-xl: initial;
92
+ --ads-col-span-xxl: initial;
93
+ --ads-col-span-xxxl: initial;
94
+ --ads-col-offset-xs: initial;
95
+ --ads-col-offset-sm: initial;
96
+ --ads-col-offset-md: initial;
97
+ --ads-col-offset-lg: initial;
98
+ --ads-col-offset-xl: initial;
99
+ --ads-col-offset-xxl: initial;
100
+ --ads-col-offset-xxxl: initial;
101
+ --ads-col-push-xs: initial;
102
+ --ads-col-push-sm: initial;
103
+ --ads-col-push-md: initial;
104
+ --ads-col-push-lg: initial;
105
+ --ads-col-push-xl: initial;
106
+ --ads-col-push-xxl: initial;
107
+ --ads-col-push-xxxl: initial;
108
+ --ads-col-pull-xs: initial;
109
+ --ads-col-pull-sm: initial;
110
+ --ads-col-pull-md: initial;
111
+ --ads-col-pull-lg: initial;
112
+ --ads-col-pull-xl: initial;
113
+ --ads-col-pull-xxl: initial;
114
+ --ads-col-pull-xxxl: initial;
115
+ --ads-col-order-xs: initial;
116
+ --ads-col-order-sm: initial;
117
+ --ads-col-order-md: initial;
118
+ --ads-col-order-lg: initial;
119
+ --ads-col-order-xl: initial;
120
+ --ads-col-order-xxl: initial;
121
+ --ads-col-order-xxxl: initial;
122
+ --ads-col-flex-xs: initial;
123
+ --ads-col-flex-sm: initial;
124
+ --ads-col-flex-md: initial;
125
+ --ads-col-flex-lg: initial;
126
+ --ads-col-flex-xl: initial;
127
+ --ads-col-flex-xxl: initial;
128
+ --ads-col-flex-xxxl: initial;
129
+ --ads-col-mw-xs: initial;
130
+ --ads-col-mw-sm: initial;
131
+ --ads-col-mw-md: initial;
132
+ --ads-col-mw-lg: initial;
133
+ --ads-col-mw-xl: initial;
134
+ --ads-col-mw-xxl: initial;
135
+ --ads-col-mw-xxxl: initial;
136
+ --ads-col-d-xs: initial;
137
+ --ads-col-d-sm: initial;
138
+ --ads-col-d-md: initial;
139
+ --ads-col-d-lg: initial;
140
+ --ads-col-d-xl: initial;
141
+ --ads-col-d-xxl: initial;
142
+ --ads-col-d-xxxl: initial;
143
+
144
+ --_span-xs: var(--ads-col-span-xs);
145
+ --_span-sm: var(--ads-col-span-sm, var(--_span-xs));
146
+ --_span-md: var(--ads-col-span-md, var(--_span-sm));
147
+ --_span-lg: var(--ads-col-span-lg, var(--_span-md));
148
+ --_span-xl: var(--ads-col-span-xl, var(--_span-lg));
149
+ --_span-xxl: var(--ads-col-span-xxl, var(--_span-xl));
150
+ --_span-xxxl: var(--ads-col-span-xxxl, var(--_span-xxl));
151
+ --_off-xs: var(--ads-col-offset-xs, 0);
152
+ --_off-sm: var(--ads-col-offset-sm, var(--_off-xs));
153
+ --_off-md: var(--ads-col-offset-md, var(--_off-sm));
154
+ --_off-lg: var(--ads-col-offset-lg, var(--_off-md));
155
+ --_off-xl: var(--ads-col-offset-xl, var(--_off-lg));
156
+ --_off-xxl: var(--ads-col-offset-xxl, var(--_off-xl));
157
+ --_off-xxxl: var(--ads-col-offset-xxxl, var(--_off-xxl));
158
+ --_push-xs: var(--ads-col-push-xs, 0);
159
+ --_push-sm: var(--ads-col-push-sm, var(--_push-xs));
160
+ --_push-md: var(--ads-col-push-md, var(--_push-sm));
161
+ --_push-lg: var(--ads-col-push-lg, var(--_push-md));
162
+ --_push-xl: var(--ads-col-push-xl, var(--_push-lg));
163
+ --_push-xxl: var(--ads-col-push-xxl, var(--_push-xl));
164
+ --_push-xxxl: var(--ads-col-push-xxxl, var(--_push-xxl));
165
+ --_pull-xs: var(--ads-col-pull-xs, 0);
166
+ --_pull-sm: var(--ads-col-pull-sm, var(--_pull-xs));
167
+ --_pull-md: var(--ads-col-pull-md, var(--_pull-sm));
168
+ --_pull-lg: var(--ads-col-pull-lg, var(--_pull-md));
169
+ --_pull-xl: var(--ads-col-pull-xl, var(--_pull-lg));
170
+ --_pull-xxl: var(--ads-col-pull-xxl, var(--_pull-xl));
171
+ --_pull-xxxl: var(--ads-col-pull-xxxl, var(--_pull-xxl));
172
+ --_order-xs: var(--ads-col-order-xs, 0);
173
+ --_order-sm: var(--ads-col-order-sm, var(--_order-xs));
174
+ --_order-md: var(--ads-col-order-md, var(--_order-sm));
175
+ --_order-lg: var(--ads-col-order-lg, var(--_order-md));
176
+ --_order-xl: var(--ads-col-order-xl, var(--_order-lg));
177
+ --_order-xxl: var(--ads-col-order-xxl, var(--_order-xl));
178
+ --_order-xxxl: var(--ads-col-order-xxxl, var(--_order-xxl));
179
+ --_flex-xs: var(--ads-col-flex-xs);
180
+ --_flex-sm: var(--ads-col-flex-sm, var(--_flex-xs));
181
+ --_flex-md: var(--ads-col-flex-md, var(--_flex-sm));
182
+ --_flex-lg: var(--ads-col-flex-lg, var(--_flex-md));
183
+ --_flex-xl: var(--ads-col-flex-xl, var(--_flex-lg));
184
+ --_flex-xxl: var(--ads-col-flex-xxl, var(--_flex-xl));
185
+ --_flex-xxxl: var(--ads-col-flex-xxxl, var(--_flex-xxl));
186
+ --_mw-xs: var(--ads-col-mw-xs);
187
+ --_mw-sm: var(--ads-col-mw-sm, var(--_mw-xs));
188
+ --_mw-md: var(--ads-col-mw-md, var(--_mw-sm));
189
+ --_mw-lg: var(--ads-col-mw-lg, var(--_mw-md));
190
+ --_mw-xl: var(--ads-col-mw-xl, var(--_mw-lg));
191
+ --_mw-xxl: var(--ads-col-mw-xxl, var(--_mw-xl));
192
+ --_mw-xxxl: var(--ads-col-mw-xxxl, var(--_mw-xxl));
193
+ --_d-xs: var(--ads-col-d-xs, block);
194
+ --_d-sm: var(--ads-col-d-sm, var(--_d-xs));
195
+ --_d-md: var(--ads-col-d-md, var(--_d-sm));
196
+ --_d-lg: var(--ads-col-d-lg, var(--_d-md));
197
+ --_d-xl: var(--ads-col-d-xl, var(--_d-lg));
198
+ --_d-xxl: var(--ads-col-d-xxl, var(--_d-xl));
199
+ --_d-xxxl: var(--ads-col-d-xxxl, var(--_d-xxl));
200
+
201
+ --_span: var(--_span-xs);
202
+ --_off: var(--_off-xs);
203
+ --_push: var(--_push-xs);
204
+ --_pull: var(--_pull-xs);
205
+ --_order: var(--_order-xs);
206
+ --_flex: var(--_flex-xs);
207
+ --_mw: var(--_mw-xs);
208
+ --_d: var(--_d-xs);
209
+
210
+ --_gx: var(--_row-gx, 0px);
211
+ /* The width of `span` columns: the span's share of the 24 columns, counting the gaps between them. */
212
+ --_w: calc((100% + var(--_gx)) * var(--_span) / 24 - var(--_gx));
213
+
214
+ position: relative;
215
+ display: var(--_d);
216
+ flex: var(--_flex, 0 0 var(--_w));
217
+ max-width: var(--_mw, var(--_w, 100%));
218
+ order: var(--_order);
219
+ margin-inline-start: calc((100% + var(--_gx)) * var(--_off) / 24);
220
+ inset-inline-start: calc((100% + var(--_gx)) * (var(--_push) - var(--_pull)) / 24);
221
+ }
222
+
223
+ @media (min-width: 576px) {
224
+ .ads-col {
225
+ --_span: var(--_span-sm);
226
+ --_off: var(--_off-sm);
227
+ --_push: var(--_push-sm);
228
+ --_pull: var(--_pull-sm);
229
+ --_order: var(--_order-sm);
230
+ --_flex: var(--_flex-sm);
231
+ --_mw: var(--_mw-sm);
232
+ --_d: var(--_d-sm);
233
+ }
234
+ }
235
+
236
+ @media (min-width: 768px) {
237
+ .ads-col {
238
+ --_span: var(--_span-md);
239
+ --_off: var(--_off-md);
240
+ --_push: var(--_push-md);
241
+ --_pull: var(--_pull-md);
242
+ --_order: var(--_order-md);
243
+ --_flex: var(--_flex-md);
244
+ --_mw: var(--_mw-md);
245
+ --_d: var(--_d-md);
246
+ }
247
+ }
248
+
249
+ @media (min-width: 992px) {
250
+ .ads-col {
251
+ --_span: var(--_span-lg);
252
+ --_off: var(--_off-lg);
253
+ --_push: var(--_push-lg);
254
+ --_pull: var(--_pull-lg);
255
+ --_order: var(--_order-lg);
256
+ --_flex: var(--_flex-lg);
257
+ --_mw: var(--_mw-lg);
258
+ --_d: var(--_d-lg);
259
+ }
260
+ }
261
+
262
+ @media (min-width: 1200px) {
263
+ .ads-col {
264
+ --_span: var(--_span-xl);
265
+ --_off: var(--_off-xl);
266
+ --_push: var(--_push-xl);
267
+ --_pull: var(--_pull-xl);
268
+ --_order: var(--_order-xl);
269
+ --_flex: var(--_flex-xl);
270
+ --_mw: var(--_mw-xl);
271
+ --_d: var(--_d-xl);
272
+ }
273
+ }
274
+
275
+ @media (min-width: 1600px) {
276
+ .ads-col {
277
+ --_span: var(--_span-xxl);
278
+ --_off: var(--_off-xxl);
279
+ --_push: var(--_push-xxl);
280
+ --_pull: var(--_pull-xxl);
281
+ --_order: var(--_order-xxl);
282
+ --_flex: var(--_flex-xxl);
283
+ --_mw: var(--_mw-xxl);
284
+ --_d: var(--_d-xxl);
285
+ }
286
+ }
287
+
288
+ @media (min-width: 1920px) {
289
+ .ads-col {
290
+ --_span: var(--_span-xxxl);
291
+ --_off: var(--_off-xxxl);
292
+ --_push: var(--_push-xxxl);
293
+ --_pull: var(--_pull-xxxl);
294
+ --_order: var(--_order-xxxl);
295
+ --_flex: var(--_flex-xxxl);
296
+ --_mw: var(--_mw-xxxl);
297
+ --_d: var(--_d-xxxl);
298
+ }
299
+ }
300
+ </style>
@@ -0,0 +1,40 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { ColSize } from './types.js';
4
+ type ColProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'style'> & {
5
+ /** How many of the 24 columns to take. `0` hides the column. Unset: the column keeps its content width. */
6
+ span?: number;
7
+ /** Empty columns before this one. */
8
+ offset?: number;
9
+ /** Columns to shift it towards the inline end, visually only (the DOM order does not change). */
10
+ push?: number;
11
+ /** Columns to shift it towards the inline start, visually only (the DOM order does not change). */
12
+ pull?: number;
13
+ /** The flex `order`, visually only (the DOM order does not change). */
14
+ order?: number;
15
+ /** A raw flex value: a number `n` is `n n auto`; a string is used as written (digits only: `n 1 0px`). */
16
+ flex?: string | number;
17
+ /** From 0 px up (the base of all widths). A number is a `span`. */
18
+ xs?: number | ColSize;
19
+ /** From 576 px up. A number is a `span`. */
20
+ sm?: number | ColSize;
21
+ /** From 768 px up. A number is a `span`. */
22
+ md?: number | ColSize;
23
+ /** From 992 px up. A number is a `span`. */
24
+ lg?: number | ColSize;
25
+ /** From 1200 px up. A number is a `span`. */
26
+ xl?: number | ColSize;
27
+ /** From 1600 px up. A number is a `span`. */
28
+ xxl?: number | ColSize;
29
+ /** From 1920 px up. A number is a `span`. */
30
+ xxxl?: number | ColSize;
31
+ /** Additional CSS class appended to the component classes. */
32
+ class?: string;
33
+ /** Inline style of the root; it is written after the component's own, so it wins on the same property. */
34
+ style?: string;
35
+ /** The content of the column. */
36
+ children?: Snippet;
37
+ };
38
+ declare const Col: import("svelte").Component<ColProps, {}, "">;
39
+ type Col = ReturnType<typeof Col>;
40
+ export default Col;
@@ -0,0 +1,75 @@
1
+ # Grid
2
+
3
+ A 24-column layout with Ant Design-inspired names and a Svelte 5 API. A `Row` lays out its `Col` children; a column takes
4
+ `span` of the 24 and moves to the next line as a whole when it does not fit. `Breakpoints` tells your code which breakpoints
5
+ the screen matches.
6
+
7
+ The API is inspired by Ant Design (MIT); the implementation is original for Svelte.
8
+
9
+ ## Usage
10
+
11
+ ```svelte
12
+ <script lang="ts">
13
+ import { Col, Row } from 'svelte-ant-design';
14
+ </script>
15
+
16
+ <Row gutter={16}>
17
+ <Col span={8}>one</Col>
18
+ <Col span={8}>two</Col>
19
+ <Col span={8}>three</Col>
20
+ </Row>
21
+ ```
22
+
23
+ The grid draws nothing, so it needs no design tokens.
24
+
25
+ ## Row
26
+
27
+ | Prop | Type | Default |
28
+ |---|---|---|
29
+ | `align` | `'top' \| 'middle' \| 'bottom' \| 'stretch'` or an object per breakpoint | `'top'` |
30
+ | `justify` | `'start' \| 'end' \| 'center' \| 'space-around' \| 'space-between' \| 'space-evenly'` or an object per breakpoint | `'start'` |
31
+ | `gutter` | number (px), CSS length string, object per breakpoint, or `[horizontal, vertical]` | `0` |
32
+ | `wrap` | `boolean` | `true` |
33
+
34
+ ## Col
35
+
36
+ | Prop | Type | Default |
37
+ |---|---|---|
38
+ | `span` | `number` (`0` hides the column) | unset |
39
+ | `offset`, `push`, `pull`, `order` | `number` | `0` |
40
+ | `flex` | `string \| number` | unset |
41
+ | `xs`, `sm`, `md`, `lg`, `xl`, `xxl`, `xxxl` | `number` (a span) or `{ span, offset, push, pull, order, flex }` | unset |
42
+
43
+ The breakpoints are 576, 768, 992, 1200, 1600 and 1920 px (`BREAKPOINTS` is exported). `xs` is the base of every width; a
44
+ breakpoint that is not given keeps the value of the next smaller one, and each key (`span`, `offset`, ...) cascades on its own.
45
+
46
+ ## Breakpoints
47
+
48
+ ```svelte
49
+ <script lang="ts">
50
+ import { Breakpoints } from 'svelte-ant-design';
51
+
52
+ const screens = new Breakpoints(); // options: { fallback: 'lg' } for a server render
53
+ </script>
54
+
55
+ {#if screens.md}...{/if}
56
+ {screens.current}
57
+ ```
58
+
59
+ `xs` is true below 576 px; every other flag is true from its width up. The values are right on the first render in a browser.
60
+
61
+ ## How it differs from Ant Design
62
+
63
+ - `gutter` is a flex `gap`. A `Row` is exactly as wide as its parent, so it never makes a page scroll sideways (the Ant Design
64
+ `Row` is wider than its parent by the gutter). The boxes of the content are in the same places.
65
+ - The responsive values are resolved in CSS, so the server and the browser render the same page and nothing flashes on
66
+ hydration. The breakpoints are fixed; a theme cannot change them.
67
+ - `Breakpoints` is a class, not a hook, and it is right on the first render.
68
+ - There is no `classNames` or `styles`: none of the three Ant Design libraries has them for the grid.
69
+
70
+ ## Accessibility
71
+
72
+ Row and Col are plain `<div>`s with no role, name or state. The reading order is the DOM order: `order`, `push` and `pull`
73
+ change only how the columns are drawn, so write the columns in the order they should be read.
74
+
75
+ See [`specs/grid.md`](../../../specs/grid.md) for the full contract.