@epam/ai-dial-ui-kit 0.15.0-dev.46 → 0.15.0-dev.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/CHANGELOG.md CHANGED
@@ -14,8 +14,13 @@ Versions match the git tags on the `development` branch.
14
14
  - **Legacy theme variable fallbacks removed** — 0.14.0 renamed several theme variables but kept the old names in the fallback chain, so every token resolved two variables and a theme could set either. The old names are no longer read: `--bg-control-neutral-hover` → `--bg-control-neutral-hover-muted`, `--stroke-focus-black` → `--stroke-focus`, and `--bg-control-accent-gradient-from` / `-to` / `-hover-from` / `-active-to` → `--bg-gradient-1` / `-2` / `-1-hover` / `-2-active`. A theme that still sets an old name falls back to the kit's default colour; rename the variable.
15
15
  See [migration guide](migration-guides/0.15.0/legacy-theme-variable-fallbacks-removal.md).
16
16
 
17
+ - **`Slider` (2.0) — redrawn thumb and track** — the slider now follows the new 2.0 design: a 12px solid accent thumb (was a 16px white disc with a border) that grows a soft halo on hover, focus and drag, over an accent-tint track (was grey). The props are unchanged, so typecheck cannot flag it, but every `Slider` renders differently and host CSS aimed at the old thumb needs a second look. The 24px pointer row and the `dial-kit-slider` class stay as they were.
18
+ See [migration guide](migration-guides/0.15.0/slider-redesign.md).
19
+
17
20
  ### Added
18
21
 
22
+ - **`Slider` (2.0) — `showTooltip`, `showTicks`, `leftContent`, `rightContent`** — the rest of the new slider design. `showTooltip` shows the formatted value in a bubble above the thumb; `showTicks` marks every step on the unfilled track for a discrete slider. Both are hidden while disabled. The bubble is `aria-hidden`, because the input already announces the value through `aria-valuetext`. `leftContent` and `rightContent` are the slider container's side slots, centred on the track: an icon on the left, a `NumberInput` or the value as text on the right. The kit does not sync a `NumberInput` placed there; the caller passes it the same `value` and setter. All four are opt-in.
23
+
19
24
  - **`SchemaRenderer` (2.0)** — a JSON Schema form built only from 2.0 controls. `DialSchemaRenderer` exists only in 1.0, so a 2.0 screen that renders a schema-driven form had to mix in 1.0 inputs, selects and the 1.0 `Dropdown` surface. The 2.0 renderer keeps the 1.0 props, except `jsonEditorTheme`: the three variants, `oneOf`/`anyOf` with select or radio selectors, arrays with discriminator types, key-value maps, `dial:resource` options, `skipUntouched`, `renderField` and `texts`. Primitives render as `Input`, `NumberInput`, `PasswordInput`, `Select`, `Switch` or `RadioGroup`. Values the schema does not describe are edited as JSON in a monospace `Textarea`, not in Monaco, so the form loads no editor bundle. Section headers are real toggle buttons with `aria-expanded`, and the remove and info buttons sit next to the toggle instead of inside it. Every control has an accessible name, including array items and key-value rows. `renderField` replaces only the control, so the field keeps its label and error. Stamps `DIAL_KIT_CLASS.schemaRenderer` (`dial-kit-schema-renderer`) on the root and `DIAL_KIT_CLASS.schemaRendererSection` (`dial-kit-schema-renderer-section`) on each section card. The schema types, enums and utils are shared with 1.0 from neutral modules; the 1.0 import paths still work. Additive.
20
25
 
21
26
  - **`AutocompleteTagInput` (2.0)** — a tag field that suggests values while typing and still accepts its own. `TagInput` takes only free text and a multiple `Select` only listed values, so a field such as a list of MIME types — where the common ones should be one keystroke away but any `<type>/<subtype>` is valid — had to be hand-built in each app (the DIAL admin's attachment types, the QuickApps editor's). Typing lists up to `maxSuggestions` (default 5) of the `suggestions` whose label, value or description contains the text and which are not already tags; Enter or comma adds the highlighted one, or the typed text when nothing matches; the arrow keys move the highlight, Escape and leaving the field close the list, Backspace on an empty input removes the last tag. The input follows the ARIA combobox pattern and keeps focus while the list is open, the list floats on the `z-floating` layer and takes the field's width, and the tags share the multiple `Select`'s look. `getRemoveTagLabel` names each tag's remove button, so a localised host is not left with the English `Remove <tag>`. Stamps `DIAL_KIT_CLASS.autocompleteTagInput` (`dial-kit-autocomplete-tag-input`) on the field. Additive; nothing else changes.
@@ -62,6 +67,8 @@ Versions match the git tags on the `development` branch.
62
67
 
63
68
  ### Changed
64
69
 
70
+ - **`StarterButton` (2.0) — a sparkles icon by default** — the design puts a sparkles glyph before every starter label, so each host was passing the same `iconBefore`. `iconBefore` now defaults to a 20px `IconSparkles` at the 1.5 stroke, `aria-hidden`, and stroked with the starter gradient like any other icon. A caller-supplied `iconBefore` replaces it; `iconBefore={null}` keeps a label-only pill. A `StarterButton` that passed no `iconBefore` now draws the icon; no other API changes.
71
+
65
72
  - **`Select` (2.0) — multi-select tags are 24px, and the field wraps them with an 8px gap** — the tags in a multi-select field used the 32px pill of `Tag`, taller than the design's field chip. They are now 24px with a `rounded-md` shape, a `layer-sunken` fill and a `stroke-secondary` rim, and the wrapped field pads 8px vertically with 8px between tags, so one row of tags still fills the 40px field. `Tag` itself is unchanged. Visual only; no API changes.
66
73
 
67
74
  ### Fixed
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),u=require("./editor-Bc9xzKuR.cjs"),d=require("@monaco-editor/react");function f(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const m=f(d),b=({value:e,onChange:o,onValidateJSON:t,options:a,currentTheme:n,themesConfig:i=u.EDITOR_THEMES_CONFIG})=>{function s(r){r?.editor?.defineTheme(n,i[n]),r.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,enableSchemaRequest:!1,schemas:[{uri:"http://custom-schema/object-required.json",fileMatch:["*"],schema:{type:"object",description:"Top-level value must be an object",additionalProperties:!0}}]})}const{Editor:l}=m;return c.jsx(l,{beforeMount:s,height:"100%",defaultLanguage:"json",value:e,onChange:o,theme:n,onValidate:t,options:{minimap:{enabled:!1},formatOnType:!0,formatOnPaste:!0,selectOnLineNumbers:!1,automaticLayout:!0,scrollBeyondLastLine:!1,wordWrap:"on",smoothScrolling:!0,overviewRulerLanes:0,scrollbar:{horizontal:"hidden",verticalScrollbarSize:4,verticalSliderSize:4},...a??{}}})};exports.DialJsonEditor=b;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("@uiw/react-md-editor"),m=require("./lazy-BEsZqouS.cjs"),u=require("./merge-classes-BEJXjzkx.cjs"),x=({value:t,onChange:s,height:o=300,preview:i="edit",theme:a=m.EditorThemes.dark,className:n,placeholder:r})=>{const d=r!==void 0&&!t;return e.jsxs("div",{"data-color-mode":a,className:u.mergeClasses("relative",n),children:[e.jsx(c,{value:t,onChange:l=>s?.(l||""),height:o,preview:i}),d&&e.jsx("div",{className:"pointer-events-none absolute left-0 top-8 px-2 dial-small-text text-secondary opacity-40",children:r})]})};exports.DialMarkdownEditor=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("@uiw/react-md-editor"),m=require("./lazy-Cy9WobJf.cjs"),u=require("./merge-classes-BEJXjzkx.cjs"),x=({value:t,onChange:s,height:o=300,preview:i="edit",theme:a=m.EditorThemes.dark,className:n,placeholder:r})=>{const d=r!==void 0&&!t;return e.jsxs("div",{"data-color-mode":a,className:u.mergeClasses("relative",n),children:[e.jsx(c,{value:t,onChange:l=>s?.(l||""),height:o,preview:i}),d&&e.jsx("div",{className:"pointer-events-none absolute left-0 top-8 px-2 dial-small-text text-secondary opacity-40",children:r})]})};exports.DialMarkdownEditor=x;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),O=require("@uiw/react-md-editor"),_=require("./lazy-BEsZqouS.cjs"),k=require("./merge-classes-BEJXjzkx.cjs"),o=require("@tabler/icons-react"),p=require("./icon-DhjrDQ8I.cjs"),f=require("./icon-CrGVkVpG.cjs");function E(n){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const c=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(i,r,c.get?c:{enumerable:!0,get:()=>n[r]})}}return i.default=n,Object.freeze(i)}const b=E(O),L=f.DIAL_ICON_SIZE.SM,t={size:L,stroke:p.DIAL_KIT_ICON_STROKE},s=(n,i)=>({...n,icon:i}),M=()=>{const{bold:n,code:i,divider:r,group:c,heading1:a,heading2:d,heading3:u,italic:l,link:m,orderedListCommand:I,quote:x,strikethrough:g,table:h,unorderedListCommand:C}=b;return[s(n,e.jsx(o.IconBold,{...t})),s(l,e.jsx(o.IconItalic,{...t})),s(g,e.jsx(o.IconStrikethrough,{...t})),r,c([a,d,u],{name:"heading",groupName:"heading",icon:e.jsx(o.IconTextSize,{...t}),buttonProps:{"aria-label":"Text style",title:"Text style"}}),r,s(C,e.jsx(o.IconList,{...t})),s(I,e.jsx(o.IconListNumbers,{...t})),r,s(x,e.jsx(o.IconQuote,{...t})),s(m,e.jsx(o.IconLink,{...t})),s(i,e.jsx(o.IconCode,{...t})),r,s(h,e.jsx(o.IconTable,{...t}))]},S=()=>{const{codeEdit:n,codeLive:i,codePreview:r,divider:c,fullscreen:a}=b;return[s(n,e.jsx(o.IconPencil,{...t})),s(i,e.jsx(o.IconLayoutColumns,{...t})),s(r,e.jsx(o.IconEye,{...t})),c,s(a,e.jsx(o.IconMaximize,{...t}))]},T=({value:n,onChange:i,height:r=300,theme:c=_.EditorThemes.light,className:a,placeholder:d,defaultPreview:u="edit",id:l,ariaLabel:m})=>{const I=j.useMemo(()=>M(),[]),x=j.useMemo(()=>S(),[]);return e.jsx("div",{"data-color-mode":c,className:k.mergeClasses("dial-kit-markdown-editor",a),children:e.jsx(O,{value:n,onChange:g=>i?.(g||""),height:r,preview:u,commands:I,extraCommands:x,textareaProps:{placeholder:d,id:l,"aria-label":m}})})};exports.MarkdownEditor=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),O=require("@uiw/react-md-editor"),_=require("./lazy-Cy9WobJf.cjs"),k=require("./merge-classes-BEJXjzkx.cjs"),o=require("@tabler/icons-react"),p=require("./icon-DhjrDQ8I.cjs"),f=require("./icon-CrGVkVpG.cjs");function E(n){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const c=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(i,r,c.get?c:{enumerable:!0,get:()=>n[r]})}}return i.default=n,Object.freeze(i)}const b=E(O),L=f.DIAL_ICON_SIZE.SM,t={size:L,stroke:p.DIAL_KIT_ICON_STROKE},s=(n,i)=>({...n,icon:i}),M=()=>{const{bold:n,code:i,divider:r,group:c,heading1:a,heading2:d,heading3:u,italic:l,link:m,orderedListCommand:I,quote:x,strikethrough:g,table:h,unorderedListCommand:C}=b;return[s(n,e.jsx(o.IconBold,{...t})),s(l,e.jsx(o.IconItalic,{...t})),s(g,e.jsx(o.IconStrikethrough,{...t})),r,c([a,d,u],{name:"heading",groupName:"heading",icon:e.jsx(o.IconTextSize,{...t}),buttonProps:{"aria-label":"Text style",title:"Text style"}}),r,s(C,e.jsx(o.IconList,{...t})),s(I,e.jsx(o.IconListNumbers,{...t})),r,s(x,e.jsx(o.IconQuote,{...t})),s(m,e.jsx(o.IconLink,{...t})),s(i,e.jsx(o.IconCode,{...t})),r,s(h,e.jsx(o.IconTable,{...t}))]},S=()=>{const{codeEdit:n,codeLive:i,codePreview:r,divider:c,fullscreen:a}=b;return[s(n,e.jsx(o.IconPencil,{...t})),s(i,e.jsx(o.IconLayoutColumns,{...t})),s(r,e.jsx(o.IconEye,{...t})),c,s(a,e.jsx(o.IconMaximize,{...t}))]},T=({value:n,onChange:i,height:r=300,theme:c=_.EditorThemes.light,className:a,placeholder:d,defaultPreview:u="edit",id:l,ariaLabel:m})=>{const I=j.useMemo(()=>M(),[]),x=j.useMemo(()=>S(),[]);return e.jsx("div",{"data-color-mode":c,className:k.mergeClasses("dial-kit-markdown-editor",a),children:e.jsx(O,{value:n,onChange:g=>i?.(g||""),height:r,preview:u,commands:I,extraCommands:x,textareaProps:{placeholder:d,id:l,"aria-label":m}})})};exports.MarkdownEditor=T;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react");require("./editor-Bc9xzKuR.cjs");const E=require("./lazy-Cy9WobJf.cjs");require("@monaco-editor/react");const m=require("./Switch-DE6MrcqJ.cjs"),N=require("./MarkdownEditor-CPzMv3lE.cjs"),b=({value:o,onChangeValue:l,label:i,headerContent:a,switcherLabel:d,height:c=300,theme:u=E.EditorThemes.dark,onValidateJSON:x,preview:j="edit"})=>{const w=n.useId(),[t,C]=n.useState(!1),[f,p]=n.useState(null);n.useEffect(()=>{t&&typeof window<"u"&&Promise.resolve().then(()=>require("./JsonEditor-CpSpVa0v.cjs")).then(s=>{p(()=>s.DialJsonEditor)})},[t]);const h=n.useCallback(s=>{l?.(s)},[l]),S=n.useCallback(s=>{x?.(s)},[x]),r=!!d;return e.jsx("div",{className:"size-full flex flex-col",children:e.jsx("div",{className:"flex flex-col gap-8",children:e.jsxs("div",{children:[(i||a||r)&&e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i&&e.jsx(m.DialLabel,{label:i}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 justify-end",children:[a,r&&e.jsx("label",{className:"flex items-center gap-2 cursor-pointer",children:e.jsx(m.DialSwitch,{isOn:t,label:d,switchId:w,onChange:s=>C(s)})})]})]}),r&&t?e.jsx("div",{className:"border border-primary rounded",style:{height:`${c}px`},children:f&&e.jsx(f,{value:o,onChange:h,onValidateJSON:S,currentTheme:u})}):e.jsx(N.DialMarkdownEditor,{value:o,onChange:h,height:c,preview:j,theme:u})]})})})};exports.DialMarkdownEditorContainer=b;
@@ -1,26 +1,28 @@
1
1
  import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
2
  import { useId as g, useState as x, useEffect as J, useCallback as u } from "react";
3
- import { DialSwitch as S } from "../Switch/Switch.js";
4
- import { EditorThemes as b } from "../../types/editor.js";
3
+ import "../../constants/editor.js";
4
+ import { EditorThemes as S } from "../../types/editor.js";
5
+ import "@monaco-editor/react";
6
+ import { DialSwitch as b } from "../Switch/Switch.js";
5
7
  import { DialMarkdownEditor as v } from "./MarkdownEditor.js";
6
8
  import { DialLabel as y } from "../Label/Label.js";
7
- const z = ({
9
+ const $ = ({
8
10
  value: s,
9
11
  onChangeValue: l,
10
- label: i,
12
+ label: t,
11
13
  headerContent: d,
12
14
  switcherLabel: a,
13
15
  height: c = 300,
14
- theme: m = b.dark,
16
+ theme: m = S.dark,
15
17
  onValidateJSON: f,
16
18
  preview: C = "edit"
17
19
  }) => {
18
- const N = g(), [n, w] = x(!1), [p, D] = x(null);
20
+ const N = g(), [i, w] = x(!1), [p, D] = x(null);
19
21
  J(() => {
20
- n && typeof window < "u" && import("../JsonEditor/JsonEditor.js").then((o) => {
22
+ i && typeof window < "u" && import("../JsonEditor/JsonEditor.js").then((o) => {
21
23
  D(() => o.DialJsonEditor);
22
24
  });
23
- }, [n]);
25
+ }, [i]);
24
26
  const h = u(
25
27
  (o) => {
26
28
  l?.(o);
@@ -31,16 +33,16 @@ const z = ({
31
33
  f?.(o);
32
34
  },
33
35
  [f]
34
- ), t = !!a;
36
+ ), n = !!a;
35
37
  return /* @__PURE__ */ e("div", { className: "size-full flex flex-col", children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-8", children: /* @__PURE__ */ r("div", { children: [
36
- (i || d || t) && /* @__PURE__ */ r("div", { className: "flex justify-between items-center mb-2", children: [
37
- i && /* @__PURE__ */ e(y, { label: i }),
38
+ (t || d || n) && /* @__PURE__ */ r("div", { className: "flex justify-between items-center mb-2", children: [
39
+ t && /* @__PURE__ */ e(y, { label: t }),
38
40
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 flex-1 justify-end", children: [
39
41
  d,
40
- t && /* @__PURE__ */ e("label", { className: "flex items-center gap-2 cursor-pointer", children: /* @__PURE__ */ e(
41
- S,
42
+ n && /* @__PURE__ */ e("label", { className: "flex items-center gap-2 cursor-pointer", children: /* @__PURE__ */ e(
43
+ b,
42
44
  {
43
- isOn: n,
45
+ isOn: i,
44
46
  label: a,
45
47
  switchId: N,
46
48
  onChange: (o) => w(o)
@@ -48,7 +50,7 @@ const z = ({
48
50
  ) })
49
51
  ] })
50
52
  ] }),
51
- t && n ? /* @__PURE__ */ e(
53
+ n && i ? /* @__PURE__ */ e(
52
54
  "div",
53
55
  {
54
56
  className: "border border-primary rounded",
@@ -76,5 +78,5 @@ const z = ({
76
78
  ] }) }) });
77
79
  };
78
80
  export {
79
- z as DialMarkdownEditorContainer
81
+ $ as DialMarkdownEditorContainer
80
82
  };
@@ -1,30 +1,33 @@
1
- import { jsx as r, jsxs as B, Fragment as f } from "react/jsx-runtime";
2
- import { useId as h } from "react";
3
- import { ButtonAppearance as n, ButtonVariant as o } from "../../../types/button.js";
1
+ import { jsx as t, jsxs as B, Fragment as g } from "react/jsx-runtime";
2
+ import { IconSparkles as y } from "@tabler/icons-react";
3
+ import { useId as S } from "react";
4
+ import { DIAL_KIT_ICON_STROKE as h } from "../constants/icon.js";
5
+ import { DIAL_ICON_SIZE as k } from "../../../constants/icon.js";
6
+ import { ButtonAppearance as o, ButtonVariant as n } from "../../../types/button.js";
4
7
  import { Button as d } from "./Button.js";
5
- const l = (a, t) => ({ appearance: s, ...u }) => /* @__PURE__ */ r(
8
+ const p = (a, r) => ({ appearance: s, ...u }) => /* @__PURE__ */ t(
6
9
  d,
7
10
  {
8
11
  ...u,
9
12
  variant: a,
10
- appearance: s || t
13
+ appearance: s || r
11
14
  }
12
- ), p = (a, t) => ({ variant: s, ...u }) => /* @__PURE__ */ r(
15
+ ), c = (a, r) => ({ variant: s, ...u }) => /* @__PURE__ */ t(
13
16
  d,
14
17
  {
15
18
  ...u,
16
- variant: s || t,
19
+ variant: s || r,
17
20
  appearance: a
18
21
  }
19
- ), N = l(
20
- o.Primary,
21
- n.Solid
22
- ), C = l(
23
- o.Neutral,
24
- n.Solid
25
- ), G = l(
26
- o.Danger,
27
- n.Solid
22
+ ), A = p(
23
+ n.Primary,
24
+ o.Solid
25
+ ), E = p(
26
+ n.Neutral,
27
+ o.Solid
28
+ ), R = p(
29
+ n.Danger,
30
+ o.Solid
28
31
  ), e = {
29
32
  x1: "-5.06",
30
33
  y1: "2.26",
@@ -32,69 +35,76 @@ const l = (a, t) => ({ appearance: s, ...u }) => /* @__PURE__ */ r(
32
35
  y2: "22.63",
33
36
  from: "var(--stroke-gradient-1, #5976E9)",
34
37
  to: "var(--stroke-gradient-2, #885DF2)"
35
- }, O = ({
36
- appearance: a = n.Outlined,
37
- iconBefore: t,
38
+ }, x = /* @__PURE__ */ t(
39
+ y,
40
+ {
41
+ size: k.MD,
42
+ stroke: h,
43
+ "aria-hidden": !0
44
+ }
45
+ ), G = ({
46
+ appearance: a = o.Outlined,
47
+ iconBefore: r = x,
38
48
  iconAfter: i,
39
49
  style: s,
40
50
  ...u
41
51
  }) => {
42
- const c = `dial-kit-starter-gradient-${h().replace(/[^\w-]/g, "")}`, g = /* @__PURE__ */ r(
52
+ const l = `dial-kit-starter-gradient-${S().replace(/[^\w-]/g, "")}`, f = /* @__PURE__ */ t(
43
53
  "svg",
44
54
  {
45
55
  className: "pointer-events-none absolute size-0 overflow-hidden",
46
56
  "aria-hidden": "true",
47
57
  focusable: "false",
48
- children: /* @__PURE__ */ r("defs", { children: /* @__PURE__ */ B(
58
+ children: /* @__PURE__ */ t("defs", { children: /* @__PURE__ */ B(
49
59
  "linearGradient",
50
60
  {
51
- id: c,
61
+ id: l,
52
62
  x1: e.x1,
53
63
  y1: e.y1,
54
64
  x2: e.x2,
55
65
  y2: e.y2,
56
66
  gradientUnits: "userSpaceOnUse",
57
67
  children: [
58
- /* @__PURE__ */ r("stop", { stopColor: e.from }),
59
- /* @__PURE__ */ r("stop", { offset: "1", stopColor: e.to })
68
+ /* @__PURE__ */ t("stop", { stopColor: e.from }),
69
+ /* @__PURE__ */ t("stop", { offset: "1", stopColor: e.to })
60
70
  ]
61
71
  }
62
72
  ) })
63
73
  }
64
- ), m = (y) => /* @__PURE__ */ B(f, { children: [
65
- g,
66
- y
74
+ ), m = (I) => /* @__PURE__ */ B(g, { children: [
75
+ f,
76
+ I
67
77
  ] });
68
- return /* @__PURE__ */ r(
78
+ return /* @__PURE__ */ t(
69
79
  d,
70
80
  {
71
81
  ...u,
72
- variant: o.Starter,
82
+ variant: n.Starter,
73
83
  appearance: a,
74
- iconBefore: t ? m(t) : void 0,
75
- iconAfter: i && !t ? m(i) : i,
84
+ iconBefore: r ? m(r) : void 0,
85
+ iconAfter: i && !r ? m(i) : i,
76
86
  style: {
77
- "--dial-kit-starter-icon-stroke": `url(#${c})`,
87
+ "--dial-kit-starter-icon-stroke": `url(#${l})`,
78
88
  ...s
79
89
  }
80
90
  }
81
91
  );
82
- }, D = p(
83
- n.Link,
84
- o.Primary
85
- ), I = p(
86
- n.Ghost,
87
- o.Primary
88
- ), P = p(
89
- n.Outlined,
90
- o.Neutral
92
+ }, L = c(
93
+ o.Link,
94
+ n.Primary
95
+ ), P = c(
96
+ o.Ghost,
97
+ n.Primary
98
+ ), W = c(
99
+ o.Outlined,
100
+ n.Neutral
91
101
  );
92
102
  export {
93
- G as DangerButton,
94
- I as GhostButton,
95
- D as LinkButton,
96
- C as NeutralButton,
97
- P as OutlinedButton,
98
- N as PrimaryButton,
99
- O as StarterButton
103
+ R as DangerButton,
104
+ P as GhostButton,
105
+ L as LinkButton,
106
+ E as NeutralButton,
107
+ W as OutlinedButton,
108
+ A as PrimaryButton,
109
+ G as StarterButton
100
110
  };
@@ -1,112 +1,173 @@
1
- import { jsxs as n, jsx as e, Fragment as C } from "react/jsx-runtime";
2
- import { useId as w, useCallback as A } from "react";
3
- import { mergeClasses as i } from "../../../utils/merge-classes.js";
4
- import { resolveAccessibleName as B } from "../../../utils/accessible-name.js";
5
- import { ErrorText as H, CaptionText as L } from "../CaptionText/CaptionText.js";
6
- import { Label as U } from "../Label/Label.js";
7
- const Z = 16, _ = (o) => (o.toString().split(".")[1] ?? "").length, O = ({
8
- id: o,
1
+ import { jsxs as n, jsx as e, Fragment as k } from "react/jsx-runtime";
2
+ import { useId as Z, useCallback as q } from "react";
3
+ import { mergeClasses as a } from "../../../utils/merge-classes.js";
4
+ import { resolveAccessibleName as D } from "../../../utils/accessible-name.js";
5
+ import { ErrorText as J, CaptionText as K } from "../CaptionText/CaptionText.js";
6
+ import { Label as O } from "../Label/Label.js";
7
+ import { getTickPercents as Q } from "./utils.js";
8
+ const R = 12, W = (t) => (t.toString().split(".")[1] ?? "").length, F = (t) => `calc(${t}% + ${(0.5 - t / 100) * R}px)`, X = (t, r) => t && r ? "grid-cols-[auto_minmax(0,1fr)_auto]" : t ? "grid-cols-[auto_minmax(0,1fr)]" : r ? "grid-cols-[minmax(0,1fr)_auto]" : "grid-cols-[minmax(0,1fr)]", le = ({
9
+ id: t,
9
10
  value: r,
10
- min: d = 0,
11
- max: h = 1,
12
- step: x = 0.1,
13
- disabled: a,
14
- labelProps: l,
15
- labels: t,
16
- formatValue: m,
17
- showValue: p = !1,
18
- caption: f,
11
+ min: m = 0,
12
+ max: g = 1,
13
+ step: h = 0.1,
14
+ disabled: i,
15
+ labelProps: s,
16
+ labels: l,
17
+ formatValue: x,
18
+ showValue: v = !1,
19
+ showTooltip: S = !1,
20
+ showTicks: j = !1,
21
+ leftContent: N,
22
+ rightContent: y,
23
+ caption: b,
19
24
  error: c,
20
- onChange: g,
21
- containerClassName: $,
22
- trackClassName: F,
23
- fillClassName: M,
24
- className: S,
25
- ...u
25
+ onChange: w,
26
+ containerClassName: z,
27
+ trackClassName: B,
28
+ fillClassName: E,
29
+ className: L,
30
+ ...I
26
31
  }) => {
27
- const T = w(), s = o ?? T, v = f && !c ? `${s}-caption` : void 0, N = c ? `${s}-error` : void 0, y = h - d, b = y > 0 ? Math.min(100, Math.max(0, (r - d) / y * 100)) : 0, j = `calc(${b}% + ${(0.5 - b / 100) * Z}px)`, I = m ? m(r) : r.toFixed(_(x)), k = A(
28
- (E) => {
29
- g?.(Number(E.target.value));
32
+ const A = Z(), o = t ?? A, C = b && !c ? `${o}-caption` : void 0, T = c ? `${o}-error` : void 0, f = g - m, G = f > 0 ? Math.min(100, Math.max(0, (r - m) / f * 100)) : 0, _ = F(G), H = j && !i ? Q(f, h) : [], M = S && !i, u = N != null, $ = y != null, p = x ? x(r) : r.toFixed(W(h)), U = q(
33
+ (d) => {
34
+ w?.(Number(d.target.value));
30
35
  },
31
- [g]
36
+ [w]
32
37
  );
33
- return /* @__PURE__ */ n("div", { className: i("flex flex-col gap-2", $), children: [
34
- (l || p) && /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
35
- l && /* @__PURE__ */ e(U, { ...l, htmlFor: s }),
36
- p && // The input already reports its value to assistive tech, so this is
38
+ return /* @__PURE__ */ n("div", { className: a("flex flex-col gap-2", z), children: [
39
+ (s || v) && /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
40
+ s && /* @__PURE__ */ e(O, { ...s, htmlFor: o }),
41
+ v && // The input already reports its value to assistive tech, so this is
37
42
  // a visual echo rather than a second announcement.
38
43
  /* @__PURE__ */ e(
39
44
  "span",
40
45
  {
41
46
  "aria-hidden": "true",
42
- className: i(
47
+ className: a(
43
48
  "dial-small-text ml-auto",
44
- a ? "text-control-disable-primary" : "text-primary"
49
+ i ? "text-control-disable-primary" : "text-primary"
45
50
  ),
46
- children: I
51
+ children: p
47
52
  }
48
53
  )
49
54
  ] }),
50
55
  /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
51
- /* @__PURE__ */ n("div", { className: "relative flex h-6 items-center", children: [
52
- /* @__PURE__ */ e(
53
- "div",
54
- {
55
- className: i(
56
- "pointer-events-none absolute inset-x-0 h-1 rounded-full",
57
- a ? "bg-control-disable-primary" : "bg-control-neutral-active",
58
- F
59
- )
60
- }
61
- ),
62
- /* @__PURE__ */ e(
63
- "div",
64
- {
65
- className: i(
66
- "pointer-events-none absolute left-0 h-1 rounded-full",
67
- a ? "bg-control-disable-secondary" : "bg-control-accent",
68
- M
69
- ),
70
- style: { width: j }
71
- }
72
- ),
73
- /* @__PURE__ */ e(
74
- "input",
75
- {
76
- ...u,
77
- type: "range",
78
- id: s,
79
- value: r,
80
- min: d,
81
- max: h,
82
- step: x,
83
- disabled: a,
84
- onChange: k,
85
- "aria-label": B(
86
- typeof l?.label != "string" ? u["aria-label"] : void 0
87
- ),
88
- "aria-valuetext": m ? I : void 0,
89
- "aria-describedby": N ?? v,
90
- className: i(
91
- "dial-kit-slider absolute inset-0 h-full w-full",
92
- S
56
+ /* @__PURE__ */ n(
57
+ "div",
58
+ {
59
+ className: a(
60
+ "grid items-center gap-x-3 gap-y-1",
61
+ X(u, $),
62
+ // Room for the value bubble, which hangs above the track row.
63
+ M && "mt-7"
64
+ ),
65
+ children: [
66
+ u && /* @__PURE__ */ e("div", { className: "flex items-center", children: N }),
67
+ /* @__PURE__ */ n("div", { className: "relative flex h-6 items-center", children: [
68
+ /* @__PURE__ */ e(
69
+ "div",
70
+ {
71
+ className: a(
72
+ "pointer-events-none absolute inset-x-0 h-1 rounded-full",
73
+ i ? "bg-control-disable-primary" : "bg-control-accent-muted",
74
+ B
75
+ )
76
+ }
77
+ ),
78
+ H.map((d) => /* @__PURE__ */ e(
79
+ "span",
80
+ {
81
+ "aria-hidden": "true",
82
+ className: "pointer-events-none absolute size-0.5 -translate-x-1/2 rounded-full bg-control-neutral-default",
83
+ style: { left: F(d) }
84
+ },
85
+ d
86
+ )),
87
+ /* @__PURE__ */ e(
88
+ "div",
89
+ {
90
+ className: a(
91
+ "pointer-events-none absolute left-0 h-1 rounded-full",
92
+ i ? "bg-control-disable-secondary" : "bg-control-accent",
93
+ E
94
+ ),
95
+ style: { width: _ }
96
+ }
97
+ ),
98
+ M && // A visual echo like `showValue`: the input already announces
99
+ // its value, so the bubble stays out of the accessibility tree.
100
+ /* @__PURE__ */ n(
101
+ "span",
102
+ {
103
+ "aria-hidden": "true",
104
+ className: "pointer-events-none absolute bottom-full mb-0.5 flex -translate-x-1/2 flex-col items-center",
105
+ style: { left: _ },
106
+ children: [
107
+ /* @__PURE__ */ e("span", { className: "whitespace-nowrap rounded-md bg-control-inverted px-2 py-0.5 dial-small-text text-control-inverted shadow-xs", children: p }),
108
+ /* @__PURE__ */ e(
109
+ "svg",
110
+ {
111
+ width: "8",
112
+ height: "4",
113
+ viewBox: "0 0 8 4",
114
+ className: "fill-control-inverted",
115
+ children: /* @__PURE__ */ e("path", { d: "M0 0h8L4 4z" })
116
+ }
117
+ )
118
+ ]
119
+ }
120
+ ),
121
+ /* @__PURE__ */ e(
122
+ "input",
123
+ {
124
+ ...I,
125
+ type: "range",
126
+ id: o,
127
+ value: r,
128
+ min: m,
129
+ max: g,
130
+ step: h,
131
+ disabled: i,
132
+ onChange: U,
133
+ "aria-label": D(
134
+ typeof s?.label != "string" ? I["aria-label"] : void 0
135
+ ),
136
+ "aria-valuetext": x ? p : void 0,
137
+ "aria-describedby": T ?? C,
138
+ className: a(
139
+ "dial-kit-slider absolute inset-0 h-full w-full",
140
+ L
141
+ )
142
+ }
143
+ )
144
+ ] }),
145
+ $ && /* @__PURE__ */ e("div", { className: "flex items-center", children: y }),
146
+ l && /* @__PURE__ */ e(
147
+ "div",
148
+ {
149
+ className: a(
150
+ "dial-tiny-text flex text-secondary",
151
+ u && "col-start-2"
152
+ ),
153
+ children: l.length === 3 ? /* @__PURE__ */ n(k, { children: [
154
+ /* @__PURE__ */ e("span", { children: l[0] }),
155
+ /* @__PURE__ */ e("span", { className: "flex-1 text-center", children: l[1] }),
156
+ /* @__PURE__ */ e("span", { children: l[2] })
157
+ ] }) : /* @__PURE__ */ n(k, { children: [
158
+ /* @__PURE__ */ e("span", { children: l[0] }),
159
+ /* @__PURE__ */ e("span", { className: "ml-auto", children: l[1] })
160
+ ] })
161
+ }
93
162
  )
94
- }
95
- )
96
- ] }),
97
- t && /* @__PURE__ */ e("div", { className: "dial-tiny-text flex text-secondary", children: t.length === 3 ? /* @__PURE__ */ n(C, { children: [
98
- /* @__PURE__ */ e("span", { children: t[0] }),
99
- /* @__PURE__ */ e("span", { className: "flex-1 text-center", children: t[1] }),
100
- /* @__PURE__ */ e("span", { children: t[2] })
101
- ] }) : /* @__PURE__ */ n(C, { children: [
102
- /* @__PURE__ */ e("span", { children: t[0] }),
103
- /* @__PURE__ */ e("span", { className: "ml-auto", children: t[1] })
104
- ] }) }),
105
- /* @__PURE__ */ e(H, { id: N, text: c }),
106
- !c && /* @__PURE__ */ e(L, { id: v, text: f })
163
+ ]
164
+ }
165
+ ),
166
+ /* @__PURE__ */ e(J, { id: T, text: c }),
167
+ !c && /* @__PURE__ */ e(K, { id: C, text: b })
107
168
  ] })
108
169
  ] });
109
170
  };
110
171
  export {
111
- O as Slider
172
+ le as Slider
112
173
  };
@@ -0,0 +1,12 @@
1
+ const e = (r, t) => {
2
+ if (r <= 0 || t <= 0)
3
+ return [];
4
+ const o = Math.floor(r / t + 1e-9);
5
+ return Array.from(
6
+ { length: o + 1 },
7
+ (n, c) => c * t / r * 100
8
+ );
9
+ };
10
+ export {
11
+ e as getTickPercents
12
+ };