@allxsmith/bestax-bulma 5.54.1 → 5.55.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.
Files changed (74) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Command.js +22 -22
  4. package/dist/esm/components/Command.js.map +1 -1
  5. package/dist/esm/components/DataTable.js +215 -0
  6. package/dist/esm/components/DataTable.js.map +1 -0
  7. package/dist/esm/components/useDataTable.js +482 -0
  8. package/dist/esm/components/useDataTable.js.map +1 -0
  9. package/dist/esm/elements/ColorSwatch.js +49 -0
  10. package/dist/esm/elements/ColorSwatch.js.map +1 -0
  11. package/dist/esm/elements/RingProgress.js +3 -3
  12. package/dist/esm/elements/Td.js +4 -2
  13. package/dist/esm/elements/Td.js.map +1 -1
  14. package/dist/esm/elements/Th.js +13 -5
  15. package/dist/esm/elements/Th.js.map +1 -1
  16. package/dist/esm/elements/Tr.js.map +1 -1
  17. package/dist/esm/form/ColorPicker.js +540 -0
  18. package/dist/esm/form/ColorPicker.js.map +1 -0
  19. package/dist/esm/form/Combobox.js +18 -18
  20. package/dist/esm/form/Combobox.js.map +1 -1
  21. package/dist/esm/form/Dropzone.js +524 -0
  22. package/dist/esm/form/Dropzone.js.map +1 -0
  23. package/dist/esm/form/_colorInternals/colorMath.js +292 -0
  24. package/dist/esm/form/_colorInternals/colorMath.js.map +1 -0
  25. package/dist/esm/form/_colorInternals/pickerState.js +160 -0
  26. package/dist/esm/form/_colorInternals/pickerState.js.map +1 -0
  27. package/dist/esm/helpers/statusRegion.js +3 -3
  28. package/dist/esm/helpers/statusRegion.js.map +1 -1
  29. package/dist/esm/helpers/useFocusTrap.js +2 -2
  30. package/dist/extras.css +1 -1
  31. package/dist/extras.css.map +1 -1
  32. package/dist/index.cjs +2986 -796
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.esm.js +5 -0
  35. package/dist/index.esm.js.map +1 -1
  36. package/dist/types/components/DataTable.d.ts +120 -0
  37. package/dist/types/components/useDataTable.d.ts +445 -0
  38. package/dist/types/elements/ColorSwatch.d.ts +54 -0
  39. package/dist/types/elements/Td.d.ts +9 -1
  40. package/dist/types/elements/Th.d.ts +14 -2
  41. package/dist/types/elements/Tr.d.ts +10 -1
  42. package/dist/types/form/ColorPicker.d.ts +266 -0
  43. package/dist/types/form/Dropzone.d.ts +138 -0
  44. package/dist/types/form/_colorInternals/colorMath.d.ts +63 -0
  45. package/dist/types/form/_colorInternals/pickerState.d.ts +62 -0
  46. package/dist/types/index.d.ts +4 -0
  47. package/dist/types-cjs/components/DataTable.d.ts +120 -0
  48. package/dist/types-cjs/components/useDataTable.d.ts +445 -0
  49. package/dist/types-cjs/elements/ColorSwatch.d.ts +54 -0
  50. package/dist/types-cjs/elements/Td.d.ts +9 -1
  51. package/dist/types-cjs/elements/Th.d.ts +14 -2
  52. package/dist/types-cjs/elements/Tr.d.ts +10 -1
  53. package/dist/types-cjs/form/ColorPicker.d.ts +266 -0
  54. package/dist/types-cjs/form/Dropzone.d.ts +138 -0
  55. package/dist/types-cjs/form/_colorInternals/colorMath.d.ts +63 -0
  56. package/dist/types-cjs/form/_colorInternals/pickerState.d.ts +62 -0
  57. package/dist/types-cjs/index.d.ts +4 -0
  58. package/dist/versions/bestax-no-dark-mode.css +1 -1
  59. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  60. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  61. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  62. package/dist/versions/bestax-no-helpers.css +1 -1
  63. package/dist/versions/bestax-no-helpers.css.map +1 -1
  64. package/dist/versions/bestax-prefixed.css +1 -1
  65. package/dist/versions/bestax-prefixed.css.map +1 -1
  66. package/package.json +1 -1
  67. package/src/scss/components/_datatable.scss +152 -0
  68. package/src/scss/components/_index.scss +1 -0
  69. package/src/scss/elements/_colorswatch.scss +100 -0
  70. package/src/scss/elements/_index.scss +1 -0
  71. package/src/scss/form/_checkbox.scss +53 -0
  72. package/src/scss/form/_colorpicker.scss +354 -0
  73. package/src/scss/form/_dropzone.scss +233 -0
  74. package/src/scss/form/_index.scss +2 -0
@@ -0,0 +1,49 @@
1
+ /* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { forwardRef, useEffect } from 'react';
4
+ import { usePrefixedClassNames, classNames } from '../helpers/classNames.js';
5
+ import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
6
+ import { warnOnce } from '../helpers/devWarnings.js';
7
+
8
+ const validColorSwatchSizes = ['small', 'medium', 'large'];
9
+ /**
10
+ * The `ColorSwatch` component shows a color as a small chip, named by its label or by the color itself.
11
+ *
12
+ * It's an image to assistive tech, so the color is always there in words.
13
+ * In forced colors it keeps its color, edged in the system's text color.
14
+ *
15
+ * @function
16
+ * @param {ColorSwatchProps} props - Props for the ColorSwatch component.
17
+ * @param {React.Ref<HTMLSpanElement>} ref - Forwarded ref to the `<span>`.
18
+ * @returns {JSX.Element} The rendered swatch.
19
+ *
20
+ * @example
21
+ * <ColorSwatch color="#1e6b99" label="Brand blue" />
22
+ */
23
+ const ColorSwatch = forwardRef(({ className, textColor, color, label, size, isRounded, children, style, ...props }, ref) => {
24
+ const { bulmaHelperClasses, rest } = useBulmaClasses({
25
+ color: textColor,
26
+ ...props,
27
+ });
28
+ const unnamed = /^\s*var\(/i.test(color) &&
29
+ !label &&
30
+ !rest['aria-label'] &&
31
+ !rest['aria-labelledby'] &&
32
+ !rest['aria-hidden'];
33
+ useEffect(() => {
34
+ if (unnamed) {
35
+ warnOnce('ColorSwatch:unnamed-var', '[bestax-bulma] <ColorSwatch> shows a CSS variable with no label, ' +
36
+ 'so a screen reader reads the var() as its name. Pass label, ' +
37
+ 'such as "Primary".');
38
+ }
39
+ }, [unnamed]);
40
+ const swatchClass = usePrefixedClassNames('color-swatch', {
41
+ [`is-${size}`]: !!size && validColorSwatchSizes.includes(size),
42
+ 'is-rounded': !!isRounded,
43
+ });
44
+ return (jsx("span", { ref: ref, className: classNames(swatchClass, bulmaHelperClasses, className), style: { ...style, ['--color-swatch-color']: color }, ...rest, role: "img", "aria-label": rest['aria-label'] || label || color, children: children !== undefined && children !== null && (jsx("span", { "aria-hidden": "true", children: children })) }));
45
+ });
46
+ ColorSwatch.displayName = 'ColorSwatch';
47
+
48
+ export { ColorSwatch };
49
+ //# sourceMappingURL=ColorSwatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorSwatch.js","sources":["../../../src/elements/ColorSwatch.tsx"],"sourcesContent":["import React, { forwardRef, useEffect } from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport {\n useBulmaClasses,\n BulmaClassesProps,\n validColors,\n} from '../helpers/useBulmaClasses';\nimport { warnOnce } from '../helpers/devWarnings';\n\nconst validColorSwatchSizes = ['small', 'medium', 'large'] as const;\n\n/**\n * Props for the ColorSwatch component. The helper props, the other\n * attributes and the `ref` land on its `<span>`.\n *\n * @extraProp {React.Ref<HTMLSpanElement>} [ref] - Ref forwarded to the `<span>`.\n * @extraProp {string} [aria-label] - Names the swatch in place of `label`.\n * @extraProp {boolean} [aria-hidden] - Hides the swatch from assistive tech, for one beside text that already names the color.\n */\nexport interface ColorSwatchProps\n extends\n Omit<React.HTMLAttributes<HTMLSpanElement>, 'color' | 'role'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /**\n * The color it shows: any CSS color, such as `#1e6b99`,\n * `hsl(202, 67%, 36%)` or `var(--bulma-primary)`. A see-through color\n * shows a checkerboard behind it.\n */\n color: string;\n /**\n * What the color is called, such as \"Brand blue\", read as the swatch's\n * name in place of `color` as written. A `var()` reads as nothing useful,\n * so a development build warns when one has no name.\n */\n label?: string;\n /** The swatch's size. */\n size?: (typeof validColorSwatchSizes)[number];\n /** Draws a circle in place of a rounded square. */\n isRounded?: boolean;\n /**\n * Drawn on the swatch, such as an icon. It's hidden from assistive tech,\n * since the swatch is an image named by its label.\n */\n children?: React.ReactNode;\n /** Text color helper, the color of anything drawn on the swatch. */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n}\n\n/**\n * The `ColorSwatch` component shows a color as a small chip, named by its label or by the color itself.\n *\n * It's an image to assistive tech, so the color is always there in words.\n * In forced colors it keeps its color, edged in the system's text color.\n *\n * @function\n * @param {ColorSwatchProps} props - Props for the ColorSwatch component.\n * @param {React.Ref<HTMLSpanElement>} ref - Forwarded ref to the `<span>`.\n * @returns {JSX.Element} The rendered swatch.\n *\n * @example\n * <ColorSwatch color=\"#1e6b99\" label=\"Brand blue\" />\n */\nexport const ColorSwatch = forwardRef<HTMLSpanElement, ColorSwatchProps>(\n (\n {\n className,\n textColor,\n color,\n label,\n size,\n isRounded,\n children,\n style,\n ...props\n },\n ref\n ) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor,\n ...props,\n });\n\n const unnamed =\n /^\\s*var\\(/i.test(color) &&\n !label &&\n !rest['aria-label'] &&\n !rest['aria-labelledby'] &&\n !rest['aria-hidden'];\n useEffect(() => {\n if (unnamed) {\n warnOnce(\n 'ColorSwatch:unnamed-var',\n '[bestax-bulma] <ColorSwatch> shows a CSS variable with no label, ' +\n 'so a screen reader reads the var() as its name. Pass label, ' +\n 'such as \"Primary\".'\n );\n }\n }, [unnamed]);\n\n const swatchClass = usePrefixedClassNames('color-swatch', {\n [`is-${size}`]:\n !!size && (validColorSwatchSizes as readonly string[]).includes(size),\n 'is-rounded': !!isRounded,\n });\n\n return (\n <span\n ref={ref}\n className={classNames(swatchClass, bulmaHelperClasses, className)}\n style={{ ...style, ['--color-swatch-color' as string]: color }}\n {...rest}\n role=\"img\"\n aria-label={rest['aria-label'] || label || color}\n >\n {children !== undefined && children !== null && (\n <span aria-hidden=\"true\">{children}</span>\n )}\n </span>\n );\n }\n);\n\nColorSwatch.displayName = 'ColorSwatch';\n\nexport default ColorSwatch;\n"],"names":["_jsx"],"mappings":";;;;;;;AASA,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAU;AAyCnE;;;;;;;;;;;;;AAaG;AACI,MAAM,WAAW,GAAG,UAAU,CACnC,CACE,EACE,SAAS,EACT,SAAS,EACT,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EACD,GAAG,KACD;AACF,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACnD,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,GAAG,KAAK;AACT,KAAA,CAAC;AAEF,IAAA,MAAM,OAAO,GACX,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;AACxB,QAAA,CAAC,KAAK;QACN,CAAC,IAAI,CAAC,YAAY,CAAC;QACnB,CAAC,IAAI,CAAC,iBAAiB,CAAC;AACxB,QAAA,CAAC,IAAI,CAAC,aAAa,CAAC;IACtB,SAAS,CAAC,MAAK;QACb,IAAI,OAAO,EAAE;YACX,QAAQ,CACN,yBAAyB,EACzB,mEAAmE;gBACjE,8DAA8D;AAC9D,gBAAA,oBAAoB,CACvB;QACH;AACF,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAEb,IAAA,MAAM,WAAW,GAAG,qBAAqB,CAAC,cAAc,EAAE;AACxD,QAAA,CAAC,CAAA,GAAA,EAAM,IAAI,CAAA,CAAE,GACX,CAAC,CAAC,IAAI,IAAK,qBAA2C,CAAC,QAAQ,CAAC,IAAI,CAAC;QACvE,YAAY,EAAE,CAAC,CAAC,SAAS;AAC1B,KAAA,CAAC;AAEF,IAAA,QACEA,GAAA,CAAA,MAAA,EAAA,EACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,UAAU,CAAC,WAAW,EAAE,kBAAkB,EAAE,SAAS,CAAC,EACjE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,sBAAgC,GAAG,KAAK,EAAE,EAAA,GAC1D,IAAI,EACR,IAAI,EAAC,KAAK,EAAA,YAAA,EACE,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,IAAI,KAAK,EAAA,QAAA,EAE/C,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,KAC1CA,GAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAkB,MAAM,EAAA,QAAA,EAAE,QAAQ,EAAA,CAAQ,CAC3C,EAAA,CACI;AAEX,CAAC;AAGH,WAAW,CAAC,WAAW,GAAG,aAAa;;"}
@@ -20,7 +20,7 @@ const validRingProgressColors = [
20
20
  'white',
21
21
  ];
22
22
  const validRingProgressSizes = ['small', 'medium', 'large'];
23
- const clamp$2 = (value, low, high) => Math.min(Math.max(value, low), high);
23
+ const clamp$4 = (value, low, high) => Math.min(Math.max(value, low), high);
24
24
  /**
25
25
  * The `RingProgress` component draws a value as a ring that fills as it grows, with anything you pass shown in the middle.
26
26
  *
@@ -58,7 +58,7 @@ const RingProgress = forwardRef(({ className, textColor, bgColor, value, max = 1
58
58
  }
59
59
  }, [named, mixed]);
60
60
  const total = max > 0 ? max : 100;
61
- const share = (part) => (clamp$2(part, 0, total) / total) * 100;
61
+ const share = (part) => (clamp$4(part, 0, total) / total) * 100;
62
62
  // Each arc starts where the one before ended, and the last stops at the
63
63
  // top, so a total over max fills the ring and no more.
64
64
  const arcs = [];
@@ -104,7 +104,7 @@ const RingProgress = forwardRef(({ className, textColor, bgColor, value, max = 1
104
104
  }
105
105
  : {
106
106
  role: isMeter ? 'meter' : 'progressbar',
107
- 'aria-valuenow': clamp$2(value ?? 0, 0, total),
107
+ 'aria-valuenow': clamp$4(value ?? 0, 0, total),
108
108
  'aria-valuemin': 0,
109
109
  'aria-valuemax': total,
110
110
  'aria-label': label || rest['aria-label'],
@@ -39,17 +39,19 @@ const validTableColors = [
39
39
  /**
40
40
  * Td component for rendering a styled Bulma table cell.
41
41
  *
42
- * Supports alignment, Bulma color modifiers, and helper classes for additional styling.
42
+ * Supports alignment, narrow and vertically centered cells, Bulma color modifiers, and helper classes for additional styling.
43
43
  *
44
44
  * @function
45
45
  * @param {TdProps} props - Props for the Td component.
46
46
  * @returns {JSX.Element} The rendered table cell element.
47
47
  * @see {@link https://bulma.io/documentation/elements/table/#table-body | Bulma Table documentation}
48
48
  */
49
- const Td = ({ className, isAligned, color, children, ...props }) => {
49
+ const Td = ({ className, isAligned, isNarrow, isVcentered, color, children, ...props }) => {
50
50
  const bulmaClasses = usePrefixedClassNames('', {
51
51
  [`has-text-${isAligned}`]: isAligned && validTableAlignments.includes(isAligned),
52
52
  [`is-${color}`]: color && validTableColors.includes(color),
53
+ 'is-narrow': isNarrow,
54
+ 'is-vcentered': isVcentered,
53
55
  });
54
56
  /**
55
57
  * Generates Bulma helper classes and separates out remaining props.
@@ -1 +1 @@
1
- {"version":3,"file":"Td.js","sources":["../../../src/elements/Td.tsx"],"sourcesContent":["/**\n * @group Table\n */\nimport React from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { TableAlignment, validTableAlignments } from './tableAlignment';\n\n/**\n * The values the table `color` prop accepts, as a readonly tuple.\n *\n * `TableColor` is typed from it, and `Tr`, `Th` and `Td` all take a\n * `TableColor`, so the tuple and those props list the same values. Map over\n * it to build a color picker, or check a value that arrives at runtime before\n * passing it in: the components add no color class for a value outside the\n * tuple.\n *\n * @example\n * import { Tr, Td, validTableColors } from '@allxsmith/bestax-bulma';\n *\n * <Tr>\n * {validTableColors.map(color => (\n * <Td key={color} color={color}>\n * {color}\n * </Td>\n * ))}\n * </Tr>;\n */\nexport const validTableColors = [\n 'primary',\n 'link',\n 'info',\n 'success',\n 'warning',\n 'danger',\n 'black',\n 'dark',\n 'light',\n 'white',\n] as const;\n\n/**\n * The color values `Tr`, `Th` and `Td` accept, typed from `validTableColors`.\n */\nexport type TableColor = (typeof validTableColors)[number];\n\n/**\n * Props for the Td component.\n */\nexport interface TdProps\n extends\n Omit<React.TdHTMLAttributes<HTMLTableCellElement>, 'color'>,\n Omit<BulmaClassesProps, 'backgroundColor' | 'color'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /** Text alignment for the table cell ('left', 'right', 'centered'). */\n isAligned?: TableAlignment;\n /** Bulma color modifier for the table cell. */\n color?: TableColor;\n /** Table cell content. */\n children?: React.ReactNode;\n}\n\n/**\n * Td component for rendering a styled Bulma table cell.\n *\n * Supports alignment, Bulma color modifiers, and helper classes for additional styling.\n *\n * @function\n * @param {TdProps} props - Props for the Td component.\n * @returns {JSX.Element} The rendered table cell element.\n * @see {@link https://bulma.io/documentation/elements/table/#table-body | Bulma Table documentation}\n */\nexport const Td: React.FC<TdProps> = ({\n className,\n isAligned,\n color,\n children,\n ...props\n}) => {\n const bulmaClasses = usePrefixedClassNames('', {\n [`has-text-${isAligned}`]:\n isAligned && validTableAlignments.includes(isAligned),\n [`is-${color}`]: color && validTableColors.includes(color),\n });\n\n /**\n * Generates Bulma helper classes and separates out remaining props.\n */\n const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });\n\n const tdClasses = classNames(bulmaClasses, className, bulmaHelperClasses);\n\n return (\n <td className={tdClasses || undefined} {...rest}>\n {children}\n </td>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAQA;;;;;;;;;;;;;;;;;;;AAmBG;AACI,MAAM,gBAAgB,GAAG;IAC9B,SAAS;IACT,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAAS;IACT,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;;AAyBT;;;;;;;;;AASG;AACI,MAAM,EAAE,GAAsB,CAAC,EACpC,SAAS,EACT,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAC7C,QAAA,CAAC,CAAA,SAAA,EAAY,SAAS,CAAA,CAAE,GACtB,SAAS,IAAI,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC;AACvD,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC3D,KAAA,CAAC;AAEF;;AAEG;AACH,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElE,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC;AAEzE,IAAA,QACEA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,SAAS,IAAI,SAAS,EAAA,GAAM,IAAI,EAAA,QAAA,EAC5C,QAAQ,EAAA,CACN;AAET;;"}
1
+ {"version":3,"file":"Td.js","sources":["../../../src/elements/Td.tsx"],"sourcesContent":["/**\n * @group Table\n */\nimport React from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { TableAlignment, validTableAlignments } from './tableAlignment';\n\n/**\n * The values the table `color` prop accepts, as a readonly tuple.\n *\n * `TableColor` is typed from it, and `Tr`, `Th` and `Td` all take a\n * `TableColor`, so the tuple and those props list the same values. Map over\n * it to build a color picker, or check a value that arrives at runtime before\n * passing it in: the components add no color class for a value outside the\n * tuple.\n *\n * @example\n * import { Tr, Td, validTableColors } from '@allxsmith/bestax-bulma';\n *\n * <Tr>\n * {validTableColors.map(color => (\n * <Td key={color} color={color}>\n * {color}\n * </Td>\n * ))}\n * </Tr>;\n */\nexport const validTableColors = [\n 'primary',\n 'link',\n 'info',\n 'success',\n 'warning',\n 'danger',\n 'black',\n 'dark',\n 'light',\n 'white',\n] as const;\n\n/**\n * The color values `Tr`, `Th` and `Td` accept, typed from `validTableColors`.\n */\nexport type TableColor = (typeof validTableColors)[number];\n\n/**\n * Props for the Td component.\n */\nexport interface TdProps\n extends\n Omit<React.TdHTMLAttributes<HTMLTableCellElement>, 'color'>,\n Omit<BulmaClassesProps, 'backgroundColor' | 'color'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /** Text alignment for the table cell ('left', 'right', 'centered'). */\n isAligned?: TableAlignment;\n /**\n * Shrinks the cell to its content and keeps that on one line (Bulma's\n * `is-narrow`), as for a column of checkboxes or actions. Not the table's\n * own `isNarrow`, which tightens every cell's padding.\n */\n isNarrow?: boolean;\n /** Centers the content vertically (Bulma's `is-vcentered`). Cells sit at the top otherwise. */\n isVcentered?: boolean;\n /** Bulma color modifier for the table cell. */\n color?: TableColor;\n /** Table cell content. */\n children?: React.ReactNode;\n}\n\n/**\n * Td component for rendering a styled Bulma table cell.\n *\n * Supports alignment, narrow and vertically centered cells, Bulma color modifiers, and helper classes for additional styling.\n *\n * @function\n * @param {TdProps} props - Props for the Td component.\n * @returns {JSX.Element} The rendered table cell element.\n * @see {@link https://bulma.io/documentation/elements/table/#table-body | Bulma Table documentation}\n */\nexport const Td: React.FC<TdProps> = ({\n className,\n isAligned,\n isNarrow,\n isVcentered,\n color,\n children,\n ...props\n}) => {\n const bulmaClasses = usePrefixedClassNames('', {\n [`has-text-${isAligned}`]:\n isAligned && validTableAlignments.includes(isAligned),\n [`is-${color}`]: color && validTableColors.includes(color),\n 'is-narrow': isNarrow,\n 'is-vcentered': isVcentered,\n });\n\n /**\n * Generates Bulma helper classes and separates out remaining props.\n */\n const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });\n\n const tdClasses = classNames(bulmaClasses, className, bulmaHelperClasses);\n\n return (\n <td className={tdClasses || undefined} {...rest}>\n {children}\n </td>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAQA;;;;;;;;;;;;;;;;;;;AAmBG;AACI,MAAM,gBAAgB,GAAG;IAC9B,SAAS;IACT,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAAS;IACT,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;;AAiCT;;;;;;;;;AASG;MACU,EAAE,GAAsB,CAAC,EACpC,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAC7C,QAAA,CAAC,CAAA,SAAA,EAAY,SAAS,CAAA,CAAE,GACtB,SAAS,IAAI,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC;AACvD,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC1D,QAAA,WAAW,EAAE,QAAQ;AACrB,QAAA,cAAc,EAAE,WAAW;AAC5B,KAAA,CAAC;AAEF;;AAEG;AACH,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElE,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC;AAEzE,IAAA,QACEA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,SAAS,IAAI,SAAS,EAAA,GAAM,IAAI,EAAA,QAAA,EAC5C,QAAQ,EAAA,CACN;AAET;;"}
@@ -8,26 +8,34 @@ import { validTableAlignments } from './tableAlignment.js';
8
8
  /**
9
9
  * Th component for rendering a styled Bulma table header cell.
10
10
  *
11
- * Supports alignment, width, and color modifiers.
11
+ * Supports alignment, width, narrow and vertically centered cells, and color modifiers.
12
12
  *
13
13
  * @function
14
14
  * @param {ThProps} props - Props for the Th component.
15
15
  * @returns {JSX.Element} The rendered table header cell element.
16
16
  * @see {@link https://bulma.io/documentation/elements/table/#table-head | Bulma Table documentation}
17
17
  */
18
- const Th = ({ className, isAligned, width, color, children, ...props }) => {
18
+ const Th = ({ className, isAligned, isNarrow, isVcentered, width, color, style, children, ...props }) => {
19
19
  const bulmaClasses = usePrefixedClassNames('', {
20
20
  [`has-text-${isAligned}`]: isAligned && validTableAlignments.includes(isAligned),
21
21
  [`is-${color}`]: color && validTableColors.includes(color),
22
+ 'is-narrow': isNarrow,
23
+ 'is-vcentered': isVcentered,
22
24
  });
23
25
  /**
24
26
  * Generates Bulma helper classes and separates out remaining props.
25
27
  */
26
28
  const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });
27
29
  const thClasses = classNames(bulmaClasses, className, bulmaHelperClasses);
28
- return (jsx("th", { className: thClasses || undefined, style: width
29
- ? { width: typeof width === 'number' ? `${width}px` : width }
30
- : undefined, ...rest, children: children }));
30
+ return (jsx("th", { className: thClasses || undefined, style:
31
+ // A `width` key the style leaves undefined isn't a width, so the
32
+ // prop's stays.
33
+ width && style?.width === undefined
34
+ ? {
35
+ ...style,
36
+ width: typeof width === 'number' ? `${width}px` : width,
37
+ }
38
+ : style, ...rest, children: children }));
31
39
  };
32
40
 
33
41
  export { Th };
@@ -1 +1 @@
1
- {"version":3,"file":"Th.js","sources":["../../../src/elements/Th.tsx"],"sourcesContent":["/**\n * @group Table\n */\nimport React from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { TableColor, validTableColors } from './Td';\nimport { TableAlignment, validTableAlignments } from './tableAlignment';\n\n/**\n * Props for the Th component.\n */\nexport interface ThProps\n extends\n Omit<React.ThHTMLAttributes<HTMLTableCellElement>, 'color'>,\n Omit<BulmaClassesProps, 'backgroundColor' | 'color'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /** Text alignment for the header cell ('left', 'right', 'centered'). */\n isAligned?: TableAlignment;\n /** Width of the header cell (e.g., '100px' or 100). */\n width?: string | number;\n /** Bulma color modifier for the header cell. */\n color?: TableColor;\n /** Table header cell content. */\n children?: React.ReactNode;\n}\n\n/**\n * Th component for rendering a styled Bulma table header cell.\n *\n * Supports alignment, width, and color modifiers.\n *\n * @function\n * @param {ThProps} props - Props for the Th component.\n * @returns {JSX.Element} The rendered table header cell element.\n * @see {@link https://bulma.io/documentation/elements/table/#table-head | Bulma Table documentation}\n */\nexport const Th: React.FC<ThProps> = ({\n className,\n isAligned,\n width,\n color,\n children,\n ...props\n}) => {\n const bulmaClasses = usePrefixedClassNames('', {\n [`has-text-${isAligned}`]:\n isAligned && validTableAlignments.includes(isAligned),\n [`is-${color}`]: color && validTableColors.includes(color),\n });\n\n /**\n * Generates Bulma helper classes and separates out remaining props.\n */\n const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });\n\n const thClasses = classNames(bulmaClasses, className, bulmaHelperClasses);\n\n return (\n <th\n className={thClasses || undefined}\n style={\n width\n ? { width: typeof width === 'number' ? `${width}px` : width }\n : undefined\n }\n {...rest}\n >\n {children}\n </th>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;AA4BA;;;;;;;;;AASG;MACU,EAAE,GAAsB,CAAC,EACpC,SAAS,EACT,SAAS,EACT,KAAK,EACL,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAC7C,QAAA,CAAC,CAAA,SAAA,EAAY,SAAS,CAAA,CAAE,GACtB,SAAS,IAAI,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC;AACvD,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC3D,KAAA,CAAC;AAEF;;AAEG;AACH,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElE,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC;IAEzE,QACEA,GAAA,CAAA,IAAA,EAAA,EACE,SAAS,EAAE,SAAS,IAAI,SAAS,EACjC,KAAK,EACH;AACE,cAAE,EAAE,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,GAAG,GAAG,KAAK,CAAA,EAAA,CAAI,GAAG,KAAK;cACzD,SAAS,EAAA,GAEX,IAAI,YAEP,QAAQ,EAAA,CACN;AAET;;"}
1
+ {"version":3,"file":"Th.js","sources":["../../../src/elements/Th.tsx"],"sourcesContent":["/**\n * @group Table\n */\nimport React from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { TableColor, validTableColors } from './Td';\nimport { TableAlignment, validTableAlignments } from './tableAlignment';\n\n/**\n * Props for the Th component.\n */\nexport interface ThProps\n extends\n Omit<React.ThHTMLAttributes<HTMLTableCellElement>, 'color'>,\n Omit<BulmaClassesProps, 'backgroundColor' | 'color'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /** Text alignment for the header cell ('left', 'right', 'centered'). */\n isAligned?: TableAlignment;\n /**\n * Shrinks the cell to its content and keeps that on one line (Bulma's\n * `is-narrow`), as for a column of checkboxes or actions. Not the table's\n * own `isNarrow`, which tightens every cell's padding.\n */\n isNarrow?: boolean;\n /** Centers the content vertically (Bulma's `is-vcentered`). Cells sit at the top otherwise. */\n isVcentered?: boolean;\n /**\n * Width of the header cell (e.g., '100px' or 100), written into its\n * `style`. A `style` passed as well keeps it, and a `width` that `style`\n * sets wins.\n */\n width?: string | number;\n /** Bulma color modifier for the header cell. */\n color?: TableColor;\n /** Table header cell content. */\n children?: React.ReactNode;\n}\n\n/**\n * Th component for rendering a styled Bulma table header cell.\n *\n * Supports alignment, width, narrow and vertically centered cells, and color modifiers.\n *\n * @function\n * @param {ThProps} props - Props for the Th component.\n * @returns {JSX.Element} The rendered table header cell element.\n * @see {@link https://bulma.io/documentation/elements/table/#table-head | Bulma Table documentation}\n */\nexport const Th: React.FC<ThProps> = ({\n className,\n isAligned,\n isNarrow,\n isVcentered,\n width,\n color,\n style,\n children,\n ...props\n}) => {\n const bulmaClasses = usePrefixedClassNames('', {\n [`has-text-${isAligned}`]:\n isAligned && validTableAlignments.includes(isAligned),\n [`is-${color}`]: color && validTableColors.includes(color),\n 'is-narrow': isNarrow,\n 'is-vcentered': isVcentered,\n });\n\n /**\n * Generates Bulma helper classes and separates out remaining props.\n */\n const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });\n\n const thClasses = classNames(bulmaClasses, className, bulmaHelperClasses);\n\n return (\n <th\n className={thClasses || undefined}\n style={\n // A `width` key the style leaves undefined isn't a width, so the\n // prop's stays.\n width && style?.width === undefined\n ? {\n ...style,\n width: typeof width === 'number' ? `${width}px` : width,\n }\n : style\n }\n {...rest}\n >\n {children}\n </th>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;AAwCA;;;;;;;;;AASG;AACI,MAAM,EAAE,GAAsB,CAAC,EACpC,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,KAAK,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAC7C,QAAA,CAAC,CAAA,SAAA,EAAY,SAAS,CAAA,CAAE,GACtB,SAAS,IAAI,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC;AACvD,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC1D,QAAA,WAAW,EAAE,QAAQ;AACrB,QAAA,cAAc,EAAE,WAAW;AAC5B,KAAA,CAAC;AAEF;;AAEG;AACH,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElE,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC;IAEzE,QACEA,YACE,SAAS,EAAE,SAAS,IAAI,SAAS,EACjC,KAAK;;;AAGH,QAAA,KAAK,IAAI,KAAK,EAAE,KAAK,KAAK;AACxB,cAAE;AACE,gBAAA,GAAG,KAAK;AACR,gBAAA,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,GAAG,CAAA,EAAG,KAAK,CAAA,EAAA,CAAI,GAAG,KAAK;AACxD;cACD,KAAK,EAAA,GAEP,IAAI,YAEP,QAAQ,EAAA,CACN;AAET;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tr.js","sources":["../../../src/elements/Tr.tsx"],"sourcesContent":["/**\n * @group Table\n */\nimport React from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { TableColor, validTableColors } from './Td'; // Import TableColor from Td\n\n/**\n * Props for the Tr component.\n */\nexport interface TrProps\n extends\n Omit<React.HTMLAttributes<HTMLTableRowElement>, 'color'>,\n Omit<BulmaClassesProps, 'backgroundColor' | 'color'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /** Whether the row is selected (adds Bulma's is-selected class). */\n isSelected?: boolean;\n /** Bulma color modifier for the table row. */\n color?: TableColor;\n /** Table row content (cells). */\n children?: React.ReactNode;\n}\n\n/**\n * Tr component for rendering a styled Bulma table row.\n *\n * Supports the is-selected modifier and color modifiers.\n *\n * @function\n * @param {TrProps} props - Props for the Tr component.\n * @returns {JSX.Element} The rendered table row element.\n * @see {@link https://bulma.io/documentation/elements/table/#table-row | Bulma Table documentation}\n */\nexport const Tr: React.FC<TrProps> = ({\n className,\n isSelected,\n color,\n children,\n ...props\n}) => {\n const bulmaClasses = usePrefixedClassNames('', {\n 'is-selected': isSelected,\n [`is-${color}`]: color && validTableColors.includes(color),\n });\n\n /**\n * Generates Bulma helper classes and separates out remaining props.\n */\n const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });\n\n const trClasses = classNames(bulmaClasses, className, bulmaHelperClasses);\n\n return (\n <tr className={trClasses || undefined} {...rest}>\n {children}\n </tr>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAyBA;;;;;;;;;AASG;AACI,MAAM,EAAE,GAAsB,CAAC,EACpC,SAAS,EACT,UAAU,EACV,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAC7C,QAAA,aAAa,EAAE,UAAU;AACzB,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC3D,KAAA,CAAC;AAEF;;AAEG;AACH,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElE,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC;AAEzE,IAAA,QACEA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,SAAS,IAAI,SAAS,EAAA,GAAM,IAAI,EAAA,QAAA,EAC5C,QAAQ,EAAA,CACN;AAET;;"}
1
+ {"version":3,"file":"Tr.js","sources":["../../../src/elements/Tr.tsx"],"sourcesContent":["/**\n * @group Table\n */\nimport React from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { TableColor, validTableColors } from './Td'; // Import TableColor from Td\n\n/**\n * Props for the Tr component.\n */\nexport interface TrProps\n extends\n Omit<React.HTMLAttributes<HTMLTableRowElement>, 'color'>,\n Omit<BulmaClassesProps, 'backgroundColor' | 'color'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /**\n * Whether the row is selected (adds Bulma's is-selected class). It's a look\n * only: it says nothing to assistive tech, so pair it with a checkbox named\n * for the row when the selection matters. A bestax `Checkbox` placed\n * straight in one of the row's cells takes the row's text color, so a\n * checked box shows on the row's fill. One in a menu or a table nested in a\n * cell, or in a cell with a `color` of its own, keeps its own colors, since\n * it sits on that surface instead, and so does every one in a row with a\n * `color`, whose cells paint that color over the fill.\n */\n isSelected?: boolean;\n /** Bulma color modifier for the table row. */\n color?: TableColor;\n /** Table row content (cells). */\n children?: React.ReactNode;\n}\n\n/**\n * Tr component for rendering a styled Bulma table row.\n *\n * Supports the is-selected modifier and color modifiers.\n *\n * @function\n * @param {TrProps} props - Props for the Tr component.\n * @returns {JSX.Element} The rendered table row element.\n * @see {@link https://bulma.io/documentation/elements/table/#table-row | Bulma Table documentation}\n */\nexport const Tr: React.FC<TrProps> = ({\n className,\n isSelected,\n color,\n children,\n ...props\n}) => {\n const bulmaClasses = usePrefixedClassNames('', {\n 'is-selected': isSelected,\n [`is-${color}`]: color && validTableColors.includes(color),\n });\n\n /**\n * Generates Bulma helper classes and separates out remaining props.\n */\n const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });\n\n const trClasses = classNames(bulmaClasses, className, bulmaHelperClasses);\n\n return (\n <tr className={trClasses || undefined} {...rest}>\n {children}\n </tr>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAkCA;;;;;;;;;AASG;AACI,MAAM,EAAE,GAAsB,CAAC,EACpC,SAAS,EACT,UAAU,EACV,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,KAAI;AACH,IAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAC7C,QAAA,aAAa,EAAE,UAAU;AACzB,QAAA,CAAC,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,GAAG,KAAK,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC3D,KAAA,CAAC;AAEF;;AAEG;AACH,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElE,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC;AAEzE,IAAA,QACEA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,SAAS,IAAI,SAAS,EAAA,GAAM,IAAI,EAAA,QAAA,EAC5C,QAAQ,EAAA,CACN;AAET;;"}