jaci-ui 1.0.0 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 3bd3028: Override package versions with high severity vulnerabilities
8
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 58c4e2c: Fix semantic tokens for dark theme
14
+ - 52c2715: Update packages
15
+
3
16
  ## 1.0.0
4
17
 
5
18
  ### Major Changes
@@ -76,9 +76,11 @@ function rgbToHsl(red, green, blue, alpha = 1) {
76
76
  let hue = 0;
77
77
  const lightness = (max + min) / 2;
78
78
  const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));
79
- if (delta !== 0) if (max === r) hue = 60 * ((g - b) / delta % 6);
80
- else if (max === g) hue = 60 * ((b - r) / delta + 2);
81
- else hue = 60 * ((r - g) / delta + 4);
79
+ if (delta !== 0) {
80
+ if (max === r) hue = 60 * ((g - b) / delta % 6);
81
+ else if (max === g) hue = 60 * ((b - r) / delta + 2);
82
+ else hue = 60 * ((r - g) / delta + 4);
83
+ }
82
84
  return {
83
85
  alpha: clamp(alpha, 0, 1),
84
86
  hue: (hue + 360) % 360,
@@ -1 +1 @@
1
- {"version":3,"file":"color-utils.cjs","names":[],"sources":["../../../src/components/color-picker/color-utils.ts"],"sourcesContent":["export type ColorFormat = \"hex\" | \"rgb\" | \"hsl\";\n\nexport interface ColorModel {\n alpha: number;\n hue: number;\n lightness: number;\n saturation: number;\n}\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\nfunction parseNumber(value: string, min: number, max: number) {\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) ? clamp(parsed, min, max) : null;\n}\n\nfunction parseAlpha(value: string | undefined) {\n if (value === undefined) return 1;\n if (value.trim().endsWith(\"%\")) {\n return parseNumber(value, 0, 100) === null\n ? null\n : (parseNumber(value, 0, 100) as number) / 100;\n }\n return parseNumber(value, 0, 1);\n}\n\nfunction parseHex(value: string): ColorModel | null {\n const hex = value.slice(1);\n if (![3, 4, 6, 8].includes(hex.length) || !/^[\\da-f]+$/i.test(hex)) return null;\n const expanded =\n hex.length <= 4\n ? hex\n .split(\"\")\n .map((part) => `${part}${part}`)\n .join(\"\")\n : hex;\n const red = Number.parseInt(expanded.slice(0, 2), 16) / 255;\n const green = Number.parseInt(expanded.slice(2, 4), 16) / 255;\n const blue = Number.parseInt(expanded.slice(4, 6), 16) / 255;\n const alpha = expanded.length === 8 ? Number.parseInt(expanded.slice(6, 8), 16) / 255 : 1;\n return rgbToHsl(red * 255, green * 255, blue * 255, alpha);\n}\n\nfunction parseRgb(value: string): ColorModel | null {\n const match = value.match(\n /^rgba?\\(\\s*([^,\\s]+)[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n\n const redValue = match[1];\n const greenValue = match[2];\n const blueValue = match[3];\n if (!redValue || !greenValue || !blueValue) return null;\n const channels = [redValue, greenValue, blueValue].map((channel) => {\n if (channel.endsWith(\"%\")) {\n const percentage = parseNumber(channel, 0, 100);\n return percentage === null ? null : (percentage / 100) * 255;\n }\n return parseNumber(channel, 0, 255);\n });\n const alpha = parseAlpha(match[4]);\n if (channels.some((channel) => channel === null) || alpha === null) return null;\n return rgbToHsl(channels[0] as number, channels[1] as number, channels[2] as number, alpha);\n}\n\nfunction parseHsl(value: string): ColorModel | null {\n const match = value.match(\n /^hsla?\\(\\s*([^,\\s]+)(?:deg)?[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n const hueValue = match[1];\n const saturationValue = match[2];\n const lightnessValue = match[3];\n if (!hueValue || !saturationValue || !lightnessValue) return null;\n const hue = parseNumber(hueValue.replace(/deg$/i, \"\"), -360, 360);\n const saturation = parseNumber(saturationValue, 0, 100);\n const lightness = parseNumber(lightnessValue, 0, 100);\n const alpha = parseAlpha(match[4]);\n if (hue === null || saturation === null || lightness === null || alpha === null) return null;\n if (!saturationValue.endsWith(\"%\") || !lightnessValue.endsWith(\"%\")) return null;\n return { alpha, hue: (hue + 360) % 360, lightness, saturation };\n}\n\nfunction rgbToHsl(red: number, green: number, blue: number, alpha = 1): ColorModel {\n const r = red / 255;\n const g = green / 255;\n const b = blue / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const delta = max - min;\n let hue = 0;\n const lightness = (max + min) / 2;\n const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));\n\n if (delta !== 0) {\n if (max === r) hue = 60 * (((g - b) / delta) % 6);\n else if (max === g) hue = 60 * ((b - r) / delta + 2);\n else hue = 60 * ((r - g) / delta + 4);\n }\n\n return {\n alpha: clamp(alpha, 0, 1),\n hue: (hue + 360) % 360,\n lightness: lightness * 100,\n saturation: saturation * 100,\n };\n}\n\nfunction hslToRgb({ hue, lightness, saturation }: ColorModel) {\n const h = hue / 360;\n const s = saturation / 100;\n const l = lightness / 100;\n const chroma = (1 - Math.abs(2 * l - 1)) * s;\n const segment = h * 6;\n const x = chroma * (1 - Math.abs((segment % 2) - 1));\n const [r, g, b] =\n segment < 1\n ? [chroma, x, 0]\n : segment < 2\n ? [x, chroma, 0]\n : segment < 3\n ? [0, chroma, x]\n : segment < 4\n ? [0, x, chroma]\n : segment < 5\n ? [x, 0, chroma]\n : [chroma, 0, x];\n const match = l - chroma / 2;\n return {\n blue: Math.round((b + match) * 255),\n green: Math.round((g + match) * 255),\n red: Math.round((r + match) * 255),\n };\n}\n\nexport function parseColor(value: string | undefined): ColorModel | null {\n if (!value) return null;\n const normalized = value.trim();\n if (normalized.startsWith(\"#\")) return parseHex(normalized);\n if (/^rgba?/i.test(normalized)) return parseRgb(normalized);\n if (/^hsla?/i.test(normalized)) return parseHsl(normalized);\n return null;\n}\n\nfunction formatAlpha(alpha: number) {\n return Number(alpha.toFixed(3)).toString();\n}\n\nexport function formatColor(color: ColorModel, format: ColorFormat, showAlpha = false) {\n const rgb = hslToRgb(color);\n if (format === \"hex\") {\n const base = [rgb.red, rgb.green, rgb.blue]\n .map((channel) => channel.toString(16).padStart(2, \"0\"))\n .join(\"\");\n return `#${base}${\n showAlpha\n ? Math.round(color.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n : \"\"\n }`;\n }\n if (format === \"rgb\") {\n return showAlpha\n ? `rgba(${rgb.red}, ${rgb.green}, ${rgb.blue}, ${formatAlpha(color.alpha)})`\n : `rgb(${rgb.red}, ${rgb.green}, ${rgb.blue})`;\n }\n return showAlpha\n ? `hsla(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)}%, ${formatAlpha(color.alpha)})`\n : `hsl(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)}%)`;\n}\n\nexport function defaultColor(value?: string) {\n return parseColor(value) ?? { alpha: 1, hue: 0, lightness: 0, saturation: 0 };\n}\n"],"mappings":";AASA,MAAM,SAAS,OAAe,KAAa,QAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAE7F,SAAS,YAAY,OAAe,KAAa,KAAa;CAC5D,MAAM,SAAS,OAAO,WAAW,KAAK;CACtC,OAAO,OAAO,SAAS,MAAM,IAAI,MAAM,QAAQ,KAAK,GAAG,IAAI;AAC7D;AAEA,SAAS,WAAW,OAA2B;CAC7C,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,GAC3B,OAAO,YAAY,OAAO,GAAG,GAAG,MAAM,OAClC,OACC,YAAY,OAAO,GAAG,GAAG,IAAe;CAE/C,OAAO,YAAY,OAAO,GAAG,CAAC;AAChC;AAEA,SAAS,SAAS,OAAkC;CACl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B,QAAqB,YAAY,OAAO;CACrF,MAAM,MAAM,SAAS,KAAK;CAC1B,IAAI,WAAW,OAIb,OAAO,IAHM;EAAC,IAAI;EAAK,IAAI;EAAO,IAAI;CAAI,CAAC,CACxC,KAAK,YAAY,QAAQ,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CACvD,KAAK,EACM,IACZ,YACI,KAAK,MAAM,MAAM,QAAQ,GAAG,CAAC,CAC1B,SAAS,EAAE,CAAC,CACZ,SAAS,GAAG,GAAG,IAClB;CAGR,IAAI,WAAW,OACb,OAAO,YACH,QAAQ,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK,IAAI,YAAY,MAAM,KAAK,EAAE,KACxE,OAAO,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK;CAEhD,OAAO,YACH,QAAQ,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE,KAAK,KAAK,MAAM,MAAM,SAAS,EAAE,KAAK,YAAY,MAAM,KAAK,EAAE,KAC9H,OAAO,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE,KAAK,KAAK,MAAM,MAAM,SAAS,EAAE;AACrG;AAEA,SAAgB,aAAa,OAAgB;CAC3C,OAAO,WAAW,KAAK,KAAK;EAAE,OAAO;EAAG,KAAK;EAAG,WAAW;EAAG,YAAY;CAAE;AAC9E"}
1
+ {"version":3,"file":"color-utils.cjs","names":[],"sources":["../../../src/components/color-picker/color-utils.ts"],"sourcesContent":["export type ColorFormat = \"hex\" | \"rgb\" | \"hsl\";\n\nexport interface ColorModel {\n alpha: number;\n hue: number;\n lightness: number;\n saturation: number;\n}\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\nfunction parseNumber(value: string, min: number, max: number) {\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) ? clamp(parsed, min, max) : null;\n}\n\nfunction parseAlpha(value: string | undefined) {\n if (value === undefined) return 1;\n if (value.trim().endsWith(\"%\")) {\n return parseNumber(value, 0, 100) === null\n ? null\n : (parseNumber(value, 0, 100) as number) / 100;\n }\n return parseNumber(value, 0, 1);\n}\n\nfunction parseHex(value: string): ColorModel | null {\n const hex = value.slice(1);\n if (![3, 4, 6, 8].includes(hex.length) || !/^[\\da-f]+$/i.test(hex)) return null;\n const expanded =\n hex.length <= 4\n ? hex\n .split(\"\")\n .map((part) => `${part}${part}`)\n .join(\"\")\n : hex;\n const red = Number.parseInt(expanded.slice(0, 2), 16) / 255;\n const green = Number.parseInt(expanded.slice(2, 4), 16) / 255;\n const blue = Number.parseInt(expanded.slice(4, 6), 16) / 255;\n const alpha = expanded.length === 8 ? Number.parseInt(expanded.slice(6, 8), 16) / 255 : 1;\n return rgbToHsl(red * 255, green * 255, blue * 255, alpha);\n}\n\nfunction parseRgb(value: string): ColorModel | null {\n const match = value.match(\n /^rgba?\\(\\s*([^,\\s]+)[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n\n const redValue = match[1];\n const greenValue = match[2];\n const blueValue = match[3];\n if (!redValue || !greenValue || !blueValue) return null;\n const channels = [redValue, greenValue, blueValue].map((channel) => {\n if (channel.endsWith(\"%\")) {\n const percentage = parseNumber(channel, 0, 100);\n return percentage === null ? null : (percentage / 100) * 255;\n }\n return parseNumber(channel, 0, 255);\n });\n const alpha = parseAlpha(match[4]);\n if (channels.some((channel) => channel === null) || alpha === null) return null;\n return rgbToHsl(channels[0] as number, channels[1] as number, channels[2] as number, alpha);\n}\n\nfunction parseHsl(value: string): ColorModel | null {\n const match = value.match(\n /^hsla?\\(\\s*([^,\\s]+)(?:deg)?[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n const hueValue = match[1];\n const saturationValue = match[2];\n const lightnessValue = match[3];\n if (!hueValue || !saturationValue || !lightnessValue) return null;\n const hue = parseNumber(hueValue.replace(/deg$/i, \"\"), -360, 360);\n const saturation = parseNumber(saturationValue, 0, 100);\n const lightness = parseNumber(lightnessValue, 0, 100);\n const alpha = parseAlpha(match[4]);\n if (hue === null || saturation === null || lightness === null || alpha === null) return null;\n if (!saturationValue.endsWith(\"%\") || !lightnessValue.endsWith(\"%\")) return null;\n return { alpha, hue: (hue + 360) % 360, lightness, saturation };\n}\n\nfunction rgbToHsl(red: number, green: number, blue: number, alpha = 1): ColorModel {\n const r = red / 255;\n const g = green / 255;\n const b = blue / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const delta = max - min;\n let hue = 0;\n const lightness = (max + min) / 2;\n const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));\n\n if (delta !== 0) {\n if (max === r) hue = 60 * (((g - b) / delta) % 6);\n else if (max === g) hue = 60 * ((b - r) / delta + 2);\n else hue = 60 * ((r - g) / delta + 4);\n }\n\n return {\n alpha: clamp(alpha, 0, 1),\n hue: (hue + 360) % 360,\n lightness: lightness * 100,\n saturation: saturation * 100,\n };\n}\n\nfunction hslToRgb({ hue, lightness, saturation }: ColorModel) {\n const h = hue / 360;\n const s = saturation / 100;\n const l = lightness / 100;\n const chroma = (1 - Math.abs(2 * l - 1)) * s;\n const segment = h * 6;\n const x = chroma * (1 - Math.abs((segment % 2) - 1));\n const [r, g, b] =\n segment < 1\n ? [chroma, x, 0]\n : segment < 2\n ? [x, chroma, 0]\n : segment < 3\n ? [0, chroma, x]\n : segment < 4\n ? [0, x, chroma]\n : segment < 5\n ? [x, 0, chroma]\n : [chroma, 0, x];\n const match = l - chroma / 2;\n return {\n blue: Math.round((b + match) * 255),\n green: Math.round((g + match) * 255),\n red: Math.round((r + match) * 255),\n };\n}\n\nexport function parseColor(value: string | undefined): ColorModel | null {\n if (!value) return null;\n const normalized = value.trim();\n if (normalized.startsWith(\"#\")) return parseHex(normalized);\n if (/^rgba?/i.test(normalized)) return parseRgb(normalized);\n if (/^hsla?/i.test(normalized)) return parseHsl(normalized);\n return null;\n}\n\nfunction formatAlpha(alpha: number) {\n return Number(alpha.toFixed(3)).toString();\n}\n\nexport function formatColor(color: ColorModel, format: ColorFormat, showAlpha = false) {\n const rgb = hslToRgb(color);\n if (format === \"hex\") {\n const base = [rgb.red, rgb.green, rgb.blue]\n .map((channel) => channel.toString(16).padStart(2, \"0\"))\n .join(\"\");\n return `#${base}${\n showAlpha\n ? Math.round(color.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n : \"\"\n }`;\n }\n if (format === \"rgb\") {\n return showAlpha\n ? `rgba(${rgb.red}, ${rgb.green}, ${rgb.blue}, ${formatAlpha(color.alpha)})`\n : `rgb(${rgb.red}, ${rgb.green}, ${rgb.blue})`;\n }\n return showAlpha\n ? `hsla(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)}%, ${formatAlpha(color.alpha)})`\n : `hsl(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)}%)`;\n}\n\nexport function defaultColor(value?: string) {\n return parseColor(value) ?? { alpha: 1, hue: 0, lightness: 0, saturation: 0 };\n}\n"],"mappings":";AASA,MAAM,SAAS,OAAe,KAAa,QAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAE7F,SAAS,YAAY,OAAe,KAAa,KAAa;CAC5D,MAAM,SAAS,OAAO,WAAW,KAAK;CACtC,OAAO,OAAO,SAAS,MAAM,IAAI,MAAM,QAAQ,KAAK,GAAG,IAAI;AAC7D;AAEA,SAAS,WAAW,OAA2B;CAC7C,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,GAC3B,OAAO,YAAY,OAAO,GAAG,GAAG,MAAM,OAClC,OACC,YAAY,OAAO,GAAG,GAAG,IAAe;CAE/C,OA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AM,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;AAC3C;AAEA,SAAgB,YAAY,OAAmB,QAAqB,YAAY,OAAO;CACrF,MAAM,MAAM,SAAS,KAAK;CAC1B,IAAI,WAAW,OAIb,OAAO,IAHM;EAAC,IAAI;EAAK,IAAI;EAAO,IAAI;CAAI,CAAC,CACxC,KAAK,YAAY,QAAQ,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CACvD,KAAK,EACM,IACZ,YACI,KAAK,MAAM,MAAM,QAAQ,GAAG,CAAC,CAC1B,SAAS,EAAE,CAAC,CACZ,SAAS,GAAG,GAAG,IAClB;CAGR,IAAI,WAAW,OACb,OAAO,YACH,QAAQ,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK,IAAI,YAAY,MAAM,KAAK,EAAE,KACxE,OAAO,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK;CAEhD,OAAO,YACH,QAAQ,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE,KAAK,KAAK,MAAM,MAAM,SAAS,EAAE,KAAK,YAAY,MAAM,KAAK,EAAE,KAC9H,OAAO,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE,KAAK,KAAK,MAAM,MAAM,SAAS,EAAE;AACrG;AAEA,SAAgB,aAAa,OAAgB;CAC3C,OAAO,WAAW,KAAK,KAAK;EAAE,OAAO;EAAG,KAAK;EAAG,WAAW;EAAG,YAAY;CAAE;AAC9E"}
@@ -76,9 +76,11 @@ function rgbToHsl(red, green, blue, alpha = 1) {
76
76
  let hue = 0;
77
77
  const lightness = (max + min) / 2;
78
78
  const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));
79
- if (delta !== 0) if (max === r) hue = 60 * ((g - b) / delta % 6);
80
- else if (max === g) hue = 60 * ((b - r) / delta + 2);
81
- else hue = 60 * ((r - g) / delta + 4);
79
+ if (delta !== 0) {
80
+ if (max === r) hue = 60 * ((g - b) / delta % 6);
81
+ else if (max === g) hue = 60 * ((b - r) / delta + 2);
82
+ else hue = 60 * ((r - g) / delta + 4);
83
+ }
82
84
  return {
83
85
  alpha: clamp(alpha, 0, 1),
84
86
  hue: (hue + 360) % 360,
@@ -1 +1 @@
1
- {"version":3,"file":"color-utils.js","names":[],"sources":["../../../src/components/color-picker/color-utils.ts"],"sourcesContent":["export type ColorFormat = \"hex\" | \"rgb\" | \"hsl\";\n\nexport interface ColorModel {\n alpha: number;\n hue: number;\n lightness: number;\n saturation: number;\n}\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\nfunction parseNumber(value: string, min: number, max: number) {\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) ? clamp(parsed, min, max) : null;\n}\n\nfunction parseAlpha(value: string | undefined) {\n if (value === undefined) return 1;\n if (value.trim().endsWith(\"%\")) {\n return parseNumber(value, 0, 100) === null\n ? null\n : (parseNumber(value, 0, 100) as number) / 100;\n }\n return parseNumber(value, 0, 1);\n}\n\nfunction parseHex(value: string): ColorModel | null {\n const hex = value.slice(1);\n if (![3, 4, 6, 8].includes(hex.length) || !/^[\\da-f]+$/i.test(hex)) return null;\n const expanded =\n hex.length <= 4\n ? hex\n .split(\"\")\n .map((part) => `${part}${part}`)\n .join(\"\")\n : hex;\n const red = Number.parseInt(expanded.slice(0, 2), 16) / 255;\n const green = Number.parseInt(expanded.slice(2, 4), 16) / 255;\n const blue = Number.parseInt(expanded.slice(4, 6), 16) / 255;\n const alpha = expanded.length === 8 ? Number.parseInt(expanded.slice(6, 8), 16) / 255 : 1;\n return rgbToHsl(red * 255, green * 255, blue * 255, alpha);\n}\n\nfunction parseRgb(value: string): ColorModel | null {\n const match = value.match(\n /^rgba?\\(\\s*([^,\\s]+)[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n\n const redValue = match[1];\n const greenValue = match[2];\n const blueValue = match[3];\n if (!redValue || !greenValue || !blueValue) return null;\n const channels = [redValue, greenValue, blueValue].map((channel) => {\n if (channel.endsWith(\"%\")) {\n const percentage = parseNumber(channel, 0, 100);\n return percentage === null ? null : (percentage / 100) * 255;\n }\n return parseNumber(channel, 0, 255);\n });\n const alpha = parseAlpha(match[4]);\n if (channels.some((channel) => channel === null) || alpha === null) return null;\n return rgbToHsl(channels[0] as number, channels[1] as number, channels[2] as number, alpha);\n}\n\nfunction parseHsl(value: string): ColorModel | null {\n const match = value.match(\n /^hsla?\\(\\s*([^,\\s]+)(?:deg)?[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n const hueValue = match[1];\n const saturationValue = match[2];\n const lightnessValue = match[3];\n if (!hueValue || !saturationValue || !lightnessValue) return null;\n const hue = parseNumber(hueValue.replace(/deg$/i, \"\"), -360, 360);\n const saturation = parseNumber(saturationValue, 0, 100);\n const lightness = parseNumber(lightnessValue, 0, 100);\n const alpha = parseAlpha(match[4]);\n if (hue === null || saturation === null || lightness === null || alpha === null) return null;\n if (!saturationValue.endsWith(\"%\") || !lightnessValue.endsWith(\"%\")) return null;\n return { alpha, hue: (hue + 360) % 360, lightness, saturation };\n}\n\nfunction rgbToHsl(red: number, green: number, blue: number, alpha = 1): ColorModel {\n const r = red / 255;\n const g = green / 255;\n const b = blue / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const delta = max - min;\n let hue = 0;\n const lightness = (max + min) / 2;\n const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));\n\n if (delta !== 0) {\n if (max === r) hue = 60 * (((g - b) / delta) % 6);\n else if (max === g) hue = 60 * ((b - r) / delta + 2);\n else hue = 60 * ((r - g) / delta + 4);\n }\n\n return {\n alpha: clamp(alpha, 0, 1),\n hue: (hue + 360) % 360,\n lightness: lightness * 100,\n saturation: saturation * 100,\n };\n}\n\nfunction hslToRgb({ hue, lightness, saturation }: ColorModel) {\n const h = hue / 360;\n const s = saturation / 100;\n const l = lightness / 100;\n const chroma = (1 - Math.abs(2 * l - 1)) * s;\n const segment = h * 6;\n const x = chroma * (1 - Math.abs((segment % 2) - 1));\n const [r, g, b] =\n segment < 1\n ? [chroma, x, 0]\n : segment < 2\n ? [x, chroma, 0]\n : segment < 3\n ? [0, chroma, x]\n : segment < 4\n ? [0, x, chroma]\n : segment < 5\n ? [x, 0, chroma]\n : [chroma, 0, x];\n const match = l - chroma / 2;\n return {\n blue: Math.round((b + match) * 255),\n green: Math.round((g + match) * 255),\n red: Math.round((r + match) * 255),\n };\n}\n\nexport function parseColor(value: string | undefined): ColorModel | null {\n if (!value) return null;\n const normalized = value.trim();\n if (normalized.startsWith(\"#\")) return parseHex(normalized);\n if (/^rgba?/i.test(normalized)) return parseRgb(normalized);\n if (/^hsla?/i.test(normalized)) return parseHsl(normalized);\n return null;\n}\n\nfunction formatAlpha(alpha: number) {\n return Number(alpha.toFixed(3)).toString();\n}\n\nexport function formatColor(color: ColorModel, format: ColorFormat, showAlpha = false) {\n const rgb = hslToRgb(color);\n if (format === \"hex\") {\n const base = [rgb.red, rgb.green, rgb.blue]\n .map((channel) => channel.toString(16).padStart(2, \"0\"))\n .join(\"\");\n return `#${base}${\n showAlpha\n ? Math.round(color.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n : \"\"\n }`;\n }\n if (format === \"rgb\") {\n return showAlpha\n ? `rgba(${rgb.red}, ${rgb.green}, ${rgb.blue}, ${formatAlpha(color.alpha)})`\n : `rgb(${rgb.red}, ${rgb.green}, ${rgb.blue})`;\n }\n return showAlpha\n ? `hsla(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)}%, ${formatAlpha(color.alpha)})`\n : `hsl(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)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AAS,EAAE,KAAK,YAAY,MAAM,KAAK,EAAE,KAC9H,OAAO,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE,KAAK,KAAK,MAAM,MAAM,SAAS,EAAE;AACrG;AAEA,SAAgB,aAAa,OAAgB;CAC3C,OAAO,WAAW,KAAK,KAAK;EAAE,OAAO;EAAG,KAAK;EAAG,WAAW;EAAG,YAAY;CAAE;AAC9E"}
1
+ {"version":3,"file":"color-utils.js","names":[],"sources":["../../../src/components/color-picker/color-utils.ts"],"sourcesContent":["export type ColorFormat = \"hex\" | \"rgb\" | \"hsl\";\n\nexport interface ColorModel {\n alpha: number;\n hue: number;\n lightness: number;\n saturation: number;\n}\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\nfunction parseNumber(value: string, min: number, max: number) {\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) ? clamp(parsed, min, max) : null;\n}\n\nfunction parseAlpha(value: string | undefined) {\n if (value === undefined) return 1;\n if (value.trim().endsWith(\"%\")) {\n return parseNumber(value, 0, 100) === null\n ? null\n : (parseNumber(value, 0, 100) as number) / 100;\n }\n return parseNumber(value, 0, 1);\n}\n\nfunction parseHex(value: string): ColorModel | null {\n const hex = value.slice(1);\n if (![3, 4, 6, 8].includes(hex.length) || !/^[\\da-f]+$/i.test(hex)) return null;\n const expanded =\n hex.length <= 4\n ? hex\n .split(\"\")\n .map((part) => `${part}${part}`)\n .join(\"\")\n : hex;\n const red = Number.parseInt(expanded.slice(0, 2), 16) / 255;\n const green = Number.parseInt(expanded.slice(2, 4), 16) / 255;\n const blue = Number.parseInt(expanded.slice(4, 6), 16) / 255;\n const alpha = expanded.length === 8 ? Number.parseInt(expanded.slice(6, 8), 16) / 255 : 1;\n return rgbToHsl(red * 255, green * 255, blue * 255, alpha);\n}\n\nfunction parseRgb(value: string): ColorModel | null {\n const match = value.match(\n /^rgba?\\(\\s*([^,\\s]+)[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n\n const redValue = match[1];\n const greenValue = match[2];\n const blueValue = match[3];\n if (!redValue || !greenValue || !blueValue) return null;\n const channels = [redValue, greenValue, blueValue].map((channel) => {\n if (channel.endsWith(\"%\")) {\n const percentage = parseNumber(channel, 0, 100);\n return percentage === null ? null : (percentage / 100) * 255;\n }\n return parseNumber(channel, 0, 255);\n });\n const alpha = parseAlpha(match[4]);\n if (channels.some((channel) => channel === null) || alpha === null) return null;\n return rgbToHsl(channels[0] as number, channels[1] as number, channels[2] as number, alpha);\n}\n\nfunction parseHsl(value: string): ColorModel | null {\n const match = value.match(\n /^hsla?\\(\\s*([^,\\s]+)(?:deg)?[,\\s]+([^,\\s]+)[,\\s]+([^,\\s]+)(?:\\s*[,/]\\s*([^\\s]+))?\\s*\\)$/i,\n );\n if (!match) return null;\n const hueValue = match[1];\n const saturationValue = match[2];\n const lightnessValue = match[3];\n if (!hueValue || !saturationValue || !lightnessValue) return null;\n const hue = parseNumber(hueValue.replace(/deg$/i, \"\"), -360, 360);\n const saturation = parseNumber(saturationValue, 0, 100);\n const lightness = parseNumber(lightnessValue, 0, 100);\n const alpha = parseAlpha(match[4]);\n if (hue === null || saturation === null || lightness === null || alpha === null) return null;\n if (!saturationValue.endsWith(\"%\") || !lightnessValue.endsWith(\"%\")) return null;\n return { alpha, hue: (hue + 360) % 360, lightness, saturation };\n}\n\nfunction rgbToHsl(red: number, green: number, blue: number, alpha = 1): ColorModel {\n const r = red / 255;\n const g = green / 255;\n const b = blue / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const delta = max - min;\n let hue = 0;\n const lightness = (max + min) / 2;\n const saturation = delta === 0 ? 0 : delta / (1 - Math.abs(2 * lightness - 1));\n\n if (delta !== 0) {\n if (max === r) hue = 60 * (((g - b) / delta) % 6);\n else if (max === g) hue = 60 * ((b - r) / delta + 2);\n else hue = 60 * ((r - g) / delta + 4);\n }\n\n return {\n alpha: clamp(alpha, 0, 1),\n hue: (hue + 360) % 360,\n lightness: lightness * 100,\n saturation: saturation * 100,\n };\n}\n\nfunction hslToRgb({ hue, lightness, saturation }: ColorModel) {\n const h = hue / 360;\n const s = saturation / 100;\n const l = lightness / 100;\n const chroma = (1 - Math.abs(2 * l - 1)) * s;\n const segment = h * 6;\n const x = chroma * (1 - Math.abs((segment % 2) - 1));\n const [r, g, b] =\n segment < 1\n ? [chroma, x, 0]\n : segment < 2\n ? [x, chroma, 0]\n : segment < 3\n ? [0, chroma, x]\n : segment < 4\n ? [0, x, chroma]\n : segment < 5\n ? [x, 0, chroma]\n : [chroma, 0, x];\n const match = l - chroma / 2;\n return {\n blue: Math.round((b + match) * 255),\n green: Math.round((g + match) * 255),\n red: Math.round((r + match) * 255),\n };\n}\n\nexport function parseColor(value: string | undefined): ColorModel | null {\n if (!value) return null;\n const normalized = value.trim();\n if (normalized.startsWith(\"#\")) return parseHex(normalized);\n if (/^rgba?/i.test(normalized)) return parseRgb(normalized);\n if (/^hsla?/i.test(normalized)) return parseHsl(normalized);\n return null;\n}\n\nfunction formatAlpha(alpha: number) {\n return Number(alpha.toFixed(3)).toString();\n}\n\nexport function formatColor(color: ColorModel, format: ColorFormat, showAlpha = false) {\n const rgb = hslToRgb(color);\n if (format === \"hex\") {\n const base = [rgb.red, rgb.green, rgb.blue]\n .map((channel) => channel.toString(16).padStart(2, \"0\"))\n .join(\"\");\n return `#${base}${\n showAlpha\n ? Math.round(color.alpha * 255)\n .toString(16)\n .padStart(2, \"0\")\n : \"\"\n }`;\n }\n if (format === \"rgb\") {\n return showAlpha\n ? `rgba(${rgb.red}, ${rgb.green}, ${rgb.blue}, ${formatAlpha(color.alpha)})`\n : `rgb(${rgb.red}, ${rgb.green}, ${rgb.blue})`;\n }\n return showAlpha\n ? `hsla(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)}%, ${formatAlpha(color.alpha)})`\n : `hsl(${Math.round(color.hue)}, ${Math.round(color.saturation)}%, ${Math.round(color.lightness)}%)`;\n}\n\nexport function defaultColor(value?: string) {\n return parseColor(value) ?? { alpha: 1, hue: 0, lightness: 0, saturation: 0 };\n}\n"],"mappings":";AASA,MAAM,SAAS,OAAe,KAAa,QAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAE7F,SAAS,YAAY,OAAe,KAAa,KAAa;CAC5D,MAAM,SAAS,OAAO,WAAW,KAAK;CACtC,OAAO,OAAO,SAAS,MAAM,IAAI,MAAM,QAAQ,KAAK,GAAG,IAAI;AAC7D;AAEA,SAAS,WAAW,OAA2B;CAC7C,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,GAC3B,OAAO,YAAY,OAAO,GAAG,GAAG,MAAM,OAClC,OACC,YAAY,OAAO,GAAG,GAAG,IAAe;CAE/C,OAAO,YAAY,OAAO,GAAG,CAAC;AAChC;AAEA,SAAS,SAAS,OAAkC;CAClD,MAAM,MAAM,MAAM,MAAM,CAAC;CACzB,IAAI,CAAC;EAAC;EAAG;EAAG;EAAG;CAAC,CAAC,CAAC,SAAS,IAAI,MAAM,KAAK,CAAC,cAAc,KAAK,GAAG,GAAG,OAAO;CAC3E,MAAM,WACJ,IAAI,UAAU,IACV,IACG,MAAM,EAAE,CAAC,CACT,KAAK,SAAS,GAAG,OAAO,MAAM,CAAC,CAC/B,KAAK,EAAE,IACV;CACN,MAAM,MAAM,OAAO,SAAS,SAAS,MAAM,GAAG,CAAC,GAAG,EAAE,IAAI;CACxD,MAAM,QAAQ,OAAO,SAAS,SAAS,MAAM,GAAG,CAAC,GAAG,EAAE,IAAI;CAC1D,MAAM,OAAO,OAAO,SAAS,SAAS,MAAM,GAAG,CAAC,GAAG,EAAE,IAAI;CACzD,MAAM,QAAQ,SAAS,WAAW,IAAI,OAAO,SAAS,SAAS,MAAM,GAAG,CAAC,GAAG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G,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE,KAAK,KAAK,MAAM,MAAM,SAAS,EAAE,KAAK,YAAY,MAAM,KAAK,EAAE,KAC9H,OAAO,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE,KAAK,KAAK,MAAM,MAAM,SAAS,EAAE;AACrG;AAEA,SAAgB,aAAa,OAAgB;CAC3C,OAAO,WAAW,KAAK,KAAK;EAAE,OAAO;EAAG,KAAK;EAAG,WAAW;EAAG,YAAY;CAAE;AAC9E"}
@@ -14,7 +14,7 @@ declare function ContextMenuPortal(props: ContextMenuPortalProps): import("react
14
14
  type ContextMenuBackdropProps = ComponentPropsWithoutRef<typeof ContextMenu.Backdrop>;
15
15
  declare const ContextMenuBackdrop: typeof ContextMenu.Backdrop;
16
16
  type ContextMenuPositionerProps = ComponentPropsWithoutRef<typeof ContextMenu.Positioner>;
17
- declare const ContextMenuPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
17
+ declare const ContextMenuPositioner: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuPositionerProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
18
18
  type ContextMenuPopupProps = ComponentPropsWithoutRef<typeof ContextMenu.Popup>;
19
19
  declare const ContextMenuPopup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
20
20
  type ContextMenuArrowProps = ComponentPropsWithoutRef<typeof ContextMenu.Arrow>;
@@ -48,7 +48,7 @@ declare const ContextMenu$1: {
48
48
  Trigger: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
49
49
  Portal: typeof ContextMenuPortal;
50
50
  Backdrop: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
51
- Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
51
+ Positioner: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuPositionerProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
52
52
  Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
53
53
  Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
54
54
  Item: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
@@ -14,7 +14,7 @@ declare function ContextMenuPortal(props: ContextMenuPortalProps): import("react
14
14
  type ContextMenuBackdropProps = ComponentPropsWithoutRef<typeof ContextMenu.Backdrop>;
15
15
  declare const ContextMenuBackdrop: typeof ContextMenu.Backdrop;
16
16
  type ContextMenuPositionerProps = ComponentPropsWithoutRef<typeof ContextMenu.Positioner>;
17
- declare const ContextMenuPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
17
+ declare const ContextMenuPositioner: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuPositionerProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
18
18
  type ContextMenuPopupProps = ComponentPropsWithoutRef<typeof ContextMenu.Popup>;
19
19
  declare const ContextMenuPopup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
20
20
  type ContextMenuArrowProps = ComponentPropsWithoutRef<typeof ContextMenu.Arrow>;
@@ -48,7 +48,7 @@ declare const ContextMenu$1: {
48
48
  Trigger: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
49
49
  Portal: typeof ContextMenuPortal;
50
50
  Backdrop: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
51
- Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
51
+ Positioner: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuPositionerProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
52
52
  Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
53
53
  Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
54
54
  Item: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"field.cjs","names":["createContext","forwardRef","useId","useState","useRef","useContext","JaciFormContext","useCallback","field","BaseField","cx"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n controlId: string | undefined;\n descriptionId: string | undefined;\n dirty: boolean;\n errorId: string | undefined;\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n labelId: string | undefined;\n name: string | undefined;\n pending: boolean;\n touched: boolean;\n valid: boolean | null;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n controlId: undefined,\n descriptionId: undefined,\n dirty: false,\n errorId: undefined,\n errors: [],\n insideField: false,\n invalid: false,\n labelId: undefined,\n name: undefined,\n pending: false,\n touched: false,\n valid: null,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Marks the field as awaiting asynchronous validation. */\n pending?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor?: string;\n}\n\nconst FieldRoot = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n pending: pendingProp = false,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const controlId = `${generatedId}-control`;\n const labelId = `${generatedId}-label`;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const [pendingValidation, setPendingValidation] = useState(false);\n const [validationErrors, setValidationErrors] = useState<ReactNode[]>([]);\n const [validationValid, setValidationValid] = useState<boolean | null>(null);\n const validationSequence = useRef(0);\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const externalErrors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const errors =\n directErrors !== undefined || formError !== undefined ? externalErrors : validationErrors;\n const invalid = invalidProp || errors.length > 0;\n const pending = pendingProp || pendingValidation;\n const wrappedValidate = useCallback<NonNullable<BaseFieldRoot.Props[\"validate\"]>>(\n (value, formValues) => {\n const sequence = ++validationSequence.current;\n if (!validate) return null;\n const result = validate(value, formValues);\n if (!result || typeof result !== \"object\" || !(\"then\" in result)) {\n const resultErrors = normalizeErrors(result);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n setPendingValidation(false);\n return result;\n }\n setValidationErrors([]);\n setValidationValid(null);\n setPendingValidation(true);\n return Promise.resolve(result)\n .then((validationResult) => {\n if (sequence !== validationSequence.current) return null;\n const resultErrors = normalizeErrors(validationResult);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n return validationResult;\n })\n .finally(() => {\n if (sequence === validationSequence.current) setPendingValidation(false);\n });\n },\n [validate],\n );\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider\n value={{\n controlId,\n descriptionId,\n dirty: dirty ?? false,\n errorId,\n errors,\n insideField: true,\n invalid,\n labelId,\n name,\n pending,\n touched: touched ?? false,\n valid: invalid ? false : validationValid,\n }}\n >\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n aria-busy={pending || undefined}\n data-dirty={dirty || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-pending={pending || undefined}\n data-slot=\"field\"\n data-touched={touched || undefined}\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n {...(validate ? { validate: wrappedValidate } : {})}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport interface FieldControlProps extends ComponentPropsWithoutRef<typeof BaseField.Control> {}\n\nexport const FieldControl = forwardRef<HTMLElement, FieldControlProps>(function FieldControl(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n \"aria-invalid\": ariaInvalid,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n id,\n ...props\n },\n ref,\n) {\n const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } =\n useContext(FieldContext);\n const describedBy =\n [ariaDescribedBy, descriptionId, invalid ? errorId : undefined].filter(Boolean).join(\" \") ||\n undefined;\n const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(\" \") || undefined;\n const controlProps = {\n ...props,\n \"aria-busy\": pending || undefined,\n \"aria-describedby\": describedBy,\n \"aria-errormessage\": ariaErrorMessage ?? (invalid ? errorId : undefined),\n \"aria-invalid\": ariaInvalid ?? (invalid || undefined),\n \"aria-labelledby\": labelledBy,\n className,\n \"data-pending\": pending || undefined,\n id: id ?? controlId,\n };\n if (!insideField) return <BaseField.Control {...controlProps} ref={ref} />;\n return <BaseField.Control {...controlProps} ref={ref} />;\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { controlId, insideField, invalid, labelId } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor: htmlFor ?? controlId,\n id: props.id ?? labelId,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor ?? controlId}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { descriptionId, insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n id: props.id ?? descriptionId,\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errorId, errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n\nexport const Field = Object.assign(FieldRoot, {\n Root: FieldRoot,\n Control: FieldControl,\n Label: FieldLabel,\n Description: FieldDescription,\n Error: FieldError,\n});\n"],"mappings":";;;;;;;;AA4BA,MAAM,gBAAA,GAAeA,MAAAA,cAAAA,CAAiC;CACpD,WAAW,KAAA;CACX,eAAe,KAAA;CACf,OAAO;CACP,SAAS,KAAA;CACT,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,SAAS,KAAA;CACT,MAAM,KAAA;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,QAA0D;CACjF,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,OACxD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD;AAEA,SAAS,aAAa,QAAqB;CACzC,IAAI,OAAO,UAAU,GACnB,OAAO,OAAO;CAGhB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAA,UAAqD,MAAU,GAAtD,OAAO,UAAU,WAAW,QAAQ,KA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A,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GAAGF,cAAAA,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,IAAI,MAAM,MAAM;EAChB,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD,CAAI,CAAA;EACZ,MAAK;EAEJ,UAAA;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,QAAA,GAAOH,MAAAA,WAAAA,CAAW,YAAY;AAChC;AAEA,MAAa,QAAQ,OAAO,OAAO,WAAW;CAC5C,MAAM;CACN,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"field.cjs","names":["createContext","forwardRef","useId","useState","useRef","useContext","JaciFormContext","useCallback","field","BaseField","cx"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n controlId: string | undefined;\n descriptionId: string | undefined;\n dirty: boolean;\n errorId: string | undefined;\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n labelId: string | undefined;\n name: string | undefined;\n pending: boolean;\n touched: boolean;\n valid: boolean | null;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n controlId: undefined,\n descriptionId: undefined,\n dirty: false,\n errorId: undefined,\n errors: [],\n insideField: false,\n invalid: false,\n labelId: undefined,\n name: undefined,\n pending: false,\n touched: false,\n valid: null,\n});\n\nfunction normalizeErrors(errors: unknown): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors as ReactNode];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Marks the field as awaiting asynchronous validation. */\n pending?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor?: string;\n}\n\nconst FieldRoot = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n pending: pendingProp = false,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const controlId = `${generatedId}-control`;\n const labelId = `${generatedId}-label`;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const [pendingValidation, setPendingValidation] = useState(false);\n const [validationErrors, setValidationErrors] = useState<ReactNode[]>([]);\n const [validationValid, setValidationValid] = useState<boolean | null>(null);\n const validationSequence = useRef(0);\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const externalErrors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const errors =\n directErrors !== undefined || formError !== undefined ? externalErrors : validationErrors;\n const invalid = invalidProp || errors.length > 0;\n const pending = pendingProp || pendingValidation;\n const wrappedValidate = useCallback<NonNullable<BaseFieldRoot.Props[\"validate\"]>>(\n (value, formValues) => {\n const sequence = ++validationSequence.current;\n if (!validate) return null;\n const result = validate(value, formValues);\n if (!result || typeof result !== \"object\" || !(\"then\" in result)) {\n const resultErrors = normalizeErrors(result);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n setPendingValidation(false);\n return result;\n }\n setValidationErrors([]);\n setValidationValid(null);\n setPendingValidation(true);\n return Promise.resolve(result)\n .then((validationResult) => {\n if (sequence !== validationSequence.current) return null;\n const resultErrors = normalizeErrors(validationResult);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n return validationResult;\n })\n .finally(() => {\n if (sequence === validationSequence.current) setPendingValidation(false);\n });\n },\n [validate],\n );\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider\n value={{\n controlId,\n descriptionId,\n dirty: dirty ?? false,\n errorId,\n errors,\n insideField: true,\n invalid,\n labelId,\n name,\n pending,\n touched: touched ?? false,\n valid: invalid ? false : validationValid,\n }}\n >\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n aria-busy={pending || undefined}\n data-dirty={dirty || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-pending={pending || undefined}\n data-slot=\"field\"\n data-touched={touched || undefined}\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n {...(validate ? { validate: wrappedValidate } : {})}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport interface FieldControlProps extends ComponentPropsWithoutRef<typeof BaseField.Control> {}\n\nexport const FieldControl = forwardRef<HTMLElement, FieldControlProps>(function FieldControl(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n \"aria-invalid\": ariaInvalid,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n id,\n ...props\n },\n ref,\n) {\n const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } =\n useContext(FieldContext);\n const describedBy =\n [ariaDescribedBy, descriptionId, invalid ? errorId : undefined].filter(Boolean).join(\" \") ||\n undefined;\n const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(\" \") || undefined;\n const controlProps = {\n ...props,\n \"aria-busy\": pending || undefined,\n \"aria-describedby\": describedBy,\n \"aria-errormessage\": ariaErrorMessage ?? (invalid ? errorId : undefined),\n \"aria-invalid\": ariaInvalid ?? (invalid || undefined),\n \"aria-labelledby\": labelledBy,\n className,\n \"data-pending\": pending || undefined,\n id: id ?? controlId,\n };\n if (!insideField) return <BaseField.Control {...controlProps} ref={ref} />;\n return <BaseField.Control {...controlProps} ref={ref} />;\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { controlId, insideField, invalid, labelId } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor: htmlFor ?? controlId,\n id: props.id ?? labelId,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor ?? controlId}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { descriptionId, insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n id: props.id ?? descriptionId,\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errorId, errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n\nexport const Field = Object.assign(FieldRoot, {\n Root: FieldRoot,\n Control: FieldControl,\n Label: FieldLabel,\n Description: FieldDescription,\n Error: FieldError,\n});\n"],"mappings":";;;;;;;;AA4BA,MAAM,gBAAA,GAAeA,MAAAA,cAAAA,CAAiC;CACpD,WAAW,KAAA;CACX,eAAe,KAAA;CACf,OAAO;CACP,SAAS,KAAA;CACT,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,SAAS,KAAA;CACT,MAAM,KAAA;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,QAA8B;CACrD,IAAI,WAAW,KAAA,KA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,CAAC,aAAa;EAChB,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,YAAY,OAC3D,OAAO;EAGT,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GACE,GAAI;GACC;GACL,WAAWK,WAAAA,GAAGF,cAAAA,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;GACjD,aAAU;GACV,IAAI,MAAM,MAAM;GAChB,MAAK;GAEJ,UAAA;EACA,CAAA;CAEP;CAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GAAGF,cAAAA,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,IAAI,MAAM,MAAM;EAChB,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD,CAAI,CAAA;EACZ,MAAK;EAEJ,UAAA;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,QAAA,GAAOH,MAAAA,WAAAA,CAAW,YAAY;AAChC;AAEA,MAAa,QAAQ,OAAO,OAAO,WAAW;CAC5C,MAAM;CACN,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;AACT,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","names":["FieldRoot","Field","BaseField"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n controlId: string | undefined;\n descriptionId: string | undefined;\n dirty: boolean;\n errorId: string | undefined;\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n labelId: string | undefined;\n name: string | undefined;\n pending: boolean;\n touched: boolean;\n valid: boolean | null;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n controlId: undefined,\n descriptionId: undefined,\n dirty: false,\n errorId: undefined,\n errors: [],\n insideField: false,\n invalid: false,\n labelId: undefined,\n name: undefined,\n pending: false,\n touched: false,\n valid: null,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Marks the field as awaiting asynchronous validation. */\n pending?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor?: string;\n}\n\nconst FieldRoot = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n pending: pendingProp = false,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const controlId = `${generatedId}-control`;\n const labelId = `${generatedId}-label`;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const [pendingValidation, setPendingValidation] = useState(false);\n const [validationErrors, setValidationErrors] = useState<ReactNode[]>([]);\n const [validationValid, setValidationValid] = useState<boolean | null>(null);\n const validationSequence = useRef(0);\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const externalErrors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const errors =\n directErrors !== undefined || formError !== undefined ? externalErrors : validationErrors;\n const invalid = invalidProp || errors.length > 0;\n const pending = pendingProp || pendingValidation;\n const wrappedValidate = useCallback<NonNullable<BaseFieldRoot.Props[\"validate\"]>>(\n (value, formValues) => {\n const sequence = ++validationSequence.current;\n if (!validate) return null;\n const result = validate(value, formValues);\n if (!result || typeof result !== \"object\" || !(\"then\" in result)) {\n const resultErrors = normalizeErrors(result);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n setPendingValidation(false);\n return result;\n }\n setValidationErrors([]);\n setValidationValid(null);\n setPendingValidation(true);\n return Promise.resolve(result)\n .then((validationResult) => {\n if (sequence !== validationSequence.current) return null;\n const resultErrors = normalizeErrors(validationResult);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n return validationResult;\n })\n .finally(() => {\n if (sequence === validationSequence.current) setPendingValidation(false);\n });\n },\n [validate],\n );\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider\n value={{\n controlId,\n descriptionId,\n dirty: dirty ?? false,\n errorId,\n errors,\n insideField: true,\n invalid,\n labelId,\n name,\n pending,\n touched: touched ?? false,\n valid: invalid ? false : validationValid,\n }}\n >\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n aria-busy={pending || undefined}\n data-dirty={dirty || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-pending={pending || undefined}\n data-slot=\"field\"\n data-touched={touched || undefined}\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n {...(validate ? { validate: wrappedValidate } : {})}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport interface FieldControlProps extends ComponentPropsWithoutRef<typeof BaseField.Control> {}\n\nexport const FieldControl = forwardRef<HTMLElement, FieldControlProps>(function FieldControl(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n \"aria-invalid\": ariaInvalid,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n id,\n ...props\n },\n ref,\n) {\n const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } =\n useContext(FieldContext);\n const describedBy =\n [ariaDescribedBy, descriptionId, invalid ? errorId : undefined].filter(Boolean).join(\" \") ||\n undefined;\n const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(\" \") || undefined;\n const controlProps = {\n ...props,\n \"aria-busy\": pending || undefined,\n \"aria-describedby\": describedBy,\n \"aria-errormessage\": ariaErrorMessage ?? (invalid ? errorId : undefined),\n \"aria-invalid\": ariaInvalid ?? (invalid || undefined),\n \"aria-labelledby\": labelledBy,\n className,\n \"data-pending\": pending || undefined,\n id: id ?? controlId,\n };\n if (!insideField) return <BaseField.Control {...controlProps} ref={ref} />;\n return <BaseField.Control {...controlProps} ref={ref} />;\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { controlId, insideField, invalid, labelId } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor: htmlFor ?? controlId,\n id: props.id ?? labelId,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor ?? controlId}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { descriptionId, insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n id: props.id ?? descriptionId,\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errorId, errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n\nexport const Field = Object.assign(FieldRoot, {\n Root: FieldRoot,\n Control: FieldControl,\n Label: FieldLabel,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MAAM,MAAM;EAChB,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,oBAAC,KAAD,CAAI,CAAA;EACZ,MAAK;EAEJ,UAAA;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,OAAO,WAAW,YAAY;AAChC;AAEA,MAAaD,UAAQ,OAAO,OAAOD,aAAW;CAC5C,MAAMA;CACN,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"field.js","names":["FieldRoot","Field","BaseField"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n controlId: string | undefined;\n descriptionId: string | undefined;\n dirty: boolean;\n errorId: string | undefined;\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n labelId: string | undefined;\n name: string | undefined;\n pending: boolean;\n touched: boolean;\n valid: boolean | null;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n controlId: undefined,\n descriptionId: undefined,\n dirty: false,\n errorId: undefined,\n errors: [],\n insideField: false,\n invalid: false,\n labelId: undefined,\n name: undefined,\n pending: false,\n touched: false,\n valid: null,\n});\n\nfunction normalizeErrors(errors: unknown): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors as ReactNode];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Marks the field as awaiting asynchronous validation. */\n pending?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor?: string;\n}\n\nconst FieldRoot = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n pending: pendingProp = false,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const controlId = `${generatedId}-control`;\n const labelId = `${generatedId}-label`;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const [pendingValidation, setPendingValidation] = useState(false);\n const [validationErrors, setValidationErrors] = useState<ReactNode[]>([]);\n const [validationValid, setValidationValid] = useState<boolean | null>(null);\n const validationSequence = useRef(0);\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const externalErrors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const errors =\n directErrors !== undefined || formError !== undefined ? externalErrors : validationErrors;\n const invalid = invalidProp || errors.length > 0;\n const pending = pendingProp || pendingValidation;\n const wrappedValidate = useCallback<NonNullable<BaseFieldRoot.Props[\"validate\"]>>(\n (value, formValues) => {\n const sequence = ++validationSequence.current;\n if (!validate) return null;\n const result = validate(value, formValues);\n if (!result || typeof result !== \"object\" || !(\"then\" in result)) {\n const resultErrors = normalizeErrors(result);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n setPendingValidation(false);\n return result;\n }\n setValidationErrors([]);\n setValidationValid(null);\n setPendingValidation(true);\n return Promise.resolve(result)\n .then((validationResult) => {\n if (sequence !== validationSequence.current) return null;\n const resultErrors = normalizeErrors(validationResult);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n return validationResult;\n })\n .finally(() => {\n if (sequence === validationSequence.current) setPendingValidation(false);\n });\n },\n [validate],\n );\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider\n value={{\n controlId,\n descriptionId,\n dirty: dirty ?? false,\n errorId,\n errors,\n insideField: true,\n invalid,\n labelId,\n name,\n pending,\n touched: touched ?? false,\n valid: invalid ? false : validationValid,\n }}\n >\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n aria-busy={pending || undefined}\n data-dirty={dirty || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-pending={pending || undefined}\n data-slot=\"field\"\n data-touched={touched || undefined}\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n {...(validate ? { validate: wrappedValidate } : {})}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport interface FieldControlProps extends ComponentPropsWithoutRef<typeof BaseField.Control> {}\n\nexport const FieldControl = forwardRef<HTMLElement, FieldControlProps>(function FieldControl(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n \"aria-invalid\": ariaInvalid,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n id,\n ...props\n },\n ref,\n) {\n const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } =\n useContext(FieldContext);\n const describedBy =\n [ariaDescribedBy, descriptionId, invalid ? errorId : undefined].filter(Boolean).join(\" \") ||\n undefined;\n const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(\" \") || undefined;\n const controlProps = {\n ...props,\n \"aria-busy\": pending || undefined,\n \"aria-describedby\": describedBy,\n \"aria-errormessage\": ariaErrorMessage ?? (invalid ? errorId : undefined),\n \"aria-invalid\": ariaInvalid ?? (invalid || undefined),\n \"aria-labelledby\": labelledBy,\n className,\n \"data-pending\": pending || undefined,\n id: id ?? controlId,\n };\n if (!insideField) return <BaseField.Control {...controlProps} ref={ref} />;\n return <BaseField.Control {...controlProps} ref={ref} />;\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { controlId, insideField, invalid, labelId } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor: htmlFor ?? controlId,\n id: props.id ?? labelId,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor ?? controlId}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { descriptionId, insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n id: props.id ?? descriptionId,\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errorId, errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n\nexport const Field = Object.assign(FieldRoot, {\n Root: FieldRoot,\n Control: FieldControl,\n Label: FieldLabel,\n Description: FieldDescription,\n Error: FieldError,\n});\n"],"mappings":";;;;;;;;AA4BA,MAAM,eAAe,cAAiC;CACpD,WAAW,KAAA;CACX,eAAe,KAAA;CACf,OAAO;CACP,SAAS,KAAA;CACT,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,SAAS,KAAA;CACT,MAAM,KAAA;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,QAA8B;CACrD,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,OACxD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAmB;AAC9D;AAEA,SAAS,aAAa,QAAqB;CACzC,IAAI,OAAO,UAAU,GACnB,OAAO,OAAO;CAGhB,OACE,oBAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,oBAAC,MAA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;EAAG,GAAI;EAAuB;CAAM,CAAA;CAG7C,OAAO,oBAACA,MAAU,aAAX;EAAuB,GAAI;EAAuB;CAAM,CAAA;AACjE,CACF;AAOA,MAAa,aAAa,WAAkD,SAAS,WACnF,EAAE,UAAU,WAAW,OAAO,GAAG,SACjC,KACA;CACA,MAAM,EAAE,SAAS,QAAQ,aAAa,YAAY,WAAW,YAAY;CACzE,MAAM,UAAU,YAAY,aAAa,MAAM;CAE/C,IAAI,CAAC,aAAa;EAChB,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,YAAY,OAC3D,OAAO;EAGT,OACE,oBAAC,KAAD;GACE,GAAI;GACC;GACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;GACjD,aAAU;GACV,IAAI,MAAM,MAAM;GAChB,MAAK;GAEJ,UAAA;EACA,CAAA;CAEP;CAEA,OACE,oBAACA,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,IAAI,MAAM,MAAM;EAChB,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,oBAAC,KAAD,CAAI,CAAA;EACZ,MAAK;EAEJ,UAAA;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,OAAO,WAAW,YAAY;AAChC;AAEA,MAAaD,UAAQ,OAAO,OAAOD,aAAW;CAC5C,MAAMA;CACN,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;AACT,CAAC"}
@@ -12,7 +12,7 @@ declare const MenuTrigger$1: import("react").ForwardRefExoticComponent<Omit<Menu
12
12
  /** Preserves Base UI's portal and optional container APIs. */
13
13
  declare function MenuPortal(props: ComponentPropsWithoutRef<typeof Menu.Portal>): import("react").JSX.Element;
14
14
  type MenuPositionerProps = ComponentPropsWithoutRef<typeof Menu.Positioner>;
15
- declare const MenuPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
15
+ declare const MenuPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
16
16
  type MenuPopupProps = ComponentPropsWithoutRef<typeof Menu.Popup>;
17
17
  declare const MenuPopup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
18
18
  type MenuItemProps = ComponentPropsWithoutRef<typeof Menu.Item>;
@@ -32,7 +32,7 @@ declare const Menu$1: {
32
32
  Root: typeof MenuRoot$1;
33
33
  Trigger: import("react").ForwardRefExoticComponent<Omit<MenuTriggerProps<unknown>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
34
34
  Portal: typeof MenuPortal;
35
- Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
35
+ Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
36
36
  Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
37
37
  Item: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
38
38
  LinkItem: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuLinkItemProps, "ref"> & import("react").RefAttributes<Element>, "ref"> & import("react").RefAttributes<Element>>;
@@ -12,7 +12,7 @@ declare const MenuTrigger$1: import("react").ForwardRefExoticComponent<Omit<Menu
12
12
  /** Preserves Base UI's portal and optional container APIs. */
13
13
  declare function MenuPortal(props: ComponentPropsWithoutRef<typeof Menu.Portal>): import("react").JSX.Element;
14
14
  type MenuPositionerProps = ComponentPropsWithoutRef<typeof Menu.Positioner>;
15
- declare const MenuPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
15
+ declare const MenuPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
16
16
  type MenuPopupProps = ComponentPropsWithoutRef<typeof Menu.Popup>;
17
17
  declare const MenuPopup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
18
18
  type MenuItemProps = ComponentPropsWithoutRef<typeof Menu.Item>;
@@ -32,7 +32,7 @@ declare const Menu$1: {
32
32
  Root: typeof MenuRoot$1;
33
33
  Trigger: import("react").ForwardRefExoticComponent<Omit<MenuTriggerProps<unknown>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
34
34
  Portal: typeof MenuPortal;
35
- Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
35
+ Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
36
36
  Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
37
37
  Item: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
38
38
  LinkItem: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuLinkItemProps, "ref"> & import("react").RefAttributes<Element>, "ref"> & import("react").RefAttributes<Element>>;
@@ -18,7 +18,7 @@ declare const MenubarTrigger: import("react").ForwardRefExoticComponent<Omit<imp
18
18
  type MenubarPortalProps = ComponentPropsWithoutRef<typeof Menu.Portal>;
19
19
  declare function MenubarPortal(props: MenubarPortalProps): import("react").JSX.Element;
20
20
  type MenubarPositionerProps = ComponentPropsWithoutRef<typeof Menu.Positioner>;
21
- declare const MenubarPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
21
+ declare const MenubarPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
22
22
  type MenubarPopupProps = ComponentPropsWithoutRef<typeof Menu.Popup>;
23
23
  declare const MenubarPopup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
24
24
  type MenubarArrowProps = ComponentPropsWithoutRef<typeof Menu.Arrow>;
@@ -52,7 +52,7 @@ declare const Menubar$1: {
52
52
  Menu: typeof MenubarMenu;
53
53
  Trigger: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").MenuTriggerProps<unknown> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
54
54
  Portal: typeof MenubarPortal;
55
- Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
55
+ Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
56
56
  Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
57
57
  Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
58
58
  Item: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
@@ -18,7 +18,7 @@ declare const MenubarTrigger: import("react").ForwardRefExoticComponent<Omit<imp
18
18
  type MenubarPortalProps = ComponentPropsWithoutRef<typeof Menu.Portal>;
19
19
  declare function MenubarPortal(props: MenubarPortalProps): import("react").JSX.Element;
20
20
  type MenubarPositionerProps = ComponentPropsWithoutRef<typeof Menu.Positioner>;
21
- declare const MenubarPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
21
+ declare const MenubarPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
22
22
  type MenubarPopupProps = ComponentPropsWithoutRef<typeof Menu.Popup>;
23
23
  declare const MenubarPopup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
24
24
  type MenubarArrowProps = ComponentPropsWithoutRef<typeof Menu.Arrow>;
@@ -52,7 +52,7 @@ declare const Menubar$1: {
52
52
  Menu: typeof MenubarMenu;
53
53
  Trigger: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").MenuTriggerProps<unknown> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
54
54
  Portal: typeof MenubarPortal;
55
- Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
55
+ Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").MenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
56
56
  Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
57
57
  Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
58
58
  Item: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ContextMenuItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
@@ -57,15 +57,16 @@ const TagsInput = (0, react.forwardRef)(function TagsInput({ "aria-describedby":
57
57
  const tag = rawTag.trim();
58
58
  const isAllowed = data.length === 0 || data.includes(tag);
59
59
  const duplicate = selectedTags.includes(tag);
60
- if (tag && isAllowed && (allowDuplicates || !duplicate)) if (editingTag) {
61
- updateTags([
62
- ...selectedTags.slice(0, editingTag.index),
63
- tag,
64
- ...selectedTags.slice(editingTag.index)
65
- ]);
66
- setEditingTag(null);
67
- } else updateTags([...selectedTags, tag]);
68
- else if (editingTag) return;
60
+ if (tag && isAllowed && (allowDuplicates || !duplicate)) {
61
+ if (editingTag) {
62
+ updateTags([
63
+ ...selectedTags.slice(0, editingTag.index),
64
+ tag,
65
+ ...selectedTags.slice(editingTag.index)
66
+ ]);
67
+ setEditingTag(null);
68
+ } else updateTags([...selectedTags, tag]);
69
+ } else if (editingTag) return;
69
70
  clearInput(event);
70
71
  }, [
71
72
  allowDuplicates,
@@ -1 +1 @@
1
- {"version":3,"file":"tags-input.cjs","names":["forwardRef","useId","useState","useRef","tagsInput","useCallback","useMemo","cx"],"sources":["../../../src/components/tags-input/tags-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport type {\n ChangeEvent,\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ClipboardEvent,\n ReactNode,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { tagsInput } from \"../../styled-system/recipes\";\n\nexport interface TagsInputProps\n extends Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"children\" | \"defaultValue\" | \"onChange\" | \"type\" | \"value\"\n > {\n /** Current tags. Omit this prop to use the uncontrolled API. */\n tags?: readonly string[];\n /** Initial tags for the uncontrolled API. */\n defaultTags?: readonly string[];\n /** Called whenever a tag is added or removed. */\n onTagsChange?: (tags: string[]) => void;\n /** Optional suggestions. A tag is accepted after a comma only when it is in this list. */\n data?: readonly string[];\n /** Visible label for the input. */\n label?: ReactNode;\n /** Current text query. This is the native input value, not the selected tags. */\n value?: string;\n /** Initial text query for an uncontrolled input. */\n defaultValue?: string;\n /** Native input change callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Optional callback useful when a controlled query is cleared by selecting a tag. */\n onInputValueChange?: (value: string) => void;\n allowDuplicates?: boolean;\n delimiter?: string | RegExp;\n editable?: boolean;\n}\n\nfunction changedEvent(event: ChangeEvent<HTMLInputElement>, value: string) {\n const target = event.target;\n const nextTarget = {\n checked: target.checked,\n id: target.id,\n name: target.name,\n value,\n } as HTMLInputElement;\n\n return {\n ...event,\n currentTarget: nextTarget,\n target: nextTarget,\n } as ChangeEvent<HTMLInputElement>;\n}\n\nfunction tagKey(tag: string, index: number) {\n return `${tag}-${index}`;\n}\n\nfunction hasDelimiter(value: string, delimiter: string | RegExp) {\n if (typeof delimiter === \"string\") return delimiter.length > 0 && value.includes(delimiter);\n delimiter.lastIndex = 0;\n const result = delimiter.test(value);\n delimiter.lastIndex = 0;\n return result;\n}\n\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-label\": ariaLabel,\n allowDuplicates = false,\n className,\n data = [],\n defaultTags = [],\n defaultValue = \"\",\n disabled = false,\n delimiter = /[,\\n]/u,\n editable = false,\n id: providedId,\n label,\n onBlur,\n onChange,\n onFocus,\n onInputValueChange,\n onTagsChange,\n placeholder,\n tags: controlledTags,\n value: controlledInputValue,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const id = providedId ?? generatedId;\n const [uncontrolledTags, setUncontrolledTags] = useState<string[]>(() => [...defaultTags]);\n const [uncontrolledInputValue, setUncontrolledInputValue] = useState(defaultValue);\n const [focused, setFocused] = useState(false);\n const [composing, setComposing] = useState(false);\n const [editingTag, setEditingTag] = useState<{ index: number; value: string } | null>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const styles = tagsInput();\n const selectedTags = controlledTags === undefined ? uncontrolledTags : [...controlledTags];\n const inputValue =\n controlledInputValue === undefined ? uncontrolledInputValue : controlledInputValue;\n\n const updateTags = useCallback(\n (nextTags: string[]) => {\n if (controlledTags === undefined) setUncontrolledTags(nextTags);\n onTagsChange?.(nextTags);\n },\n [controlledTags, onTagsChange],\n );\n\n const clearInput = useCallback(\n (event?: ChangeEvent<HTMLInputElement>) => {\n if (controlledInputValue === undefined) setUncontrolledInputValue(\"\");\n onInputValueChange?.(\"\");\n if (event) onChange?.(changedEvent(event, \"\"));\n },\n [controlledInputValue, onChange, onInputValueChange],\n );\n\n const addTag = useCallback(\n (rawTag: string, event?: ChangeEvent<HTMLInputElement>) => {\n const tag = rawTag.trim();\n const isAllowed = data.length === 0 || data.includes(tag);\n const duplicate = selectedTags.includes(tag);\n if (tag && isAllowed && (allowDuplicates || !duplicate)) {\n if (editingTag) {\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n tag,\n ...selectedTags.slice(editingTag.index),\n ]);\n setEditingTag(null);\n } else {\n updateTags([...selectedTags, tag]);\n }\n } else if (editingTag) {\n return;\n }\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, editingTag, selectedTags, updateTags],\n );\n\n const addDelimited = useCallback(\n (rawValue: string, event?: ChangeEvent<HTMLInputElement>) => {\n const separator =\n typeof delimiter === \"string\" && delimiter.length === 0 ? /\\r?\\n/u : delimiter;\n const values = rawValue\n .split(separator)\n .map((value) => value.trim())\n .filter(Boolean);\n const nextTags = [...selectedTags];\n for (const value of values) {\n const isAllowed = data.length === 0 || data.includes(value);\n if (isAllowed && (allowDuplicates || !nextTags.includes(value))) nextTags.push(value);\n }\n if (nextTags.length !== selectedTags.length) updateTags(nextTags);\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, delimiter, selectedTags, updateTags],\n );\n\n const suggestions = useMemo(() => {\n const query = inputValue.trim().toLocaleLowerCase();\n return data.filter(\n (item) =>\n !selectedTags.includes(item) &&\n (query.length === 0 || item.toLocaleLowerCase().includes(query)),\n );\n }, [data, inputValue, selectedTags]);\n\n function handleChange(event: ChangeEvent<HTMLInputElement>) {\n const nextValue = event.currentTarget.value;\n if (nextValue.trim() === \"\") {\n clearInput(event);\n onChange?.(event);\n return;\n }\n\n if (!composing && hasDelimiter(nextValue, delimiter)) {\n addDelimited(nextValue, event);\n return;\n }\n\n if (controlledInputValue === undefined) setUncontrolledInputValue(nextValue);\n onInputValueChange?.(nextValue);\n onChange?.(event);\n }\n\n function handleBlur(event: FocusEvent<HTMLInputElement>) {\n setFocused(false);\n onBlur?.(event);\n }\n\n function handlePaste(event: ClipboardEvent<HTMLInputElement>) {\n const pasted = event.clipboardData.getData(\"text\");\n if (!pasted || (!hasDelimiter(pasted, delimiter) && !pasted.includes(\"\\n\"))) return;\n event.preventDefault();\n addDelimited(pasted);\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n if (event.nativeEvent.isComposing || composing) return;\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (inputValue.trim()) addTag(inputValue);\n else if (editingTag) setEditingTag(null);\n } else if (event.key === \"Escape\" && editingTag) {\n event.preventDefault();\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n editingTag.value,\n ...selectedTags.slice(editingTag.index),\n ]);\n clearInput();\n setEditingTag(null);\n } else if (event.key === \"Backspace\" && !inputValue && editable && selectedTags.length > 0) {\n const index = selectedTags.length - 1;\n const tag = selectedTags[index];\n if (tag === undefined) return;\n setEditingTag({ index, value: tag });\n updateTags(selectedTags.slice(0, -1));\n if (controlledInputValue === undefined) setUncontrolledInputValue(tag);\n onInputValueChange?.(tag);\n }\n props.onKeyDown?.(event);\n }\n\n function removeTag(index: number) {\n updateTags(selectedTags.filter((_, currentIndex) => currentIndex !== index));\n }\n\n return (\n <div\n className={styles.root}\n data-jaci-component=\"tags-input\"\n data-slot=\"tags-input\"\n ref={rootRef}\n >\n {label ? (\n <label className={styles.label} data-slot=\"tags-input-label\" htmlFor={id}>\n {label}\n </label>\n ) : null}\n <div\n className={cx(styles.control, className)}\n data-disabled={disabled || undefined}\n data-focus={focused || undefined}\n data-slot=\"tags-input-control\"\n >\n <div className={styles.tagList} data-slot=\"tags-input-tag-list\">\n {selectedTags.map((tag, index) => (\n <span className={styles.tag} data-slot=\"tags-input-tag\" key={tagKey(tag, index)}>\n <span className={styles.tagLabel} data-slot=\"tags-input-tag-label\">\n {tag}\n </span>\n <button\n aria-label={`Remove ${tag}`}\n className={styles.tagRemove}\n data-slot=\"tags-input-tag-remove\"\n disabled={disabled}\n onClick={() => removeTag(index)}\n type=\"button\"\n >\n ×\n </button>\n </span>\n ))}\n </div>\n <input\n {...props}\n {...(ariaDescribedBy ? { \"aria-describedby\": ariaDescribedBy } : {})}\n {...(ariaInvalid !== undefined ? { \"aria-invalid\": ariaInvalid } : {})}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n autoComplete=\"off\"\n className={styles.input}\n disabled={disabled}\n id={id}\n onBlur={handleBlur}\n onChange={handleChange}\n onCompositionEnd={() => setComposing(false)}\n onCompositionStart={() => setComposing(true)}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={ref}\n type=\"text\"\n value={inputValue}\n />\n </div>\n {focused && data.length > 0 ? (\n <div className={styles.positioner} data-slot=\"tags-input-positioner\">\n <div\n aria-label=\"Suggestions\"\n className={styles.list}\n data-slot=\"tags-input-list\"\n role=\"listbox\"\n >\n {suggestions.length > 0 ? (\n suggestions.map((item) => (\n <button\n aria-selected={false}\n className={styles.item}\n data-slot=\"tags-input-item\"\n key={item}\n onClick={() => addTag(item)}\n onMouseDown={(event: MouseEvent<HTMLButtonElement>) => event.preventDefault()}\n role=\"option\"\n type=\"button\"\n >\n {item}\n </button>\n ))\n ) : (\n <div className={styles.empty} data-slot=\"tags-input-empty\">\n No options\n </div>\n )}\n </div>\n </div>\n ) : null}\n </div>\n );\n});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U;MAEV,eAAe,OAAO,IAAI;MAC1B,cAAc,UAAyC,MAAM,eAAe;MAC5E,MAAK;MACL,MAAK;MAEJ,UAAA;KACK,GAPD,IAOC,CACT,IAED,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;MAAK,WAAW,OAAO;MAAO,aAAU;MAAmB,UAAA;KAEtD,CAAA;IAEJ,CAAA;GACF,CAAA,IACH;EACD;;AAET,CAAC"}
1
+ {"version":3,"file":"tags-input.cjs","names":["forwardRef","useId","useState","useRef","tagsInput","useCallback","useMemo","cx"],"sources":["../../../src/components/tags-input/tags-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport type {\n ChangeEvent,\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ClipboardEvent,\n ReactNode,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { tagsInput } from \"../../styled-system/recipes\";\n\nexport interface TagsInputProps\n extends Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"children\" | \"defaultValue\" | \"onChange\" | \"type\" | \"value\"\n > {\n /** Current tags. Omit this prop to use the uncontrolled API. */\n tags?: readonly string[];\n /** Initial tags for the uncontrolled API. */\n defaultTags?: readonly string[];\n /** Called whenever a tag is added or removed. */\n onTagsChange?: (tags: string[]) => void;\n /** Optional suggestions. A tag is accepted after a comma only when it is in this list. */\n data?: readonly string[];\n /** Visible label for the input. */\n label?: ReactNode;\n /** Current text query. This is the native input value, not the selected tags. */\n value?: string;\n /** Initial text query for an uncontrolled input. */\n defaultValue?: string;\n /** Native input change callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Optional callback useful when a controlled query is cleared by selecting a tag. */\n onInputValueChange?: (value: string) => void;\n allowDuplicates?: boolean;\n delimiter?: string | RegExp;\n editable?: boolean;\n}\n\nfunction changedEvent(event: ChangeEvent<HTMLInputElement>, value: string) {\n const target = event.target;\n const nextTarget = {\n checked: target.checked,\n id: target.id,\n name: target.name,\n value,\n } as HTMLInputElement;\n\n return {\n ...event,\n currentTarget: nextTarget,\n target: nextTarget,\n } as ChangeEvent<HTMLInputElement>;\n}\n\nfunction tagKey(tag: string, index: number) {\n return `${tag}-${index}`;\n}\n\nfunction hasDelimiter(value: string, delimiter: string | RegExp) {\n if (typeof delimiter === \"string\") return delimiter.length > 0 && value.includes(delimiter);\n delimiter.lastIndex = 0;\n const result = delimiter.test(value);\n delimiter.lastIndex = 0;\n return result;\n}\n\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-label\": ariaLabel,\n allowDuplicates = false,\n className,\n data = [],\n defaultTags = [],\n defaultValue = \"\",\n disabled = false,\n delimiter = /[,\\n]/u,\n editable = false,\n id: providedId,\n label,\n onBlur,\n onChange,\n onFocus,\n onInputValueChange,\n onTagsChange,\n placeholder,\n tags: controlledTags,\n value: controlledInputValue,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const id = providedId ?? generatedId;\n const [uncontrolledTags, setUncontrolledTags] = useState<string[]>(() => [...defaultTags]);\n const [uncontrolledInputValue, setUncontrolledInputValue] = useState(defaultValue);\n const [focused, setFocused] = useState(false);\n const [composing, setComposing] = useState(false);\n const [editingTag, setEditingTag] = useState<{ index: number; value: string } | null>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const styles = tagsInput();\n const selectedTags = controlledTags === undefined ? uncontrolledTags : [...controlledTags];\n const inputValue =\n controlledInputValue === undefined ? uncontrolledInputValue : controlledInputValue;\n\n const updateTags = useCallback(\n (nextTags: string[]) => {\n if (controlledTags === undefined) setUncontrolledTags(nextTags);\n onTagsChange?.(nextTags);\n },\n [controlledTags, onTagsChange],\n );\n\n const clearInput = useCallback(\n (event?: ChangeEvent<HTMLInputElement>) => {\n if (controlledInputValue === undefined) setUncontrolledInputValue(\"\");\n onInputValueChange?.(\"\");\n if (event) onChange?.(changedEvent(event, \"\"));\n },\n [controlledInputValue, onChange, onInputValueChange],\n );\n\n const addTag = useCallback(\n (rawTag: string, event?: ChangeEvent<HTMLInputElement>) => {\n const tag = rawTag.trim();\n const isAllowed = data.length === 0 || data.includes(tag);\n const duplicate = selectedTags.includes(tag);\n if (tag && isAllowed && (allowDuplicates || !duplicate)) {\n if (editingTag) {\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n tag,\n ...selectedTags.slice(editingTag.index),\n ]);\n setEditingTag(null);\n } else {\n updateTags([...selectedTags, tag]);\n }\n } else if (editingTag) {\n return;\n }\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, editingTag, selectedTags, updateTags],\n );\n\n const addDelimited = useCallback(\n (rawValue: string, event?: ChangeEvent<HTMLInputElement>) => {\n const separator =\n typeof delimiter === \"string\" && delimiter.length === 0 ? /\\r?\\n/u : delimiter;\n const values = rawValue\n .split(separator)\n .map((value) => value.trim())\n .filter(Boolean);\n const nextTags = [...selectedTags];\n for (const value of values) {\n const isAllowed = data.length === 0 || data.includes(value);\n if (isAllowed && (allowDuplicates || !nextTags.includes(value))) nextTags.push(value);\n }\n if (nextTags.length !== selectedTags.length) updateTags(nextTags);\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, delimiter, selectedTags, updateTags],\n );\n\n const suggestions = useMemo(() => {\n const query = inputValue.trim().toLocaleLowerCase();\n return data.filter(\n (item) =>\n !selectedTags.includes(item) &&\n (query.length === 0 || item.toLocaleLowerCase().includes(query)),\n );\n }, [data, inputValue, selectedTags]);\n\n function handleChange(event: ChangeEvent<HTMLInputElement>) {\n const nextValue = event.currentTarget.value;\n if (nextValue.trim() === \"\") {\n clearInput(event);\n onChange?.(event);\n return;\n }\n\n if (!composing && hasDelimiter(nextValue, delimiter)) {\n addDelimited(nextValue, event);\n return;\n }\n\n if (controlledInputValue === undefined) setUncontrolledInputValue(nextValue);\n onInputValueChange?.(nextValue);\n onChange?.(event);\n }\n\n function handleBlur(event: FocusEvent<HTMLInputElement>) {\n setFocused(false);\n onBlur?.(event);\n }\n\n function handlePaste(event: ClipboardEvent<HTMLInputElement>) {\n const pasted = event.clipboardData.getData(\"text\");\n if (!pasted || (!hasDelimiter(pasted, delimiter) && !pasted.includes(\"\\n\"))) return;\n event.preventDefault();\n addDelimited(pasted);\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n if (event.nativeEvent.isComposing || composing) return;\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (inputValue.trim()) addTag(inputValue);\n else if (editingTag) setEditingTag(null);\n } else if (event.key === \"Escape\" && editingTag) {\n event.preventDefault();\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n editingTag.value,\n ...selectedTags.slice(editingTag.index),\n ]);\n clearInput();\n setEditingTag(null);\n } else if (event.key === \"Backspace\" && !inputValue && editable && selectedTags.length > 0) {\n const index = selectedTags.length - 1;\n const tag = selectedTags[index];\n if (tag === undefined) return;\n setEditingTag({ index, value: tag });\n updateTags(selectedTags.slice(0, -1));\n if (controlledInputValue === undefined) setUncontrolledInputValue(tag);\n onInputValueChange?.(tag);\n }\n props.onKeyDown?.(event);\n }\n\n function removeTag(index: number) {\n updateTags(selectedTags.filter((_, currentIndex) => currentIndex !== index));\n }\n\n return (\n <div\n className={styles.root}\n data-jaci-component=\"tags-input\"\n data-slot=\"tags-input\"\n ref={rootRef}\n >\n {label ? (\n <label className={styles.label} data-slot=\"tags-input-label\" htmlFor={id}>\n {label}\n </label>\n ) : null}\n <div\n className={cx(styles.control, className)}\n data-disabled={disabled || undefined}\n data-focus={focused || undefined}\n data-slot=\"tags-input-control\"\n >\n <div className={styles.tagList} data-slot=\"tags-input-tag-list\">\n {selectedTags.map((tag, index) => (\n <span className={styles.tag} data-slot=\"tags-input-tag\" key={tagKey(tag, index)}>\n <span className={styles.tagLabel} data-slot=\"tags-input-tag-label\">\n {tag}\n </span>\n <button\n aria-label={`Remove ${tag}`}\n className={styles.tagRemove}\n data-slot=\"tags-input-tag-remove\"\n disabled={disabled}\n onClick={() => removeTag(index)}\n type=\"button\"\n >\n ×\n </button>\n </span>\n ))}\n </div>\n <input\n {...props}\n {...(ariaDescribedBy ? { \"aria-describedby\": ariaDescribedBy } : {})}\n {...(ariaInvalid !== undefined ? { \"aria-invalid\": ariaInvalid } : {})}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n autoComplete=\"off\"\n className={styles.input}\n disabled={disabled}\n id={id}\n onBlur={handleBlur}\n onChange={handleChange}\n onCompositionEnd={() => setComposing(false)}\n onCompositionStart={() => setComposing(true)}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={ref}\n type=\"text\"\n value={inputValue}\n />\n </div>\n {focused && data.length > 0 ? (\n <div className={styles.positioner} data-slot=\"tags-input-positioner\">\n <div\n aria-label=\"Suggestions\"\n className={styles.list}\n data-slot=\"tags-input-list\"\n role=\"listbox\"\n >\n {suggestions.length > 0 ? (\n suggestions.map((item) => (\n <button\n aria-selected={false}\n className={styles.item}\n data-slot=\"tags-input-item\"\n key={item}\n onClick={() => addTag(item)}\n onMouseDown={(event: MouseEvent<HTMLButtonElement>) => event.preventDefault()}\n role=\"option\"\n type=\"button\"\n >\n {item}\n </button>\n ))\n ) : (\n <div className={styles.empty} data-slot=\"tags-input-empty\">\n No options\n </div>\n )}\n </div>\n </div>\n ) : null}\n </div>\n );\n});\n"],"mappings":";;;;;;AA6CA,SAAS,aAAa,OAAsC,OAAe;CACzE,MAAM,SAAS,MAAM;CACrB,MAAM,aAAa;EACjB,SAAS,OAAO;EAChB,IAAI,OAAO;EACX,MAAM,OAAO;EACb;CACF;CAEA,OAAO;EACL,GAAG;EACH,eAAe;EACf,QAAQ;CACV;AACF;AAEA,SAAS,OAAO,KAAa,OAAe;CAC1C,OAAO,GAAG,IAAI,GAAG;AACnB;AAEA,SAAS,aAAa,OAAe,WAA4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Ref(function TagsInput({ "aria-describedby": ariaDescri
57
57
  const tag = rawTag.trim();
58
58
  const isAllowed = data.length === 0 || data.includes(tag);
59
59
  const duplicate = selectedTags.includes(tag);
60
- if (tag && isAllowed && (allowDuplicates || !duplicate)) if (editingTag) {
61
- updateTags([
62
- ...selectedTags.slice(0, editingTag.index),
63
- tag,
64
- ...selectedTags.slice(editingTag.index)
65
- ]);
66
- setEditingTag(null);
67
- } else updateTags([...selectedTags, tag]);
68
- else if (editingTag) return;
60
+ if (tag && isAllowed && (allowDuplicates || !duplicate)) {
61
+ if (editingTag) {
62
+ updateTags([
63
+ ...selectedTags.slice(0, editingTag.index),
64
+ tag,
65
+ ...selectedTags.slice(editingTag.index)
66
+ ]);
67
+ setEditingTag(null);
68
+ } else updateTags([...selectedTags, tag]);
69
+ } else if (editingTag) return;
69
70
  clearInput(event);
70
71
  }, [
71
72
  allowDuplicates,
@@ -1 +1 @@
1
- {"version":3,"file":"tags-input.js","names":[],"sources":["../../../src/components/tags-input/tags-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport type {\n ChangeEvent,\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ClipboardEvent,\n ReactNode,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { tagsInput } from \"../../styled-system/recipes\";\n\nexport interface TagsInputProps\n extends Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"children\" | \"defaultValue\" | \"onChange\" | \"type\" | \"value\"\n > {\n /** Current tags. Omit this prop to use the uncontrolled API. */\n tags?: readonly string[];\n /** Initial tags for the uncontrolled API. */\n defaultTags?: readonly string[];\n /** Called whenever a tag is added or removed. */\n onTagsChange?: (tags: string[]) => void;\n /** Optional suggestions. A tag is accepted after a comma only when it is in this list. */\n data?: readonly string[];\n /** Visible label for the input. */\n label?: ReactNode;\n /** Current text query. This is the native input value, not the selected tags. */\n value?: string;\n /** Initial text query for an uncontrolled input. */\n defaultValue?: string;\n /** Native input change callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Optional callback useful when a controlled query is cleared by selecting a tag. */\n onInputValueChange?: (value: string) => void;\n allowDuplicates?: boolean;\n delimiter?: string | RegExp;\n editable?: boolean;\n}\n\nfunction changedEvent(event: ChangeEvent<HTMLInputElement>, value: string) {\n const target = event.target;\n const nextTarget = {\n checked: target.checked,\n id: target.id,\n name: target.name,\n value,\n } as HTMLInputElement;\n\n return {\n ...event,\n currentTarget: nextTarget,\n target: nextTarget,\n } as ChangeEvent<HTMLInputElement>;\n}\n\nfunction tagKey(tag: string, index: number) {\n return `${tag}-${index}`;\n}\n\nfunction hasDelimiter(value: string, delimiter: string | RegExp) {\n if (typeof delimiter === \"string\") return delimiter.length > 0 && value.includes(delimiter);\n delimiter.lastIndex = 0;\n const result = delimiter.test(value);\n delimiter.lastIndex = 0;\n return result;\n}\n\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-label\": ariaLabel,\n allowDuplicates = false,\n className,\n data = [],\n defaultTags = [],\n defaultValue = \"\",\n disabled = false,\n delimiter = /[,\\n]/u,\n editable = false,\n id: providedId,\n label,\n onBlur,\n onChange,\n onFocus,\n onInputValueChange,\n onTagsChange,\n placeholder,\n tags: controlledTags,\n value: controlledInputValue,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const id = providedId ?? generatedId;\n const [uncontrolledTags, setUncontrolledTags] = useState<string[]>(() => [...defaultTags]);\n const [uncontrolledInputValue, setUncontrolledInputValue] = useState(defaultValue);\n const [focused, setFocused] = useState(false);\n const [composing, setComposing] = useState(false);\n const [editingTag, setEditingTag] = useState<{ index: number; value: string } | null>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const styles = tagsInput();\n const selectedTags = controlledTags === undefined ? uncontrolledTags : [...controlledTags];\n const inputValue =\n controlledInputValue === undefined ? uncontrolledInputValue : controlledInputValue;\n\n const updateTags = useCallback(\n (nextTags: string[]) => {\n if (controlledTags === undefined) setUncontrolledTags(nextTags);\n onTagsChange?.(nextTags);\n },\n [controlledTags, onTagsChange],\n );\n\n const clearInput = useCallback(\n (event?: ChangeEvent<HTMLInputElement>) => {\n if (controlledInputValue === undefined) setUncontrolledInputValue(\"\");\n onInputValueChange?.(\"\");\n if (event) onChange?.(changedEvent(event, \"\"));\n },\n [controlledInputValue, onChange, onInputValueChange],\n );\n\n const addTag = useCallback(\n (rawTag: string, event?: ChangeEvent<HTMLInputElement>) => {\n const tag = rawTag.trim();\n const isAllowed = data.length === 0 || data.includes(tag);\n const duplicate = selectedTags.includes(tag);\n if (tag && isAllowed && (allowDuplicates || !duplicate)) {\n if (editingTag) {\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n tag,\n ...selectedTags.slice(editingTag.index),\n ]);\n setEditingTag(null);\n } else {\n updateTags([...selectedTags, tag]);\n }\n } else if (editingTag) {\n return;\n }\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, editingTag, selectedTags, updateTags],\n );\n\n const addDelimited = useCallback(\n (rawValue: string, event?: ChangeEvent<HTMLInputElement>) => {\n const separator =\n typeof delimiter === \"string\" && delimiter.length === 0 ? /\\r?\\n/u : delimiter;\n const values = rawValue\n .split(separator)\n .map((value) => value.trim())\n .filter(Boolean);\n const nextTags = [...selectedTags];\n for (const value of values) {\n const isAllowed = data.length === 0 || data.includes(value);\n if (isAllowed && (allowDuplicates || !nextTags.includes(value))) nextTags.push(value);\n }\n if (nextTags.length !== selectedTags.length) updateTags(nextTags);\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, delimiter, selectedTags, updateTags],\n );\n\n const suggestions = useMemo(() => {\n const query = inputValue.trim().toLocaleLowerCase();\n return data.filter(\n (item) =>\n !selectedTags.includes(item) &&\n (query.length === 0 || item.toLocaleLowerCase().includes(query)),\n );\n }, [data, inputValue, selectedTags]);\n\n function handleChange(event: ChangeEvent<HTMLInputElement>) {\n const nextValue = event.currentTarget.value;\n if (nextValue.trim() === \"\") {\n clearInput(event);\n onChange?.(event);\n return;\n }\n\n if (!composing && hasDelimiter(nextValue, delimiter)) {\n addDelimited(nextValue, event);\n return;\n }\n\n if (controlledInputValue === undefined) setUncontrolledInputValue(nextValue);\n onInputValueChange?.(nextValue);\n onChange?.(event);\n }\n\n function handleBlur(event: FocusEvent<HTMLInputElement>) {\n setFocused(false);\n onBlur?.(event);\n }\n\n function handlePaste(event: ClipboardEvent<HTMLInputElement>) {\n const pasted = event.clipboardData.getData(\"text\");\n if (!pasted || (!hasDelimiter(pasted, delimiter) && !pasted.includes(\"\\n\"))) return;\n event.preventDefault();\n addDelimited(pasted);\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n if (event.nativeEvent.isComposing || composing) return;\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (inputValue.trim()) addTag(inputValue);\n else if (editingTag) setEditingTag(null);\n } else if (event.key === \"Escape\" && editingTag) {\n event.preventDefault();\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n editingTag.value,\n ...selectedTags.slice(editingTag.index),\n ]);\n clearInput();\n setEditingTag(null);\n } else if (event.key === \"Backspace\" && !inputValue && editable && selectedTags.length > 0) {\n const index = selectedTags.length - 1;\n const tag = selectedTags[index];\n if (tag === undefined) return;\n setEditingTag({ index, value: tag });\n updateTags(selectedTags.slice(0, -1));\n if (controlledInputValue === undefined) setUncontrolledInputValue(tag);\n onInputValueChange?.(tag);\n }\n props.onKeyDown?.(event);\n }\n\n function removeTag(index: number) {\n updateTags(selectedTags.filter((_, currentIndex) => currentIndex !== index));\n }\n\n return (\n <div\n className={styles.root}\n data-jaci-component=\"tags-input\"\n data-slot=\"tags-input\"\n ref={rootRef}\n >\n {label ? (\n <label className={styles.label} data-slot=\"tags-input-label\" htmlFor={id}>\n {label}\n </label>\n ) : null}\n <div\n className={cx(styles.control, className)}\n data-disabled={disabled || undefined}\n data-focus={focused || undefined}\n data-slot=\"tags-input-control\"\n >\n <div className={styles.tagList} data-slot=\"tags-input-tag-list\">\n {selectedTags.map((tag, index) => (\n <span className={styles.tag} data-slot=\"tags-input-tag\" key={tagKey(tag, index)}>\n <span className={styles.tagLabel} data-slot=\"tags-input-tag-label\">\n {tag}\n </span>\n <button\n aria-label={`Remove ${tag}`}\n className={styles.tagRemove}\n data-slot=\"tags-input-tag-remove\"\n disabled={disabled}\n onClick={() => removeTag(index)}\n type=\"button\"\n >\n ×\n </button>\n </span>\n ))}\n </div>\n <input\n {...props}\n {...(ariaDescribedBy ? { \"aria-describedby\": ariaDescribedBy } : {})}\n {...(ariaInvalid !== undefined ? { \"aria-invalid\": ariaInvalid } : {})}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n autoComplete=\"off\"\n className={styles.input}\n disabled={disabled}\n id={id}\n onBlur={handleBlur}\n onChange={handleChange}\n onCompositionEnd={() => setComposing(false)}\n onCompositionStart={() => setComposing(true)}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={ref}\n type=\"text\"\n value={inputValue}\n />\n </div>\n {focused && data.length > 0 ? (\n <div className={styles.positioner} data-slot=\"tags-input-positioner\">\n <div\n aria-label=\"Suggestions\"\n className={styles.list}\n data-slot=\"tags-input-list\"\n role=\"listbox\"\n >\n {suggestions.length > 0 ? (\n suggestions.map((item) => (\n <button\n aria-selected={false}\n className={styles.item}\n data-slot=\"tags-input-item\"\n key={item}\n onClick={() => addTag(item)}\n onMouseDown={(event: MouseEvent<HTMLButtonElement>) => event.preventDefault()}\n role=\"option\"\n type=\"button\"\n >\n {item}\n </button>\n ))\n ) : (\n <div className={styles.empty} data-slot=\"tags-input-empty\">\n No options\n </div>\n )}\n </div>\n </div>\n ) : null}\n </div>\n );\n});\n"],"mappings":";;;;;;AA6CA,SAAS,aAAa,OAAsC,OA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KAClE,GAAK,gBAAgB,KAAA,IAAY,EAAE,gBAAgB,YAAY,IAAI,CAAC;KACpE,GAAK,YAAY,EAAE,cAAc,UAAU,IAAI,CAAC;KAChD,cAAa;KACb,WAAW,OAAO;KACR;KACN;KACJ,QAAQ;KACR,UAAU;KACV,wBAAwB,aAAa,KAAK;KAC1C,0BAA0B,aAAa,IAAI;KAC3C,UAAU,UAAU;MAClB,WAAW,IAAI;MACf,UAAU,KAAK;KACjB;KACA,WAAW;KACX,SAAS;KACI;KACR;KACL,MAAK;KACL,OAAO;IACR,CAAA,CACE;;GACJ,WAAW,KAAK,SAAS,IACxB,oBAAC,OAAD;IAAK,WAAW,OAAO;IAAY,aAAU;IAC3C,UAAA,oBAAC,OAAD;KACE,cAAW;KACX,WAAW,OAAO;KAClB,aAAU;KACV,MAAK;KAEJ,UAAA,YAAY,SAAS,IACpB,YAAY,KAAK,SACf,oBAAC,UAAD;MACE,iBAAe;MACf,WAAW,OAAO;MAClB,aAAU;MAEV,eAAe,OAAO,IAAI;MAC1B,cAAc,UAAyC,MAAM,eAAe;MAC5E,MAAK;MACL,MAAK;MAEJ,UAAA;KACK,GAPD,IAOC,CACT,IAED,oBAAC,OAAD;MAAK,WAAW,OAAO;MAAO,aAAU;MAAmB,UAAA;KAEtD,CAAA;IAEJ,CAAA;GACF,CAAA,IACH;EACD;;AAET,CAAC"}
1
+ {"version":3,"file":"tags-input.js","names":[],"sources":["../../../src/components/tags-input/tags-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport type {\n ChangeEvent,\n ChangeEventHandler,\n ComponentPropsWithoutRef,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ClipboardEvent,\n ReactNode,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { tagsInput } from \"../../styled-system/recipes\";\n\nexport interface TagsInputProps\n extends Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"children\" | \"defaultValue\" | \"onChange\" | \"type\" | \"value\"\n > {\n /** Current tags. Omit this prop to use the uncontrolled API. */\n tags?: readonly string[];\n /** Initial tags for the uncontrolled API. */\n defaultTags?: readonly string[];\n /** Called whenever a tag is added or removed. */\n onTagsChange?: (tags: string[]) => void;\n /** Optional suggestions. A tag is accepted after a comma only when it is in this list. */\n data?: readonly string[];\n /** Visible label for the input. */\n label?: ReactNode;\n /** Current text query. This is the native input value, not the selected tags. */\n value?: string;\n /** Initial text query for an uncontrolled input. */\n defaultValue?: string;\n /** Native input change callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Optional callback useful when a controlled query is cleared by selecting a tag. */\n onInputValueChange?: (value: string) => void;\n allowDuplicates?: boolean;\n delimiter?: string | RegExp;\n editable?: boolean;\n}\n\nfunction changedEvent(event: ChangeEvent<HTMLInputElement>, value: string) {\n const target = event.target;\n const nextTarget = {\n checked: target.checked,\n id: target.id,\n name: target.name,\n value,\n } as HTMLInputElement;\n\n return {\n ...event,\n currentTarget: nextTarget,\n target: nextTarget,\n } as ChangeEvent<HTMLInputElement>;\n}\n\nfunction tagKey(tag: string, index: number) {\n return `${tag}-${index}`;\n}\n\nfunction hasDelimiter(value: string, delimiter: string | RegExp) {\n if (typeof delimiter === \"string\") return delimiter.length > 0 && value.includes(delimiter);\n delimiter.lastIndex = 0;\n const result = delimiter.test(value);\n delimiter.lastIndex = 0;\n return result;\n}\n\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n \"aria-label\": ariaLabel,\n allowDuplicates = false,\n className,\n data = [],\n defaultTags = [],\n defaultValue = \"\",\n disabled = false,\n delimiter = /[,\\n]/u,\n editable = false,\n id: providedId,\n label,\n onBlur,\n onChange,\n onFocus,\n onInputValueChange,\n onTagsChange,\n placeholder,\n tags: controlledTags,\n value: controlledInputValue,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const id = providedId ?? generatedId;\n const [uncontrolledTags, setUncontrolledTags] = useState<string[]>(() => [...defaultTags]);\n const [uncontrolledInputValue, setUncontrolledInputValue] = useState(defaultValue);\n const [focused, setFocused] = useState(false);\n const [composing, setComposing] = useState(false);\n const [editingTag, setEditingTag] = useState<{ index: number; value: string } | null>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const styles = tagsInput();\n const selectedTags = controlledTags === undefined ? uncontrolledTags : [...controlledTags];\n const inputValue =\n controlledInputValue === undefined ? uncontrolledInputValue : controlledInputValue;\n\n const updateTags = useCallback(\n (nextTags: string[]) => {\n if (controlledTags === undefined) setUncontrolledTags(nextTags);\n onTagsChange?.(nextTags);\n },\n [controlledTags, onTagsChange],\n );\n\n const clearInput = useCallback(\n (event?: ChangeEvent<HTMLInputElement>) => {\n if (controlledInputValue === undefined) setUncontrolledInputValue(\"\");\n onInputValueChange?.(\"\");\n if (event) onChange?.(changedEvent(event, \"\"));\n },\n [controlledInputValue, onChange, onInputValueChange],\n );\n\n const addTag = useCallback(\n (rawTag: string, event?: ChangeEvent<HTMLInputElement>) => {\n const tag = rawTag.trim();\n const isAllowed = data.length === 0 || data.includes(tag);\n const duplicate = selectedTags.includes(tag);\n if (tag && isAllowed && (allowDuplicates || !duplicate)) {\n if (editingTag) {\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n tag,\n ...selectedTags.slice(editingTag.index),\n ]);\n setEditingTag(null);\n } else {\n updateTags([...selectedTags, tag]);\n }\n } else if (editingTag) {\n return;\n }\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, editingTag, selectedTags, updateTags],\n );\n\n const addDelimited = useCallback(\n (rawValue: string, event?: ChangeEvent<HTMLInputElement>) => {\n const separator =\n typeof delimiter === \"string\" && delimiter.length === 0 ? /\\r?\\n/u : delimiter;\n const values = rawValue\n .split(separator)\n .map((value) => value.trim())\n .filter(Boolean);\n const nextTags = [...selectedTags];\n for (const value of values) {\n const isAllowed = data.length === 0 || data.includes(value);\n if (isAllowed && (allowDuplicates || !nextTags.includes(value))) nextTags.push(value);\n }\n if (nextTags.length !== selectedTags.length) updateTags(nextTags);\n clearInput(event);\n },\n [allowDuplicates, clearInput, data, delimiter, selectedTags, updateTags],\n );\n\n const suggestions = useMemo(() => {\n const query = inputValue.trim().toLocaleLowerCase();\n return data.filter(\n (item) =>\n !selectedTags.includes(item) &&\n (query.length === 0 || item.toLocaleLowerCase().includes(query)),\n );\n }, [data, inputValue, selectedTags]);\n\n function handleChange(event: ChangeEvent<HTMLInputElement>) {\n const nextValue = event.currentTarget.value;\n if (nextValue.trim() === \"\") {\n clearInput(event);\n onChange?.(event);\n return;\n }\n\n if (!composing && hasDelimiter(nextValue, delimiter)) {\n addDelimited(nextValue, event);\n return;\n }\n\n if (controlledInputValue === undefined) setUncontrolledInputValue(nextValue);\n onInputValueChange?.(nextValue);\n onChange?.(event);\n }\n\n function handleBlur(event: FocusEvent<HTMLInputElement>) {\n setFocused(false);\n onBlur?.(event);\n }\n\n function handlePaste(event: ClipboardEvent<HTMLInputElement>) {\n const pasted = event.clipboardData.getData(\"text\");\n if (!pasted || (!hasDelimiter(pasted, delimiter) && !pasted.includes(\"\\n\"))) return;\n event.preventDefault();\n addDelimited(pasted);\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n if (event.nativeEvent.isComposing || composing) return;\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (inputValue.trim()) addTag(inputValue);\n else if (editingTag) setEditingTag(null);\n } else if (event.key === \"Escape\" && editingTag) {\n event.preventDefault();\n updateTags([\n ...selectedTags.slice(0, editingTag.index),\n editingTag.value,\n ...selectedTags.slice(editingTag.index),\n ]);\n clearInput();\n setEditingTag(null);\n } else if (event.key === \"Backspace\" && !inputValue && editable && selectedTags.length > 0) {\n const index = selectedTags.length - 1;\n const tag = selectedTags[index];\n if (tag === undefined) return;\n setEditingTag({ index, value: tag });\n updateTags(selectedTags.slice(0, -1));\n if (controlledInputValue === undefined) setUncontrolledInputValue(tag);\n onInputValueChange?.(tag);\n }\n props.onKeyDown?.(event);\n }\n\n function removeTag(index: number) {\n updateTags(selectedTags.filter((_, currentIndex) => currentIndex !== index));\n }\n\n return (\n <div\n className={styles.root}\n data-jaci-component=\"tags-input\"\n data-slot=\"tags-input\"\n ref={rootRef}\n >\n {label ? (\n <label className={styles.label} data-slot=\"tags-input-label\" htmlFor={id}>\n {label}\n </label>\n ) : null}\n <div\n className={cx(styles.control, className)}\n data-disabled={disabled || undefined}\n data-focus={focused || undefined}\n data-slot=\"tags-input-control\"\n >\n <div className={styles.tagList} data-slot=\"tags-input-tag-list\">\n {selectedTags.map((tag, index) => (\n <span className={styles.tag} data-slot=\"tags-input-tag\" key={tagKey(tag, index)}>\n <span className={styles.tagLabel} data-slot=\"tags-input-tag-label\">\n {tag}\n </span>\n <button\n aria-label={`Remove ${tag}`}\n className={styles.tagRemove}\n data-slot=\"tags-input-tag-remove\"\n disabled={disabled}\n onClick={() => removeTag(index)}\n type=\"button\"\n >\n ×\n </button>\n </span>\n ))}\n </div>\n <input\n {...props}\n {...(ariaDescribedBy ? { \"aria-describedby\": ariaDescribedBy } : {})}\n {...(ariaInvalid !== undefined ? { \"aria-invalid\": ariaInvalid } : {})}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n autoComplete=\"off\"\n className={styles.input}\n disabled={disabled}\n id={id}\n onBlur={handleBlur}\n onChange={handleChange}\n onCompositionEnd={() => setComposing(false)}\n onCompositionStart={() => setComposing(true)}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n ref={ref}\n type=\"text\"\n value={inputValue}\n />\n </div>\n {focused && data.length > 0 ? (\n <div className={styles.positioner} data-slot=\"tags-input-positioner\">\n <div\n aria-label=\"Suggestions\"\n className={styles.list}\n data-slot=\"tags-input-list\"\n role=\"listbox\"\n >\n {suggestions.length > 0 ? (\n suggestions.map((item) => (\n <button\n aria-selected={false}\n className={styles.item}\n data-slot=\"tags-input-item\"\n key={item}\n onClick={() => addTag(item)}\n onMouseDown={(event: MouseEvent<HTMLButtonElement>) => event.preventDefault()}\n role=\"option\"\n type=\"button\"\n >\n {item}\n </button>\n ))\n ) : (\n <div className={styles.empty} data-slot=\"tags-input-empty\">\n No options\n </div>\n )}\n </div>\n </div>\n ) : null}\n </div>\n );\n});\n"],"mappings":";;;;;;AA6CA,SAAS,aAAa,OAAsC,OAAe;CACzE,MAAM,SAAS,MAAM;CACrB,MAAM,aAAa;EACjB,SAAS,OAAO;EAChB,IAAI,OAAO;EACX,MAAM,OAAO;EACb;CACF;CAEA,OAAO;EACL,GAAG;EACH,eAAe;EACf,QAAQ;CACV;AACF;AAEA,SAAS,OAAO,KAAa,OAAe;CAC1C,OAAO,GAAG,IAAI,GAAG;AACnB;AAEA,SAAS,aAAa,OAAe,WAA4B;CAC/D,IAAI,OAAO,cAAc,UAAU,OAAO,UAAU,SAAS,KAAK,MAAM,SAAS,SAAS;CAC1F,UAAU,YAAY;CACtB,MAAM,SAAS,UAAU,KAAK,KAAK;CACnC,UAAU,YAAY;CACtB,OAAO;AACT;AAEA,MAAa,YAAY,WAA6C,SAAS,UAC7E,EACE,oBAAoB,iBACpB,gBAAgB,aAChB,cAAc,WACd,kBAAkB,OAClB,WACA,OAAO,CAAC,GACR,cAAc,CAAC,GACf,eAAe,IACf,WAAW,OACX,YAAY,UACZ,WAAW,OACX,IAAI,YACJ,OACA,QACA,UACA,SACA,oBACA,cACA,aACA,MAAM,gBACN,OAAO,sBACP,GAAG,SAEL,KACA;CACA,MAAM,cAAc,MAAM;CAC1B,MAAM,KAAK,cAAc;CACzB,MAAM,CAAC,kBAAkB,uBAAuB,eAAyB,CAAC,GAAG,WAAW,CAAC;CACzF,MAAM,CAAC,wBAAwB,6BAA6B,SAAS,YAAY;CACjF,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MA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UAAA;MACG,CAAA,GACN,oBAAC,UAAD;OACE,cAAY,UAAU;OACtB,WAAW,OAAO;OAClB,aAAU;OACA;OACV,eAAe,UAAU,KAAK;OAC9B,MAAK;OACN,UAAA;MAEO,CAAA,CACJ;KAduD,GAAA,OAAO,KAAK,KAAK,CAcxE,CACP;IACE,CAAA,GACL,oBAAC,SAAD;KACE,GAAI;KACJ,GAAK,kBAAkB,EAAE,oBAAoB,gBAAgB,IAAI,CAAC;KAClE,GAAK,gBAAgB,KAAA,IAAY,EAAE,gBAAgB,YAAY,IAAI,CAAC;KACpE,GAAK,YAAY,EAAE,cAAc,UAAU,IAAI,CAAC;KAChD,cAAa;KACb,WAAW,OAAO;KACR;KACN;KACJ,QAAQ;KACR,UAAU;KACV,wBAAwB,aAAa,KAAK;KAC1C,0BAA0B,aAAa,IAAI;KAC3C,UAAU,UAAU;MAClB,WAAW,IAAI;MACf,UAAU,KAAK;KACjB;KACA,WAAW;KACX,SAAS;KACI;KACR;KACL,MAAK;KACL,OAAO;IACR,CAAA,CACE;;GACJ,WAAW,KAAK,SAAS,IACxB,oBAAC,OAAD;IAAK,WAAW,OAAO;IAAY,aAAU;IAC3C,UAAA,oBAAC,OAAD;KACE,cAAW;KACX,WAAW,OAAO;KAClB,aAAU;KACV,MAAK;KAEJ,UAAA,YAAY,SAAS,IACpB,YAAY,KAAK,SACf,oBAAC,UAAD;MACE,iBAAe;MACf,WAAW,OAAO;MAClB,aAAU;MAEV,eAAe,OAAO,IAAI;MAC1B,cAAc,UAAyC,MAAM,eAAe;MAC5E,MAAK;MACL,MAAK;MAEJ,UAAA;KACK,GAPD,IAOC,CACT,IAED,oBAAC,OAAD;MAAK,WAAW,OAAO;MAAO,aAAU;MAAmB,UAAA;KAEtD,CAAA;IAEJ,CAAA;GACF,CAAA,IACH;EACD;;AAET,CAAC"}
@@ -68,48 +68,48 @@ const jaciTheme = { extend: {
68
68
  surface: {
69
69
  canvas: { value: {
70
70
  base: "{colors.neutral.50}",
71
- _dark: "{colors.neutral.950}"
71
+ dark: "{colors.neutral.950}"
72
72
  } },
73
73
  default: { value: {
74
74
  base: "{colors.neutral.100}",
75
- _dark: "{colors.neutral.900}"
75
+ dark: "{colors.neutral.900}"
76
76
  } },
77
77
  raised: { value: {
78
78
  base: "{colors.neutral.50}",
79
- _dark: "{colors.neutral.800}"
79
+ dark: "{colors.neutral.800}"
80
80
  } },
81
81
  subtle: { value: {
82
82
  base: "{colors.neutral.200}",
83
- _dark: "{colors.neutral.800}"
83
+ dark: "{colors.neutral.800}"
84
84
  } },
85
85
  overlay: { value: {
86
86
  base: "rgb(250 250 250 / 0.32)",
87
- _dark: "rgb(9 9 11 / 0.4)"
87
+ dark: "rgb(9 9 11 / 0.4)"
88
88
  } }
89
89
  },
90
90
  fg: {
91
91
  default: { value: {
92
92
  base: "{colors.neutral.900}",
93
- _dark: "{colors.neutral.100}"
93
+ dark: "{colors.neutral.100}"
94
94
  } },
95
95
  muted: { value: {
96
96
  base: "{colors.neutral.600}",
97
- _dark: "{colors.neutral.400}"
97
+ dark: "{colors.neutral.400}"
98
98
  } },
99
99
  onAccent: { value: "{colors.neutral.50}" }
100
100
  },
101
101
  border: {
102
102
  default: { value: {
103
103
  base: "{colors.neutral.300}",
104
- _dark: "{colors.neutral.700}"
104
+ dark: "{colors.neutral.700}"
105
105
  } },
106
106
  strong: { value: {
107
107
  base: "{colors.neutral.500}",
108
- _dark: "{colors.neutral.500}"
108
+ dark: "{colors.neutral.500}"
109
109
  } },
110
110
  interactive: { value: {
111
111
  base: "{colors.neutral.900}",
112
- _dark: "{colors.neutral.200}"
112
+ dark: "{colors.neutral.200}"
113
113
  } }
114
114
  },
115
115
  accent: {
@@ -123,39 +123,39 @@ const jaciTheme = { extend: {
123
123
  focus: { value: "{colors.blue.600}" },
124
124
  disabled: { value: {
125
125
  base: "{colors.neutral.400}",
126
- _dark: "{colors.neutral.600}"
126
+ dark: "{colors.neutral.600}"
127
127
  } },
128
128
  selected: { value: {
129
129
  base: "{colors.blue.50}",
130
- _dark: "{colors.blue.950}"
130
+ dark: "{colors.blue.950}"
131
131
  } },
132
132
  link: {
133
133
  default: { value: {
134
134
  base: "{colors.neutral.600}",
135
- _dark: "{colors.neutral.400}"
135
+ dark: "{colors.neutral.400}"
136
136
  } },
137
137
  hover: { value: {
138
138
  base: "{colors.neutral.900}",
139
- _dark: "{colors.neutral.200}"
139
+ dark: "{colors.neutral.200}"
140
140
  } }
141
141
  }
142
142
  },
143
143
  shadows: {
144
144
  sm: { value: {
145
145
  base: "0 1px 2px rgb(0 0 0 / 0.08)",
146
- _dark: "0 1px 2px rgb(255 255 255 / 0.08)"
146
+ dark: "0 1px 2px rgb(255 255 255 / 0.08)"
147
147
  } },
148
148
  md: { value: {
149
149
  base: "0 10px 24px rgb(0 0 0 / 0.12)",
150
- _dark: "0 10px 24px rgb(255 255 255 / 0.1)"
150
+ dark: "0 10px 24px rgb(255 255 255 / 0.1)"
151
151
  } },
152
152
  lg: { value: {
153
153
  base: "0 18px 42px rgb(0 0 0 / 0.16)",
154
- _dark: "0 18px 42px rgb(255 255 255 / 0.12)"
154
+ dark: "0 18px 42px rgb(255 255 255 / 0.12)"
155
155
  } },
156
156
  xl: { value: {
157
157
  base: "0 24px 52px rgb(0 0 0 / 0.2)",
158
- _dark: "0 24px 52px rgb(255 255 255 / 0.14)"
158
+ dark: "0 24px 52px rgb(255 255 255 / 0.14)"
159
159
  } }
160
160
  }
161
161
  },
@@ -1 +1 @@
1
- {"version":3,"file":"theme.cjs","names":[],"sources":["../../src/styles/theme.ts"],"sourcesContent":["export const jaciConditions = {\n extend: {\n dark: '[data-jaci-theme=\"dark\"] &',\n },\n};\n\nexport const jaciTheme = {\n extend: {\n tokens: {\n colors: {\n neutral: {\n 50: { value: \"#fafafa\" },\n 100: { value: \"#f4f4f5\" },\n 200: { value: \"#e4e4e7\" },\n 300: { value: \"#d4d4d8\" },\n 400: { value: \"#a1a1aa\" },\n 500: { value: \"#71717a\" },\n 600: { value: \"#52525b\" },\n 700: { value: \"#3f3f46\" },\n 800: { value: \"#27272a\" },\n 900: { value: \"#18181b\" },\n 950: { value: \"#09090b\" },\n },\n blue: {\n 500: { value: \"#3b82f6\" },\n 600: { value: \"#2563eb\" },\n 700: { value: \"#1d4ed8\" },\n },\n green: {\n 500: { value: \"#22c55e\" },\n 600: { value: \"#16a34a\" },\n 700: { value: \"#15803d\" },\n },\n amber: {\n 500: { value: \"#f59e0b\" },\n 600: { value: \"#d97706\" },\n 700: { value: \"#b45309\" },\n },\n red: {\n 500: { value: \"#ef4444\" },\n 600: { value: \"#dc2626\" },\n },\n },\n radii: {\n sm: { value: \"0.375rem\" },\n md: { value: \"0.75rem\" },\n lg: { value: \"1rem\" },\n xl: { value: \"1.5rem\" },\n \"2xl\": { value: \"2rem\" },\n full: { value: \"9999px\" },\n },\n shadows: {\n sm: { value: \"0 1px 2px rgb(0 0 0 / 0.08)\" },\n md: { value: \"0 10px 24px rgb(0 0 0 / 0.12)\" },\n lg: { value: \"0 18px 42px rgb(0 0 0 / 0.16)\" },\n xl: { value: \"0 24px 52px rgb(0 0 0 / 0.2)\" },\n },\n durations: {\n fast: { value: \"150ms\" },\n normal: { value: \"250ms\" },\n slow: { value: \"500ms\" },\n },\n easings: {\n standard: { value: \"cubic-bezier(0.2, 0, 0, 1)\" },\n },\n transitions: {\n colors: { value: \"background-color, border-color, box-shadow, color\" },\n transform: { value: \"transform\" },\n standard: { value: \"background-color, border-color, box-shadow, color, transform\" },\n },\n animations: {\n spin: { value: \"spin 900ms linear infinite\" },\n },\n },\n semanticTokens: {\n colors: {\n surface: {\n canvas: {\n value: { base: \"{colors.neutral.50}\", _dark: \"{colors.neutral.950}\" },\n },\n default: {\n value: { base: \"{colors.neutral.100}\", _dark: \"{colors.neutral.900}\" },\n },\n raised: {\n value: { base: \"{colors.neutral.50}\", _dark: \"{colors.neutral.800}\" },\n },\n subtle: {\n value: { base: \"{colors.neutral.200}\", _dark: \"{colors.neutral.800}\" },\n },\n overlay: {\n value: {\n base: \"rgb(250 250 250 / 0.32)\",\n _dark: \"rgb(9 9 11 / 0.4)\",\n },\n },\n },\n fg: {\n default: {\n value: { base: \"{colors.neutral.900}\", _dark: \"{colors.neutral.100}\" },\n },\n muted: {\n value: { base: \"{colors.neutral.600}\", _dark: \"{colors.neutral.400}\" },\n },\n onAccent: { value: \"{colors.neutral.50}\" },\n },\n border: {\n default: {\n value: { base: \"{colors.neutral.300}\", _dark: \"{colors.neutral.700}\" },\n },\n strong: {\n value: { base: \"{colors.neutral.500}\", _dark: \"{colors.neutral.500}\" },\n },\n interactive: {\n value: { base: \"{colors.neutral.900}\", _dark: \"{colors.neutral.200}\" },\n },\n },\n accent: {\n default: { value: \"{colors.blue.600}\" },\n hover: { value: \"{colors.blue.700}\" },\n },\n success: { value: \"{colors.green.700}\" },\n warning: { value: \"{colors.amber.700}\" },\n danger: { value: \"{colors.red.600}\" },\n info: { value: \"{colors.blue.600}\" },\n focus: { value: \"{colors.blue.600}\" },\n disabled: {\n value: { base: \"{colors.neutral.400}\", _dark: \"{colors.neutral.600}\" },\n },\n selected: {\n value: { base: \"{colors.blue.50}\", _dark: \"{colors.blue.950}\" },\n },\n link: {\n default: {\n value: { base: \"{colors.neutral.600}\", _dark: \"{colors.neutral.400}\" },\n },\n hover: {\n value: { base: \"{colors.neutral.900}\", _dark: \"{colors.neutral.200}\" },\n },\n },\n },\n shadows: {\n sm: {\n value: {\n base: \"0 1px 2px rgb(0 0 0 / 0.08)\",\n _dark: \"0 1px 2px rgb(255 255 255 / 0.08)\",\n },\n },\n md: {\n value: {\n base: \"0 10px 24px rgb(0 0 0 / 0.12)\",\n _dark: \"0 10px 24px rgb(255 255 255 / 0.1)\",\n },\n },\n lg: {\n value: {\n base: \"0 18px 42px rgb(0 0 0 / 0.16)\",\n _dark: \"0 18px 42px rgb(255 255 255 / 0.12)\",\n },\n },\n xl: {\n value: {\n base: \"0 24px 52px rgb(0 0 0 / 0.2)\",\n _dark: \"0 24px 52px rgb(255 255 255 / 0.14)\",\n },\n },\n },\n },\n textStyles: {\n body: {\n value: {\n fontFamily: \"system-ui, sans-serif\",\n lineHeight: \"1.5\",\n },\n },\n },\n keyframes: {\n spin: {\n to: {\n transform: \"rotate(360deg)\",\n },\n },\n },\n },\n};\n"],"mappings":";AAAA,MAAa,iBAAiB,EAC5B,QAAQ,EACN,MAAM,+BACR,EACF;AAEA,MAAa,YAAY,EACvB,QAAQ;CACN,QAAQ;EACN,QAAQ;GACN,SAAS;IACP,IAAI,EAAE,OAAO,UAAU;IACvB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;GAC1B;GACA,MAAM;IACJ,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;GAC1B;GACA,OAAO;IACL,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;GAC1B;GACA,OAAO;IACL,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;GAC1B;GACA,KAAK;IACH,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;GAC1B;EACF;EACA,OAAO;GACL,IAAI,EAAE,OAAO,WAAW;GACxB,IAAI,EAAE,OAAO,UAAU;GACvB,IAAI,EAAE,OAAO,OAAO;GACpB,IAAI,EAAE,OAAO,SAAS;GACtB,OAAO,EAAE,OAAO,OAAO;GACvB,MAAM,EAAE,OAAO,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AAoB;IACtC,OAAO,EAAE,OAAO,oBAAoB;GACtC;GACA,SAAS,EAAE,OAAO,qBAAqB;GACvC,SAAS,EAAE,OAAO,qBAAqB;GACvC,QAAQ,EAAE,OAAO,mBAAmB;GACpC,MAAM,EAAE,OAAO,oBAAoB;GACnC,OAAO,EAAE,OAAO,oBAAoB;GACpC,UAAU,EACR,OAAO;IAAE,MAAM;IAAwB,OAAO;GAAuB,EACvE;GACA,UAAU,EACR,OAAO;IAAE,MAAM;IAAoB,OAAO;GAAoB,EAChE;GACA,MAAM;IACJ,SAAS,EACP,OAAO;KAAE,MAAM;KAAwB,OAAO;IAAuB,EACvE;IACA,OAAO,EACL,OAAO;KAAE,MAAM;KAAwB,OAAO;IAAuB,EACvE;GACF;EACF;EACA,SAAS;GACP,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;EACF;CACF;CACA,YAAY,EACV,MAAM,EACJ,OAAO;EACL,YAAY;EACZ,YAAY;CACd,EACF,EACF;CACA,WAAW,EACT,MAAM,EACJ,IAAI,EACF,WAAW,iBACb,EACF,EACF;AACF,EACF"}
1
+ {"version":3,"file":"theme.cjs","names":[],"sources":["../../src/styles/theme.ts"],"sourcesContent":["export const jaciConditions = {\n extend: {\n dark: '[data-jaci-theme=\"dark\"] &',\n },\n};\n\nexport const jaciTheme = {\n extend: {\n tokens: {\n colors: {\n neutral: {\n 50: { value: \"#fafafa\" },\n 100: { value: \"#f4f4f5\" },\n 200: { value: \"#e4e4e7\" },\n 300: { value: \"#d4d4d8\" },\n 400: { value: \"#a1a1aa\" },\n 500: { value: \"#71717a\" },\n 600: { value: \"#52525b\" },\n 700: { value: \"#3f3f46\" },\n 800: { value: \"#27272a\" },\n 900: { value: \"#18181b\" },\n 950: { value: \"#09090b\" },\n },\n blue: {\n 500: { value: \"#3b82f6\" },\n 600: { value: \"#2563eb\" },\n 700: { value: \"#1d4ed8\" },\n },\n green: {\n 500: { value: \"#22c55e\" },\n 600: { value: \"#16a34a\" },\n 700: { value: \"#15803d\" },\n },\n amber: {\n 500: { value: \"#f59e0b\" },\n 600: { value: \"#d97706\" },\n 700: { value: \"#b45309\" },\n },\n red: {\n 500: { value: \"#ef4444\" },\n 600: { value: \"#dc2626\" },\n },\n },\n radii: {\n sm: { value: \"0.375rem\" },\n md: { value: \"0.75rem\" },\n lg: { value: \"1rem\" },\n xl: { value: \"1.5rem\" },\n \"2xl\": { value: \"2rem\" },\n full: { value: \"9999px\" },\n },\n shadows: {\n sm: { value: \"0 1px 2px rgb(0 0 0 / 0.08)\" },\n md: { value: \"0 10px 24px rgb(0 0 0 / 0.12)\" },\n lg: { value: \"0 18px 42px rgb(0 0 0 / 0.16)\" },\n xl: { value: \"0 24px 52px rgb(0 0 0 / 0.2)\" },\n },\n durations: {\n fast: { value: \"150ms\" },\n normal: { value: \"250ms\" },\n slow: { value: \"500ms\" },\n },\n easings: {\n standard: { value: \"cubic-bezier(0.2, 0, 0, 1)\" },\n },\n transitions: {\n colors: { value: \"background-color, border-color, box-shadow, color\" },\n transform: { value: \"transform\" },\n standard: { value: \"background-color, border-color, box-shadow, color, transform\" },\n },\n animations: {\n spin: { value: \"spin 900ms linear infinite\" },\n },\n },\n semanticTokens: {\n colors: {\n surface: {\n canvas: {\n value: { base: \"{colors.neutral.50}\", dark: \"{colors.neutral.950}\" },\n },\n default: {\n value: { base: \"{colors.neutral.100}\", dark: \"{colors.neutral.900}\" },\n },\n raised: {\n value: { base: \"{colors.neutral.50}\", dark: \"{colors.neutral.800}\" },\n },\n subtle: {\n value: { base: \"{colors.neutral.200}\", dark: \"{colors.neutral.800}\" },\n },\n overlay: {\n value: {\n base: \"rgb(250 250 250 / 0.32)\",\n dark: \"rgb(9 9 11 / 0.4)\",\n },\n },\n },\n fg: {\n default: {\n value: { base: \"{colors.neutral.900}\", dark: \"{colors.neutral.100}\" },\n },\n muted: {\n value: { base: \"{colors.neutral.600}\", dark: \"{colors.neutral.400}\" },\n },\n onAccent: { value: \"{colors.neutral.50}\" },\n },\n border: {\n default: {\n value: { base: \"{colors.neutral.300}\", dark: \"{colors.neutral.700}\" },\n },\n strong: {\n value: { base: \"{colors.neutral.500}\", dark: \"{colors.neutral.500}\" },\n },\n interactive: {\n value: { base: \"{colors.neutral.900}\", dark: \"{colors.neutral.200}\" },\n },\n },\n accent: {\n default: { value: \"{colors.blue.600}\" },\n hover: { value: \"{colors.blue.700}\" },\n },\n success: { value: \"{colors.green.700}\" },\n warning: { value: \"{colors.amber.700}\" },\n danger: { value: \"{colors.red.600}\" },\n info: { value: \"{colors.blue.600}\" },\n focus: { value: \"{colors.blue.600}\" },\n disabled: {\n value: { base: \"{colors.neutral.400}\", dark: \"{colors.neutral.600}\" },\n },\n selected: {\n value: { base: \"{colors.blue.50}\", dark: \"{colors.blue.950}\" },\n },\n link: {\n default: {\n value: { base: \"{colors.neutral.600}\", dark: \"{colors.neutral.400}\" },\n },\n hover: {\n value: { base: \"{colors.neutral.900}\", dark: \"{colors.neutral.200}\" },\n },\n },\n },\n shadows: {\n sm: {\n value: {\n base: \"0 1px 2px rgb(0 0 0 / 0.08)\",\n dark: \"0 1px 2px rgb(255 255 255 / 0.08)\",\n },\n },\n md: {\n value: {\n base: \"0 10px 24px rgb(0 0 0 / 0.12)\",\n dark: \"0 10px 24px rgb(255 255 255 / 0.1)\",\n },\n },\n lg: {\n value: {\n base: \"0 18px 42px rgb(0 0 0 / 0.16)\",\n dark: \"0 18px 42px rgb(255 255 255 / 0.12)\",\n },\n },\n xl: {\n value: {\n base: \"0 24px 52px rgb(0 0 0 / 0.2)\",\n dark: \"0 24px 52px rgb(255 255 255 / 0.14)\",\n },\n },\n },\n },\n textStyles: {\n body: {\n value: {\n fontFamily: \"system-ui, sans-serif\",\n line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,EAAE,OAAO,qBAAqB;GACvC,QAAQ,EAAE,OAAO,mBAAmB;GACpC,MAAM,EAAE,OAAO,oBAAoB;GACnC,OAAO,EAAE,OAAO,oBAAoB;GACpC,UAAU,EACR,OAAO;IAAE,MAAM;IAAwB,MAAM;GAAuB,EACtE;GACA,UAAU,EACR,OAAO;IAAE,MAAM;IAAoB,MAAM;GAAoB,EAC/D;GACA,MAAM;IACJ,SAAS,EACP,OAAO;KAAE,MAAM;KAAwB,MAAM;IAAuB,EACtE;IACA,OAAO,EACL,OAAO;KAAE,MAAM;KAAwB,MAAM;IAAuB,EACtE;GACF;EACF;EACA,SAAS;GACP,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;EACF;CACF;CACA,YAAY,EACV,MAAM,EACJ,OAAO;EACL,YAAY;EACZ,YAAY;CACd,EACF,EACF;CACA,WAAW,EACT,MAAM,EACJ,IAAI,EACF,WAAW,iBACb,EACF,EACF;AACF,EACF"}
@@ -68,48 +68,48 @@ const jaciTheme = { extend: {
68
68
  surface: {
69
69
  canvas: { value: {
70
70
  base: "{colors.neutral.50}",
71
- _dark: "{colors.neutral.950}"
71
+ dark: "{colors.neutral.950}"
72
72
  } },
73
73
  default: { value: {
74
74
  base: "{colors.neutral.100}",
75
- _dark: "{colors.neutral.900}"
75
+ dark: "{colors.neutral.900}"
76
76
  } },
77
77
  raised: { value: {
78
78
  base: "{colors.neutral.50}",
79
- _dark: "{colors.neutral.800}"
79
+ dark: "{colors.neutral.800}"
80
80
  } },
81
81
  subtle: { value: {
82
82
  base: "{colors.neutral.200}",
83
- _dark: "{colors.neutral.800}"
83
+ dark: "{colors.neutral.800}"
84
84
  } },
85
85
  overlay: { value: {
86
86
  base: "rgb(250 250 250 / 0.32)",
87
- _dark: "rgb(9 9 11 / 0.4)"
87
+ dark: "rgb(9 9 11 / 0.4)"
88
88
  } }
89
89
  },
90
90
  fg: {
91
91
  default: { value: {
92
92
  base: "{colors.neutral.900}",
93
- _dark: "{colors.neutral.100}"
93
+ dark: "{colors.neutral.100}"
94
94
  } },
95
95
  muted: { value: {
96
96
  base: "{colors.neutral.600}",
97
- _dark: "{colors.neutral.400}"
97
+ dark: "{colors.neutral.400}"
98
98
  } },
99
99
  onAccent: { value: "{colors.neutral.50}" }
100
100
  },
101
101
  border: {
102
102
  default: { value: {
103
103
  base: "{colors.neutral.300}",
104
- _dark: "{colors.neutral.700}"
104
+ dark: "{colors.neutral.700}"
105
105
  } },
106
106
  strong: { value: {
107
107
  base: "{colors.neutral.500}",
108
- _dark: "{colors.neutral.500}"
108
+ dark: "{colors.neutral.500}"
109
109
  } },
110
110
  interactive: { value: {
111
111
  base: "{colors.neutral.900}",
112
- _dark: "{colors.neutral.200}"
112
+ dark: "{colors.neutral.200}"
113
113
  } }
114
114
  },
115
115
  accent: {
@@ -123,39 +123,39 @@ const jaciTheme = { extend: {
123
123
  focus: { value: "{colors.blue.600}" },
124
124
  disabled: { value: {
125
125
  base: "{colors.neutral.400}",
126
- _dark: "{colors.neutral.600}"
126
+ dark: "{colors.neutral.600}"
127
127
  } },
128
128
  selected: { value: {
129
129
  base: "{colors.blue.50}",
130
- _dark: "{colors.blue.950}"
130
+ dark: "{colors.blue.950}"
131
131
  } },
132
132
  link: {
133
133
  default: { value: {
134
134
  base: "{colors.neutral.600}",
135
- _dark: "{colors.neutral.400}"
135
+ dark: "{colors.neutral.400}"
136
136
  } },
137
137
  hover: { value: {
138
138
  base: "{colors.neutral.900}",
139
- _dark: "{colors.neutral.200}"
139
+ dark: "{colors.neutral.200}"
140
140
  } }
141
141
  }
142
142
  },
143
143
  shadows: {
144
144
  sm: { value: {
145
145
  base: "0 1px 2px rgb(0 0 0 / 0.08)",
146
- _dark: "0 1px 2px rgb(255 255 255 / 0.08)"
146
+ dark: "0 1px 2px rgb(255 255 255 / 0.08)"
147
147
  } },
148
148
  md: { value: {
149
149
  base: "0 10px 24px rgb(0 0 0 / 0.12)",
150
- _dark: "0 10px 24px rgb(255 255 255 / 0.1)"
150
+ dark: "0 10px 24px rgb(255 255 255 / 0.1)"
151
151
  } },
152
152
  lg: { value: {
153
153
  base: "0 18px 42px rgb(0 0 0 / 0.16)",
154
- _dark: "0 18px 42px rgb(255 255 255 / 0.12)"
154
+ dark: "0 18px 42px rgb(255 255 255 / 0.12)"
155
155
  } },
156
156
  xl: { value: {
157
157
  base: "0 24px 52px rgb(0 0 0 / 0.2)",
158
- _dark: "0 24px 52px rgb(255 255 255 / 0.14)"
158
+ dark: "0 24px 52px rgb(255 255 255 / 0.14)"
159
159
  } }
160
160
  }
161
161
  },
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","names":[],"sources":["../../src/styles/theme.ts"],"sourcesContent":["export const jaciConditions = {\n extend: {\n dark: '[data-jaci-theme=\"dark\"] &',\n },\n};\n\nexport const jaciTheme = {\n extend: {\n tokens: {\n colors: {\n neutral: {\n 50: { value: \"#fafafa\" },\n 100: { value: \"#f4f4f5\" },\n 200: { value: \"#e4e4e7\" },\n 300: { value: \"#d4d4d8\" },\n 400: { value: \"#a1a1aa\" },\n 500: { value: \"#71717a\" },\n 600: { value: \"#52525b\" },\n 700: { value: \"#3f3f46\" },\n 800: { value: \"#27272a\" },\n 900: { value: \"#18181b\" },\n 950: { value: \"#09090b\" },\n },\n blue: {\n 500: { value: \"#3b82f6\" },\n 600: { value: \"#2563eb\" },\n 700: { value: \"#1d4ed8\" },\n },\n green: {\n 500: { value: \"#22c55e\" },\n 600: { value: \"#16a34a\" },\n 700: { value: \"#15803d\" },\n },\n amber: {\n 500: { value: \"#f59e0b\" },\n 600: { value: \"#d97706\" },\n 700: { value: \"#b45309\" },\n },\n red: {\n 500: { value: \"#ef4444\" },\n 600: { value: \"#dc2626\" },\n },\n },\n radii: {\n sm: { value: \"0.375rem\" },\n md: { value: \"0.75rem\" },\n lg: { value: \"1rem\" },\n xl: { value: \"1.5rem\" },\n \"2xl\": { value: \"2rem\" },\n full: { value: \"9999px\" },\n },\n shadows: {\n sm: { value: \"0 1px 2px rgb(0 0 0 / 0.08)\" },\n md: { value: \"0 10px 24px rgb(0 0 0 / 0.12)\" },\n lg: { value: \"0 18px 42px rgb(0 0 0 / 0.16)\" },\n xl: { value: \"0 24px 52px rgb(0 0 0 / 0.2)\" },\n },\n durations: {\n fast: { value: \"150ms\" },\n normal: { value: \"250ms\" },\n slow: { value: \"500ms\" },\n },\n easings: {\n standard: { value: \"cubic-bezier(0.2, 0, 0, 1)\" },\n },\n transitions: {\n colors: { value: \"background-color, border-color, box-shadow, color\" },\n transform: { value: \"transform\" },\n standard: { value: \"background-color, border-color, box-shadow, color, transform\" },\n },\n animations: {\n spin: { value: \"spin 900ms linear infinite\" },\n },\n },\n semanticTokens: {\n colors: {\n surface: {\n canvas: {\n value: { base: \"{colors.neutral.50}\", _dark: \"{colors.neutral.950}\" },\n },\n default: {\n value: { base: \"{colors.neutral.100}\", _dark: \"{colors.neutral.900}\" },\n },\n raised: {\n value: { base: \"{colors.neutral.50}\", _dark: \"{colors.neutral.800}\" },\n },\n subtle: {\n value: { base: \"{colors.neutral.200}\", _dark: \"{colors.neutral.800}\" },\n },\n overlay: {\n value: {\n base: \"rgb(250 250 250 / 0.32)\",\n _dark: \"rgb(9 9 11 / 0.4)\",\n },\n },\n },\n fg: {\n default: {\n value: { base: \"{colors.neutral.900}\", _dark: \"{colors.neutral.100}\" },\n },\n muted: {\n value: { base: \"{colors.neutral.600}\", _dark: \"{colors.neutral.400}\" },\n },\n onAccent: { value: \"{colors.neutral.50}\" },\n },\n border: {\n default: {\n value: { base: \"{colors.neutral.300}\", _dark: \"{colors.neutral.700}\" },\n },\n strong: {\n value: { base: \"{colors.neutral.500}\", _dark: \"{colors.neutral.500}\" },\n },\n interactive: {\n value: { base: \"{colors.neutral.900}\", _dark: \"{colors.neutral.200}\" },\n },\n },\n accent: {\n default: { value: \"{colors.blue.600}\" },\n hover: { value: \"{colors.blue.700}\" },\n },\n success: { value: \"{colors.green.700}\" },\n warning: { value: \"{colors.amber.700}\" },\n danger: { value: \"{colors.red.600}\" },\n info: { value: \"{colors.blue.600}\" },\n focus: { value: \"{colors.blue.600}\" },\n disabled: {\n value: { base: \"{colors.neutral.400}\", _dark: \"{colors.neutral.600}\" },\n },\n selected: {\n value: { base: \"{colors.blue.50}\", _dark: \"{colors.blue.950}\" },\n },\n link: {\n default: {\n value: { base: \"{colors.neutral.600}\", _dark: \"{colors.neutral.400}\" },\n },\n hover: {\n value: { base: \"{colors.neutral.900}\", _dark: \"{colors.neutral.200}\" },\n },\n },\n },\n shadows: {\n sm: {\n value: {\n base: \"0 1px 2px rgb(0 0 0 / 0.08)\",\n _dark: \"0 1px 2px rgb(255 255 255 / 0.08)\",\n },\n },\n md: {\n value: {\n base: \"0 10px 24px rgb(0 0 0 / 0.12)\",\n _dark: \"0 10px 24px rgb(255 255 255 / 0.1)\",\n },\n },\n lg: {\n value: {\n base: \"0 18px 42px rgb(0 0 0 / 0.16)\",\n _dark: \"0 18px 42px rgb(255 255 255 / 0.12)\",\n },\n },\n xl: {\n value: {\n base: \"0 24px 52px rgb(0 0 0 / 0.2)\",\n _dark: \"0 24px 52px rgb(255 255 255 / 0.14)\",\n },\n },\n },\n },\n textStyles: {\n body: {\n value: {\n fontFamily: \"system-ui, sans-serif\",\n lineHeight: \"1.5\",\n },\n },\n },\n keyframes: {\n spin: {\n to: {\n transform: \"rotate(360deg)\",\n },\n },\n },\n },\n};\n"],"mappings":";AAAA,MAAa,iBAAiB,EAC5B,QAAQ,EACN,MAAM,+BACR,EACF;AAEA,MAAa,YAAY,EACvB,QAAQ;CACN,QAAQ;EACN,QAAQ;GACN,SAAS;IACP,IAAI,EAAE,OAAO,UAAU;IACvB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EA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,OAAO;IAAuB,EACvE;IACA,OAAO,EACL,OAAO;KAAE,MAAM;KAAwB,OAAO;IAAuB,EACvE;GACF;EACF;EACA,SAAS;GACP,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,OAAO;GACT,EACF;EACF;CACF;CACA,YAAY,EACV,MAAM,EACJ,OAAO;EACL,YAAY;EACZ,YAAY;CACd,EACF,EACF;CACA,WAAW,EACT,MAAM,EACJ,IAAI,EACF,WAAW,iBACb,EACF,EACF;AACF,EACF"}
1
+ {"version":3,"file":"theme.js","names":[],"sources":["../../src/styles/theme.ts"],"sourcesContent":["export const jaciConditions = {\n extend: {\n dark: '[data-jaci-theme=\"dark\"] &',\n },\n};\n\nexport const jaciTheme = {\n extend: {\n tokens: {\n colors: {\n neutral: {\n 50: { value: \"#fafafa\" },\n 100: { value: \"#f4f4f5\" },\n 200: { value: \"#e4e4e7\" },\n 300: { value: \"#d4d4d8\" },\n 400: { value: \"#a1a1aa\" },\n 500: { value: \"#71717a\" },\n 600: { value: \"#52525b\" },\n 700: { value: \"#3f3f46\" },\n 800: { value: \"#27272a\" },\n 900: { value: \"#18181b\" },\n 950: { value: \"#09090b\" },\n },\n blue: {\n 500: { value: \"#3b82f6\" },\n 600: { value: \"#2563eb\" },\n 700: { value: \"#1d4ed8\" },\n },\n green: {\n 500: { value: \"#22c55e\" },\n 600: { value: \"#16a34a\" },\n 700: { value: \"#15803d\" },\n },\n amber: {\n 500: { value: \"#f59e0b\" },\n 600: { value: \"#d97706\" },\n 700: { value: \"#b45309\" },\n },\n red: {\n 500: { value: \"#ef4444\" },\n 600: { value: \"#dc2626\" },\n },\n },\n radii: {\n sm: { value: \"0.375rem\" },\n md: { value: \"0.75rem\" },\n lg: { value: \"1rem\" },\n xl: { value: \"1.5rem\" },\n \"2xl\": { value: \"2rem\" },\n full: { value: \"9999px\" },\n },\n shadows: {\n sm: { value: \"0 1px 2px rgb(0 0 0 / 0.08)\" },\n md: { value: \"0 10px 24px rgb(0 0 0 / 0.12)\" },\n lg: { value: \"0 18px 42px rgb(0 0 0 / 0.16)\" },\n xl: { value: \"0 24px 52px rgb(0 0 0 / 0.2)\" },\n },\n durations: {\n fast: { value: \"150ms\" },\n normal: { value: \"250ms\" },\n slow: { value: \"500ms\" },\n },\n easings: {\n standard: { value: \"cubic-bezier(0.2, 0, 0, 1)\" },\n },\n transitions: {\n colors: { value: \"background-color, border-color, box-shadow, color\" },\n transform: { value: \"transform\" },\n standard: { value: \"background-color, border-color, box-shadow, color, transform\" },\n },\n animations: {\n spin: { value: \"spin 900ms linear infinite\" },\n },\n },\n semanticTokens: {\n colors: {\n surface: {\n canvas: {\n value: { base: \"{colors.neutral.50}\", dark: \"{colors.neutral.950}\" },\n },\n default: {\n value: { base: \"{colors.neutral.100}\", dark: \"{colors.neutral.900}\" },\n },\n raised: {\n value: { base: \"{colors.neutral.50}\", dark: \"{colors.neutral.800}\" },\n },\n subtle: {\n value: { base: \"{colors.neutral.200}\", dark: \"{colors.neutral.800}\" },\n },\n overlay: {\n value: {\n base: \"rgb(250 250 250 / 0.32)\",\n dark: \"rgb(9 9 11 / 0.4)\",\n },\n },\n },\n fg: {\n default: {\n value: { base: \"{colors.neutral.900}\", dark: \"{colors.neutral.100}\" },\n },\n muted: {\n value: { base: \"{colors.neutral.600}\", dark: \"{colors.neutral.400}\" },\n },\n onAccent: { value: \"{colors.neutral.50}\" },\n },\n border: {\n default: {\n value: { base: \"{colors.neutral.300}\", dark: \"{colors.neutral.700}\" },\n },\n strong: {\n value: { base: \"{colors.neutral.500}\", dark: \"{colors.neutral.500}\" },\n },\n interactive: {\n value: { base: \"{colors.neutral.900}\", dark: \"{colors.neutral.200}\" },\n },\n },\n accent: {\n default: { value: \"{colors.blue.600}\" },\n hover: { value: \"{colors.blue.700}\" },\n },\n success: { value: \"{colors.green.700}\" },\n warning: { value: \"{colors.amber.700}\" },\n danger: { value: \"{colors.red.600}\" },\n info: { value: \"{colors.blue.600}\" },\n focus: { value: \"{colors.blue.600}\" },\n disabled: {\n value: { base: \"{colors.neutral.400}\", dark: \"{colors.neutral.600}\" },\n },\n selected: {\n value: { base: \"{colors.blue.50}\", dark: \"{colors.blue.950}\" },\n },\n link: {\n default: {\n value: { base: \"{colors.neutral.600}\", dark: \"{colors.neutral.400}\" },\n },\n hover: {\n value: { base: \"{colors.neutral.900}\", dark: \"{colors.neutral.200}\" },\n },\n },\n },\n shadows: {\n sm: {\n value: {\n base: \"0 1px 2px rgb(0 0 0 / 0.08)\",\n dark: \"0 1px 2px rgb(255 255 255 / 0.08)\",\n },\n },\n md: {\n value: {\n base: \"0 10px 24px rgb(0 0 0 / 0.12)\",\n dark: \"0 10px 24px rgb(255 255 255 / 0.1)\",\n },\n },\n lg: {\n value: {\n base: \"0 18px 42px rgb(0 0 0 / 0.16)\",\n dark: \"0 18px 42px rgb(255 255 255 / 0.12)\",\n },\n },\n xl: {\n value: {\n base: \"0 24px 52px rgb(0 0 0 / 0.2)\",\n dark: \"0 24px 52px rgb(255 255 255 / 0.14)\",\n },\n },\n },\n },\n textStyles: {\n body: {\n value: {\n fontFamily: \"system-ui, sans-serif\",\n lineHeight: \"1.5\",\n },\n },\n },\n keyframes: {\n spin: {\n to: {\n transform: \"rotate(360deg)\",\n },\n },\n },\n },\n};\n"],"mappings":";AAAA,MAAa,iBAAiB,EAC5B,QAAQ,EACN,MAAM,+BACR,EACF;AAEA,MAAa,YAAY,EACvB,QAAQ;CACN,QAAQ;EACN,QAAQ;GACN,SAAS;IACP,IAAI,EAAE,OAAO,UAAU;IACvB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,EAAE,OAAO,UAAU;IACxB,KAAK,E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F;EACA,SAAS;GACP,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;GACA,IAAI,EACF,OAAO;IACL,MAAM;IACN,MAAM;GACR,EACF;EACF;CACF;CACA,YAAY,EACV,MAAM,EACJ,OAAO;EACL,YAAY;EACZ,YAAY;CACd,EACF,EACF;CACA,WAAW,EACT,MAAM,EACJ,IAAI,EACF,WAAW,iBACb,EACF,EACF;AACF,EACF"}
package/dist/styles.css CHANGED
@@ -5,6 +5,18 @@
5
5
  --made-with-panda: '🐼';
6
6
  }
7
7
 
8
+ [data-jaci-theme="dark"] {
9
+ --jaci-colors-surface-canvas: var(--jaci-colors-neutral-950);
10
+ --jaci-colors-surface-default: var(--jaci-colors-neutral-900);
11
+ --jaci-colors-surface-raised: var(--jaci-colors-neutral-800);
12
+ --jaci-colors-surface-subtle: var(--jaci-colors-neutral-800);
13
+ --jaci-colors-surface-overlay: rgb(9 9 11 / 0.4);
14
+ --jaci-colors-fg-default: var(--jaci-colors-neutral-100);
15
+ --jaci-colors-fg-muted: var(--jaci-colors-neutral-400);
16
+ --jaci-colors-border-default: var(--jaci-colors-neutral-700);
17
+ --jaci-colors-border-interactive: var(--jaci-colors-neutral-200);
18
+ }
19
+
8
20
  :where([data-slot="bottom-navigation"]),:where([data-slot="sidebar"]) {
9
21
  display: flex;
10
22
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jaci-ui",
3
3
  "description": "Accessible, themeable React components by Jaci UI",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Richard Borges",
@@ -78,7 +78,7 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
- "@base-ui/react": "^1.7.0",
81
+ "@base-ui/react": "^1.8.0",
82
82
  "date-fns": "^4.4.0",
83
83
  "qrcode": "^1.5.4"
84
84
  },
@@ -86,13 +86,13 @@
86
86
  "access": "public"
87
87
  },
88
88
  "devDependencies": {
89
- "@pandacss/dev": "^1.12.0",
89
+ "@pandacss/dev": "^1.12.1",
90
90
  "@types/qrcode": "^1.5.6",
91
- "@types/react": "^19.2.18",
92
- "@types/react-dom": "^19.2.4",
91
+ "@types/react": "^19.3.0",
92
+ "@types/react-dom": "^19.3.0",
93
93
  "jsdom": "^27.4.0",
94
- "react": "^19.2.8",
95
- "react-dom": "^19.2.8",
94
+ "react": "^19.3.0",
95
+ "react-dom": "^19.3.0",
96
96
  "tsdown": "^0.22.14"
97
97
  },
98
98
  "scripts": {