@mason-ds/react 0.2.0 → 0.2.2

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/dist/index.cjs CHANGED
@@ -21,18 +21,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  Badge: () => Badge,
24
+ Box: () => Box,
24
25
  Button: () => Button,
25
26
  Callout: () => Callout,
26
27
  Card: () => Card,
27
28
  Checkbox: () => Checkbox,
29
+ Container: () => Container,
28
30
  Divider: () => Divider,
31
+ Grid: () => Grid,
29
32
  Link: () => Link,
30
33
  MasonProvider: () => MasonProvider,
34
+ Radio: () => Radio,
31
35
  Select: () => Select,
32
36
  Spinner: () => Spinner,
33
37
  Stack: () => Stack,
34
38
  Text: () => Text,
35
- TextField: () => TextField
39
+ TextField: () => TextField,
40
+ Toggle: () => Toggle
36
41
  });
37
42
  module.exports = __toCommonJS(index_exports);
38
43
 
@@ -50,6 +55,9 @@ function cssVar(path) {
50
55
  function spacingVar(axis, level) {
51
56
  return cssVar(`spacing.${axis}.${level}`);
52
57
  }
58
+ function containerMaxWidthVar(level) {
59
+ return cssVar(`spacing.layout.container.${level}`);
60
+ }
53
61
  function radiusVar(level) {
54
62
  return cssVar(`radius.${level}`);
55
63
  }
@@ -73,7 +81,7 @@ function mergeClassName(...parts) {
73
81
  return merged.length > 0 ? merged : void 0;
74
82
  }
75
83
 
76
- // src/textStyles.ts
84
+ // src/primitives/textStyles.ts
77
85
  function textStyle({
78
86
  variant = "body.md",
79
87
  tone = "primary",
@@ -89,7 +97,7 @@ function textStyle({
89
97
  };
90
98
  }
91
99
 
92
- // src/Text.tsx
100
+ // src/primitives/Text.tsx
93
101
  var import_jsx_runtime2 = require("react/jsx-runtime");
94
102
  function Text({
95
103
  as = "p",
@@ -116,7 +124,7 @@ function Text({
116
124
  );
117
125
  }
118
126
 
119
- // src/stackStyles.ts
127
+ // src/primitives/stackStyles.ts
120
128
  var FLEX_ALIGN = {
121
129
  start: "flex-start",
122
130
  center: "center",
@@ -149,7 +157,7 @@ function stackStyle({
149
157
  };
150
158
  }
151
159
 
152
- // src/Stack.tsx
160
+ // src/primitives/Stack.tsx
153
161
  var import_jsx_runtime3 = require("react/jsx-runtime");
154
162
  function Stack({
155
163
  direction = "column",
@@ -179,8 +187,156 @@ function Stack({
179
187
  );
180
188
  }
181
189
 
182
- // src/cardStyles.ts
190
+ // src/primitives/boxStyles.ts
183
191
  var TONE_BG = {
192
+ canvas: "color.bg.canvas",
193
+ surface: "color.bg.surface",
194
+ elevated: "color.bg.elevated"
195
+ };
196
+ function boxStyle({
197
+ padding,
198
+ tone = "transparent",
199
+ radius,
200
+ bordered = false
201
+ }) {
202
+ return {
203
+ display: "block",
204
+ boxSizing: "border-box",
205
+ minWidth: 0,
206
+ ...padding ? { padding: spacingVar("inset", padding) } : null,
207
+ ...tone !== "transparent" ? { backgroundColor: cssVar(TONE_BG[tone]) } : null,
208
+ ...radius ? { borderRadius: radiusVar(radius) } : null,
209
+ ...bordered ? { border: `1px solid ${cssVar("color.border.subtle")}` } : null
210
+ };
211
+ }
212
+
213
+ // src/primitives/Box.tsx
214
+ var import_jsx_runtime4 = require("react/jsx-runtime");
215
+ function Box({
216
+ as = "div",
217
+ padding,
218
+ tone = "transparent",
219
+ radius,
220
+ bordered = false,
221
+ className,
222
+ style,
223
+ children,
224
+ ...rest
225
+ }) {
226
+ const Component = as;
227
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
228
+ Component,
229
+ {
230
+ "data-mason-component": "box",
231
+ "data-tone": tone,
232
+ className: mergeClassName(className),
233
+ style: { ...boxStyle({ padding, tone, radius, bordered }), ...style },
234
+ ...rest,
235
+ children
236
+ }
237
+ );
238
+ }
239
+
240
+ // src/primitives/gridStyles.ts
241
+ var GRID_ALIGN = {
242
+ start: "start",
243
+ center: "center",
244
+ end: "end",
245
+ stretch: "stretch",
246
+ baseline: "baseline"
247
+ };
248
+ var GRID_JUSTIFY = {
249
+ start: "start",
250
+ center: "center",
251
+ end: "end",
252
+ between: "space-between"
253
+ };
254
+ function gridStyle({
255
+ columns = 2,
256
+ gap = "md",
257
+ align,
258
+ justify
259
+ }) {
260
+ return {
261
+ display: "grid",
262
+ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
263
+ gap: spacingVar("stack", gap),
264
+ minWidth: 0,
265
+ ...align ? { alignItems: GRID_ALIGN[align] } : null,
266
+ ...justify ? { justifyContent: GRID_JUSTIFY[justify] } : null
267
+ };
268
+ }
269
+
270
+ // src/primitives/Grid.tsx
271
+ var import_jsx_runtime5 = require("react/jsx-runtime");
272
+ function Grid({
273
+ columns = 2,
274
+ gap = "md",
275
+ align,
276
+ justify,
277
+ className,
278
+ style,
279
+ children,
280
+ ...rest
281
+ }) {
282
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
283
+ "div",
284
+ {
285
+ "data-mason-component": "grid",
286
+ "data-columns": columns,
287
+ className: mergeClassName(className),
288
+ style: { ...gridStyle({ columns, gap, align, justify }), ...style },
289
+ ...rest,
290
+ children
291
+ }
292
+ );
293
+ }
294
+
295
+ // src/primitives/containerStyles.ts
296
+ function containerStyle({
297
+ maxWidth = "lg",
298
+ padding,
299
+ center = true
300
+ }) {
301
+ return {
302
+ display: "block",
303
+ boxSizing: "border-box",
304
+ width: "100%",
305
+ minWidth: 0,
306
+ maxWidth: containerMaxWidthVar(maxWidth),
307
+ ...center ? { marginInline: "auto" } : null,
308
+ ...padding ? { paddingInline: spacingVar("inline", padding) } : null
309
+ };
310
+ }
311
+
312
+ // src/primitives/Container.tsx
313
+ var import_jsx_runtime6 = require("react/jsx-runtime");
314
+ function Container({
315
+ as = "div",
316
+ maxWidth = "lg",
317
+ padding,
318
+ center = true,
319
+ className,
320
+ style,
321
+ children,
322
+ ...rest
323
+ }) {
324
+ const Component = as;
325
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
326
+ Component,
327
+ {
328
+ "data-mason-component": "container",
329
+ "data-max-width": maxWidth,
330
+ className: mergeClassName(className),
331
+ style: { ...containerStyle({ maxWidth, padding, center }), ...style },
332
+ ...rest,
333
+ children
334
+ }
335
+ );
336
+ }
337
+
338
+ // src/primitives/cardStyles.ts
339
+ var TONE_BG2 = {
184
340
  surface: "color.bg.surface",
185
341
  canvas: "color.bg.canvas",
186
342
  elevated: "color.bg.elevated"
@@ -195,7 +351,7 @@ function cardStyle({
195
351
  return {
196
352
  display: "block",
197
353
  padding: spacingVar("inset", padding),
198
- backgroundColor: cssVar(TONE_BG[tone]),
354
+ backgroundColor: cssVar(TONE_BG2[tone]),
199
355
  color: cssVar("color.text.primary"),
200
356
  border: bordered ? `1px solid ${cssVar("color.border.subtle")}` : "none",
201
357
  borderRadius: radiusVar(radius),
@@ -205,8 +361,8 @@ function cardStyle({
205
361
  };
206
362
  }
207
363
 
208
- // src/Card.tsx
209
- var import_jsx_runtime4 = require("react/jsx-runtime");
364
+ // src/primitives/Card.tsx
365
+ var import_jsx_runtime7 = require("react/jsx-runtime");
210
366
  function Card({
211
367
  padding = "md",
212
368
  elevation = "sm",
@@ -218,7 +374,7 @@ function Card({
218
374
  children,
219
375
  ...rest
220
376
  }) {
221
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
377
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
222
378
  "div",
223
379
  {
224
380
  "data-mason-component": "card",
@@ -234,7 +390,7 @@ function Card({
234
390
  );
235
391
  }
236
392
 
237
- // src/dividerStyles.ts
393
+ // src/primitives/dividerStyles.ts
238
394
  function dividerStyle(orientation = "horizontal") {
239
395
  const line = `1px solid ${cssVar("color.border.subtle")}`;
240
396
  if (orientation === "vertical") {
@@ -256,15 +412,15 @@ function dividerStyle(orientation = "horizontal") {
256
412
  };
257
413
  }
258
414
 
259
- // src/Divider.tsx
260
- var import_jsx_runtime5 = require("react/jsx-runtime");
415
+ // src/primitives/Divider.tsx
416
+ var import_jsx_runtime8 = require("react/jsx-runtime");
261
417
  function Divider({
262
418
  orientation = "horizontal",
263
419
  className,
264
420
  style,
265
421
  ...rest
266
422
  }) {
267
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
423
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
268
424
  "hr",
269
425
  {
270
426
  "data-mason-component": "divider",
@@ -277,7 +433,7 @@ function Divider({
277
433
  );
278
434
  }
279
435
 
280
- // src/linkStyles.ts
436
+ // src/primitives/linkStyles.ts
281
437
  function linkStyle({
282
438
  tone = "link",
283
439
  underline = "hover"
@@ -291,8 +447,8 @@ function linkStyle({
291
447
  };
292
448
  }
293
449
 
294
- // src/Link.tsx
295
- var import_jsx_runtime6 = require("react/jsx-runtime");
450
+ // src/primitives/Link.tsx
451
+ var import_jsx_runtime9 = require("react/jsx-runtime");
296
452
  function Link({
297
453
  tone = "link",
298
454
  underline = "hover",
@@ -303,7 +459,7 @@ function Link({
303
459
  ...rest
304
460
  }) {
305
461
  const externalProps = external ? { target: "_blank", rel: "noreferrer noopener" } : null;
306
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
462
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
307
463
  "a",
308
464
  {
309
465
  "data-mason-component": "link",
@@ -318,7 +474,7 @@ function Link({
318
474
  );
319
475
  }
320
476
 
321
- // src/spinnerStyles.ts
477
+ // src/primitives/spinnerStyles.ts
322
478
  var SIZE_DIMENSION = {
323
479
  sm: cssVar("font.body.sm.size"),
324
480
  md: cssVar("font.body.md.size"),
@@ -338,8 +494,8 @@ function spinnerStyle(size = "md") {
338
494
  };
339
495
  }
340
496
 
341
- // src/Spinner.tsx
342
- var import_jsx_runtime7 = require("react/jsx-runtime");
497
+ // src/primitives/Spinner.tsx
498
+ var import_jsx_runtime10 = require("react/jsx-runtime");
343
499
  function Spinner({
344
500
  size = "md",
345
501
  label,
@@ -347,7 +503,7 @@ function Spinner({
347
503
  style,
348
504
  ...rest
349
505
  }) {
350
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
506
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
351
507
  "span",
352
508
  {
353
509
  "data-mason-component": "spinner",
@@ -362,14 +518,7 @@ function Spinner({
362
518
  );
363
519
  }
364
520
 
365
- // src/buttonStyles.ts
366
- function actionColors(variant) {
367
- return {
368
- bg: `color.action.${variant}.bg`,
369
- text: `color.action.${variant}.text`,
370
- border: `color.action.${variant}.border`
371
- };
372
- }
521
+ // src/primitives/buttonStyles.ts
373
522
  var sizeStyles = {
374
523
  sm: {
375
524
  paddingBlock: cssVar("spacing.inset.sm"),
@@ -393,14 +542,7 @@ var sizeStyles = {
393
542
  font: "label.lg"
394
543
  }
395
544
  };
396
- function buttonStyle({
397
- variant = "primary",
398
- size = "md",
399
- disabled = false,
400
- loading = false
401
- }) {
402
- const inactive = disabled || loading;
403
- const colors = actionColors(inactive ? "disabled" : variant);
545
+ function buttonStyle({ size = "md" }) {
404
546
  const sizing = sizeStyles[size];
405
547
  return {
406
548
  display: "inline-flex",
@@ -410,9 +552,6 @@ function buttonStyle({
410
552
  paddingBlock: sizing.paddingBlock,
411
553
  paddingInline: sizing.paddingInline,
412
554
  margin: 0,
413
- backgroundColor: cssVar(colors.bg),
414
- color: cssVar(colors.text),
415
- border: `1px solid ${cssVar(colors.border)}`,
416
555
  borderRadius: sizing.radius,
417
556
  boxSizing: "border-box",
418
557
  ...typographyStyle(sizing.font),
@@ -421,8 +560,8 @@ function buttonStyle({
421
560
  };
422
561
  }
423
562
 
424
- // src/Button.tsx
425
- var import_jsx_runtime8 = require("react/jsx-runtime");
563
+ // src/primitives/Button.tsx
564
+ var import_jsx_runtime11 = require("react/jsx-runtime");
426
565
  function Button({
427
566
  variant = "primary",
428
567
  size = "md",
@@ -437,7 +576,7 @@ function Button({
437
576
  ...rest
438
577
  }) {
439
578
  const isDisabled = disabled || loading;
440
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
579
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
441
580
  "button",
442
581
  {
443
582
  type,
@@ -448,20 +587,20 @@ function Button({
448
587
  "aria-busy": loading || void 0,
449
588
  className: mergeClassName(className),
450
589
  style: {
451
- ...buttonStyle({ variant, size, disabled, loading }),
590
+ ...buttonStyle({ size }),
452
591
  ...style
453
592
  },
454
593
  ...rest,
455
594
  children: [
456
- loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, { size: "inherit", "data-mason-slot": "spinner" }) : leadingSlot ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "data-mason-slot": "leading", children: leadingSlot }) : null,
457
- children ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "data-mason-slot": "label", children }) : null,
458
- trailingSlot && !loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "data-mason-slot": "trailing", children: trailingSlot }) : null
595
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Spinner, { size: "inherit", "data-mason-slot": "spinner" }) : leadingSlot ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "data-mason-slot": "leading", children: leadingSlot }) : null,
596
+ children ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "data-mason-slot": "label", children }) : null,
597
+ trailingSlot && !loading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "data-mason-slot": "trailing", children: trailingSlot }) : null
459
598
  ]
460
599
  }
461
600
  );
462
601
  }
463
602
 
464
- // src/badgeStyles.ts
603
+ // src/primitives/badgeStyles.ts
465
604
  function badgeStyle({
466
605
  tone = "neutral",
467
606
  size = "sm"
@@ -490,8 +629,8 @@ function badgeStyle({
490
629
  };
491
630
  }
492
631
 
493
- // src/Badge.tsx
494
- var import_jsx_runtime9 = require("react/jsx-runtime");
632
+ // src/primitives/Badge.tsx
633
+ var import_jsx_runtime12 = require("react/jsx-runtime");
495
634
  function Badge({
496
635
  tone = "neutral",
497
636
  size = "sm",
@@ -500,7 +639,7 @@ function Badge({
500
639
  children,
501
640
  ...rest
502
641
  }) {
503
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
642
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
504
643
  "span",
505
644
  {
506
645
  "data-mason-component": "badge",
@@ -514,7 +653,7 @@ function Badge({
514
653
  );
515
654
  }
516
655
 
517
- // src/calloutStyles.ts
656
+ // src/primitives/calloutStyles.ts
518
657
  function calloutStyle(tone = "info") {
519
658
  return {
520
659
  display: "flex",
@@ -543,8 +682,8 @@ function calloutBodyStyle() {
543
682
  return { margin: 0, ...typographyStyle("body.sm") };
544
683
  }
545
684
 
546
- // src/Callout.tsx
547
- var import_jsx_runtime10 = require("react/jsx-runtime");
685
+ // src/primitives/Callout.tsx
686
+ var import_jsx_runtime13 = require("react/jsx-runtime");
548
687
  function Callout({
549
688
  tone = "info",
550
689
  title,
@@ -554,7 +693,7 @@ function Callout({
554
693
  children,
555
694
  ...rest
556
695
  }) {
557
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
696
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
558
697
  "div",
559
698
  {
560
699
  "data-mason-component": "callout",
@@ -563,20 +702,20 @@ function Callout({
563
702
  style: { ...calloutStyle(tone), ...style },
564
703
  ...rest,
565
704
  children: [
566
- iconSlot ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "data-mason-slot": "icon", "aria-hidden": "true", children: iconSlot }) : null,
567
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { "data-mason-slot": "content", style: calloutContentStyle(), children: [
568
- title ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { "data-mason-slot": "title", style: calloutTitleStyle(), children: title }) : null,
569
- children ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "data-mason-slot": "body", style: calloutBodyStyle(), children }) : null
705
+ iconSlot ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { "data-mason-slot": "icon", "aria-hidden": "true", children: iconSlot }) : null,
706
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { "data-mason-slot": "content", style: calloutContentStyle(), children: [
707
+ title ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { "data-mason-slot": "title", style: calloutTitleStyle(), children: title }) : null,
708
+ children ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { "data-mason-slot": "body", style: calloutBodyStyle(), children }) : null
570
709
  ] })
571
710
  ]
572
711
  }
573
712
  );
574
713
  }
575
714
 
576
- // src/field.tsx
715
+ // src/compounds/field.tsx
577
716
  var import_react = require("react");
578
717
 
579
- // src/fieldStyles.ts
718
+ // src/compounds/fieldStyles.ts
580
719
  var CONTROL_FONT = {
581
720
  sm: "body.sm",
582
721
  md: "body.md",
@@ -637,9 +776,26 @@ function fieldErrorStyle() {
637
776
  ...typographyStyle("body.sm")
638
777
  };
639
778
  }
779
+ function visuallyHiddenControlStyle() {
780
+ return {
781
+ position: "absolute",
782
+ left: 0,
783
+ top: 0,
784
+ width: 1,
785
+ height: 1,
786
+ padding: 0,
787
+ margin: 0,
788
+ overflow: "hidden",
789
+ clip: "rect(0, 0, 0, 0)",
790
+ whiteSpace: "nowrap",
791
+ borderWidth: 0,
792
+ borderStyle: "solid",
793
+ borderColor: "transparent"
794
+ };
795
+ }
640
796
 
641
- // src/field.tsx
642
- var import_jsx_runtime11 = require("react/jsx-runtime");
797
+ // src/compounds/field.tsx
798
+ var import_jsx_runtime14 = require("react/jsx-runtime");
643
799
  function useFieldIds({
644
800
  id,
645
801
  description,
@@ -665,7 +821,7 @@ function FieldFrame({
665
821
  style,
666
822
  children
667
823
  }) {
668
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
824
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
669
825
  "div",
670
826
  {
671
827
  "data-mason-component": component,
@@ -675,7 +831,7 @@ function FieldFrame({
675
831
  className: mergeClassName(className),
676
832
  style: { ...fieldRootStyle(), ...style },
677
833
  children: [
678
- label ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
834
+ label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
679
835
  "label",
680
836
  {
681
837
  "data-mason-slot": "label",
@@ -685,7 +841,7 @@ function FieldFrame({
685
841
  }
686
842
  ) : null,
687
843
  children,
688
- description ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
844
+ description ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
689
845
  "p",
690
846
  {
691
847
  "data-mason-slot": "description",
@@ -694,7 +850,7 @@ function FieldFrame({
694
850
  children: description
695
851
  }
696
852
  ) : null,
697
- error ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
853
+ error ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
698
854
  "p",
699
855
  {
700
856
  "data-mason-slot": "error",
@@ -709,8 +865,8 @@ function FieldFrame({
709
865
  );
710
866
  }
711
867
 
712
- // src/TextField.tsx
713
- var import_jsx_runtime12 = require("react/jsx-runtime");
868
+ // src/compounds/TextField.tsx
869
+ var import_jsx_runtime15 = require("react/jsx-runtime");
714
870
  function TextField({
715
871
  label,
716
872
  description,
@@ -725,7 +881,7 @@ function TextField({
725
881
  }) {
726
882
  const ids = useFieldIds({ id, description, error });
727
883
  const isInvalid = invalid ?? Boolean(error);
728
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
884
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
729
885
  FieldFrame,
730
886
  {
731
887
  component: "text-field",
@@ -738,7 +894,7 @@ function TextField({
738
894
  disabled,
739
895
  className,
740
896
  style,
741
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
897
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
742
898
  "input",
743
899
  {
744
900
  ...rest,
@@ -754,8 +910,8 @@ function TextField({
754
910
  );
755
911
  }
756
912
 
757
- // src/Select.tsx
758
- var import_jsx_runtime13 = require("react/jsx-runtime");
913
+ // src/compounds/Select.tsx
914
+ var import_jsx_runtime16 = require("react/jsx-runtime");
759
915
  function Select({
760
916
  label,
761
917
  description,
@@ -772,7 +928,7 @@ function Select({
772
928
  }) {
773
929
  const ids = useFieldIds({ id, description, error });
774
930
  const isInvalid = invalid ?? Boolean(error);
775
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
931
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
776
932
  FieldFrame,
777
933
  {
778
934
  component: "select",
@@ -785,7 +941,7 @@ function Select({
785
941
  disabled,
786
942
  className,
787
943
  style,
788
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
944
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
789
945
  "select",
790
946
  {
791
947
  ...rest,
@@ -796,7 +952,7 @@ function Select({
796
952
  "aria-describedby": ids.describedBy,
797
953
  style: fieldControlStyle({ size, invalid: isInvalid, disabled }),
798
954
  children: [
799
- placeholder ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: placeholder }) : null,
955
+ placeholder ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: placeholder }) : null,
800
956
  children
801
957
  ]
802
958
  }
@@ -805,9 +961,11 @@ function Select({
805
961
  );
806
962
  }
807
963
 
808
- // src/checkboxStyles.ts
964
+ // src/compounds/checkboxStyles.ts
965
+ var CONTROL_SIZE = "1.125rem";
809
966
  function checkboxRootStyle() {
810
967
  return {
968
+ position: "relative",
811
969
  display: "flex",
812
970
  flexDirection: "column",
813
971
  gap: spacingVar("stack", "sm"),
@@ -824,19 +982,24 @@ function checkboxLabelStyle(disabled = false) {
824
982
  ...typographyStyle("body.md")
825
983
  };
826
984
  }
827
- function checkboxControlStyle() {
985
+ function checkboxIndicatorStyle() {
828
986
  return {
829
- width: "1em",
830
- height: "1em",
831
- margin: 0,
832
- marginBlockStart: "0.15em",
833
- accentColor: cssVar("color.action.primary.bg"),
834
- flexShrink: 0
987
+ display: "inline-flex",
988
+ alignItems: "center",
989
+ justifyContent: "center",
990
+ width: CONTROL_SIZE,
991
+ height: CONTROL_SIZE,
992
+ marginBlockStart: "0.2em",
993
+ flexShrink: 0,
994
+ boxSizing: "border-box",
995
+ borderRadius: radiusVar("sm"),
996
+ borderStyle: "solid",
997
+ borderWidth: "1.5px"
835
998
  };
836
999
  }
837
1000
 
838
- // src/Checkbox.tsx
839
- var import_jsx_runtime14 = require("react/jsx-runtime");
1001
+ // src/compounds/Checkbox.tsx
1002
+ var import_jsx_runtime17 = require("react/jsx-runtime");
840
1003
  function Checkbox({
841
1004
  label,
842
1005
  description,
@@ -850,7 +1013,7 @@ function Checkbox({
850
1013
  }) {
851
1014
  const ids = useFieldIds({ id, description, error });
852
1015
  const isInvalid = invalid ?? Boolean(error);
853
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1016
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
854
1017
  "div",
855
1018
  {
856
1019
  "data-mason-component": "checkbox",
@@ -859,14 +1022,14 @@ function Checkbox({
859
1022
  className: mergeClassName(className),
860
1023
  style: { ...checkboxRootStyle(), ...style },
861
1024
  children: [
862
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1025
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
863
1026
  "label",
864
1027
  {
865
1028
  "data-mason-slot": "label",
866
1029
  htmlFor: ids.controlId,
867
1030
  style: checkboxLabelStyle(disabled),
868
1031
  children: [
869
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1032
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
870
1033
  "input",
871
1034
  {
872
1035
  ...rest,
@@ -876,14 +1039,15 @@ function Checkbox({
876
1039
  disabled,
877
1040
  "aria-invalid": isInvalid || void 0,
878
1041
  "aria-describedby": ids.describedBy,
879
- style: checkboxControlStyle()
1042
+ style: visuallyHiddenControlStyle()
880
1043
  }
881
1044
  ),
882
- label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { "data-mason-slot": "label-text", children: label }) : null
1045
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { "data-mason-slot": "indicator", "aria-hidden": "true", style: checkboxIndicatorStyle() }),
1046
+ label ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { "data-mason-slot": "label-text", children: label }) : null
883
1047
  ]
884
1048
  }
885
1049
  ),
886
- description ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1050
+ description ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
887
1051
  "p",
888
1052
  {
889
1053
  "data-mason-slot": "description",
@@ -892,7 +1056,245 @@ function Checkbox({
892
1056
  children: description
893
1057
  }
894
1058
  ) : null,
895
- error ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1059
+ error ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1060
+ "p",
1061
+ {
1062
+ "data-mason-slot": "error",
1063
+ id: ids.errorId,
1064
+ role: "alert",
1065
+ style: fieldErrorStyle(),
1066
+ children: error
1067
+ }
1068
+ ) : null
1069
+ ]
1070
+ }
1071
+ );
1072
+ }
1073
+
1074
+ // src/compounds/radioStyles.ts
1075
+ var CONTROL_SIZE2 = "1.125rem";
1076
+ function radioRootStyle() {
1077
+ return {
1078
+ position: "relative",
1079
+ display: "flex",
1080
+ flexDirection: "column",
1081
+ gap: spacingVar("stack", "sm"),
1082
+ minWidth: 0
1083
+ };
1084
+ }
1085
+ function radioLabelStyle(disabled = false) {
1086
+ return {
1087
+ display: "inline-flex",
1088
+ alignItems: "flex-start",
1089
+ gap: spacingVar("inline", "sm"),
1090
+ cursor: disabled ? "not-allowed" : "pointer",
1091
+ color: disabled ? cssVar("color.text.disabled") : cssVar("color.text.primary"),
1092
+ ...typographyStyle("body.md")
1093
+ };
1094
+ }
1095
+ function radioIndicatorStyle() {
1096
+ return {
1097
+ display: "inline-flex",
1098
+ alignItems: "center",
1099
+ justifyContent: "center",
1100
+ width: CONTROL_SIZE2,
1101
+ height: CONTROL_SIZE2,
1102
+ marginBlockStart: "0.2em",
1103
+ flexShrink: 0,
1104
+ boxSizing: "border-box",
1105
+ borderRadius: "999px",
1106
+ borderStyle: "solid",
1107
+ borderWidth: "1.5px"
1108
+ };
1109
+ }
1110
+
1111
+ // src/compounds/Radio.tsx
1112
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1113
+ function Radio({
1114
+ label,
1115
+ description,
1116
+ error,
1117
+ invalid,
1118
+ id,
1119
+ disabled = false,
1120
+ className,
1121
+ style,
1122
+ ...rest
1123
+ }) {
1124
+ const ids = useFieldIds({ id, description, error });
1125
+ const isInvalid = invalid ?? Boolean(error);
1126
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1127
+ "div",
1128
+ {
1129
+ "data-mason-component": "radio",
1130
+ "data-invalid": isInvalid || void 0,
1131
+ "data-disabled": disabled || void 0,
1132
+ className: mergeClassName(className),
1133
+ style: { ...radioRootStyle(), ...style },
1134
+ children: [
1135
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1136
+ "label",
1137
+ {
1138
+ "data-mason-slot": "label",
1139
+ htmlFor: ids.controlId,
1140
+ style: radioLabelStyle(disabled),
1141
+ children: [
1142
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1143
+ "input",
1144
+ {
1145
+ ...rest,
1146
+ type: "radio",
1147
+ id: ids.controlId,
1148
+ "data-mason-slot": "control",
1149
+ disabled,
1150
+ "aria-invalid": isInvalid || void 0,
1151
+ "aria-describedby": ids.describedBy,
1152
+ style: visuallyHiddenControlStyle()
1153
+ }
1154
+ ),
1155
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { "data-mason-slot": "indicator", "aria-hidden": "true", style: radioIndicatorStyle() }),
1156
+ label ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { "data-mason-slot": "label-text", children: label }) : null
1157
+ ]
1158
+ }
1159
+ ),
1160
+ description ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1161
+ "p",
1162
+ {
1163
+ "data-mason-slot": "description",
1164
+ id: ids.descriptionId,
1165
+ style: fieldDescriptionStyle(),
1166
+ children: description
1167
+ }
1168
+ ) : null,
1169
+ error ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1170
+ "p",
1171
+ {
1172
+ "data-mason-slot": "error",
1173
+ id: ids.errorId,
1174
+ role: "alert",
1175
+ style: fieldErrorStyle(),
1176
+ children: error
1177
+ }
1178
+ ) : null
1179
+ ]
1180
+ }
1181
+ );
1182
+ }
1183
+
1184
+ // src/compounds/toggleStyles.ts
1185
+ var TRACK = {
1186
+ sm: { width: "1.75rem", height: "1rem" },
1187
+ md: { width: "2.25rem", height: "1.25rem" },
1188
+ lg: { width: "2.75rem", height: "1.5rem" }
1189
+ };
1190
+ var THUMB = {
1191
+ sm: "0.75rem",
1192
+ md: "1rem",
1193
+ lg: "1.25rem"
1194
+ };
1195
+ function toggleRootStyle() {
1196
+ return {
1197
+ position: "relative",
1198
+ display: "flex",
1199
+ flexDirection: "column",
1200
+ gap: spacingVar("stack", "sm"),
1201
+ minWidth: 0
1202
+ };
1203
+ }
1204
+ function toggleLabelStyle(disabled = false) {
1205
+ return {
1206
+ display: "inline-flex",
1207
+ alignItems: "center",
1208
+ gap: spacingVar("inline", "sm"),
1209
+ cursor: disabled ? "not-allowed" : "pointer",
1210
+ color: disabled ? cssVar("color.text.disabled") : cssVar("color.text.primary"),
1211
+ ...typographyStyle("label.md")
1212
+ };
1213
+ }
1214
+ function toggleIndicatorStyle(size = "md") {
1215
+ return {
1216
+ position: "relative",
1217
+ display: "inline-flex",
1218
+ alignItems: "center",
1219
+ width: TRACK[size].width,
1220
+ height: TRACK[size].height,
1221
+ padding: "0.125rem",
1222
+ flexShrink: 0,
1223
+ boxSizing: "border-box",
1224
+ borderRadius: radiusVar("full")
1225
+ };
1226
+ }
1227
+ function toggleThumbStyle(size = "md") {
1228
+ return {
1229
+ width: THUMB[size],
1230
+ height: THUMB[size],
1231
+ borderRadius: radiusVar("full"),
1232
+ flexShrink: 0
1233
+ };
1234
+ }
1235
+
1236
+ // src/compounds/Toggle.tsx
1237
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1238
+ function Toggle({
1239
+ label,
1240
+ description,
1241
+ error,
1242
+ invalid,
1243
+ size = "md",
1244
+ id,
1245
+ disabled = false,
1246
+ className,
1247
+ style,
1248
+ ...rest
1249
+ }) {
1250
+ const ids = useFieldIds({ id, description, error });
1251
+ const isInvalid = invalid ?? Boolean(error);
1252
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1253
+ "div",
1254
+ {
1255
+ "data-mason-component": "toggle",
1256
+ "data-size": size,
1257
+ "data-invalid": isInvalid || void 0,
1258
+ "data-disabled": disabled || void 0,
1259
+ className: mergeClassName(className),
1260
+ style: { ...toggleRootStyle(), ...style },
1261
+ children: [
1262
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1263
+ "label",
1264
+ {
1265
+ "data-mason-slot": "label",
1266
+ htmlFor: ids.controlId,
1267
+ style: toggleLabelStyle(disabled),
1268
+ children: [
1269
+ label ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-mason-slot": "label-text", children: label }) : null,
1270
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1271
+ "input",
1272
+ {
1273
+ ...rest,
1274
+ type: "checkbox",
1275
+ role: "switch",
1276
+ id: ids.controlId,
1277
+ "data-mason-slot": "control",
1278
+ disabled,
1279
+ "aria-invalid": isInvalid || void 0,
1280
+ "aria-describedby": ids.describedBy,
1281
+ style: visuallyHiddenControlStyle()
1282
+ }
1283
+ ),
1284
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-mason-slot": "indicator", "aria-hidden": "true", style: toggleIndicatorStyle(size), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-mason-slot": "thumb", style: toggleThumbStyle(size) }) })
1285
+ ]
1286
+ }
1287
+ ),
1288
+ description ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1289
+ "p",
1290
+ {
1291
+ "data-mason-slot": "description",
1292
+ id: ids.descriptionId,
1293
+ style: fieldDescriptionStyle(),
1294
+ children: description
1295
+ }
1296
+ ) : null,
1297
+ error ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
896
1298
  "p",
897
1299
  {
898
1300
  "data-mason-slot": "error",
@@ -909,17 +1311,22 @@ function Checkbox({
909
1311
  // Annotate the CommonJS export names for ESM import in node:
910
1312
  0 && (module.exports = {
911
1313
  Badge,
1314
+ Box,
912
1315
  Button,
913
1316
  Callout,
914
1317
  Card,
915
1318
  Checkbox,
1319
+ Container,
916
1320
  Divider,
1321
+ Grid,
917
1322
  Link,
918
1323
  MasonProvider,
1324
+ Radio,
919
1325
  Select,
920
1326
  Spinner,
921
1327
  Stack,
922
1328
  Text,
923
- TextField
1329
+ TextField,
1330
+ Toggle
924
1331
  });
925
1332
  //# sourceMappingURL=index.cjs.map