@epam/ai-dial-settings-panel 1.1.0-dev.242
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/components/SettingsPanel/SettingsPanel.d.ts +5 -0
- package/components/SettingsPanel/SettingsPanel.d.ts.map +1 -0
- package/index.css +2 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +91 -0
- package/models/settings-panel-props.d.ts +61 -0
- package/models/settings-panel-props.d.ts.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { SettingsPanelProps } from '../../models/settings-panel-props';
|
|
3
|
+
/** Vertical icon + label navigation panel with a roving-tabindex ARIA tablist. */
|
|
4
|
+
export declare const SettingsPanel: FC<SettingsPanelProps>;
|
|
5
|
+
//# sourceMappingURL=SettingsPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsPanel.d.ts","sourceRoot":"","sources":["../../../src/components/SettingsPanel/SettingsPanel.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AACnE,OAAO,KAAK,EAEV,kBAAkB,EACnB,MAAM,mCAAmC,CAAC;AA0B3C,kFAAkF;AAClF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAgIhD,CAAC"}
|
package/index.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
._sectionLabel_7wog3_1{color:var(--sp-section-label-text,var(--text-primary,#161b2d))}._row_7wog3_5{color:var(--sp-row-text,var(--text-secondary,#57647a))}._row_7wog3_5:focus-visible{outline-color:var(--sp-row-focus-outline,var(--stroke-focus-black,#161b2d))}@media (hover:hover){._row_7wog3_5:hover:not(:disabled):not(._rowActive_7wog3_12){background-color:var(--sp-row-bg-hover,var(--bg-control-accent-alpha-hover,#2764d924))}}._row_7wog3_5:disabled{cursor:not-allowed}._row_7wog3_5._rowActive_7wog3_12{color:var(--sp-active-row-text,var(--text-accent,#1d4ed8));background-color:var(--sp-active-row-bg,var(--bg-control-accent-alpha,#2764d90f))}@media (hover:hover){._row_7wog3_5._rowActive_7wog3_12:hover{background-color:var(--sp-active-row-bg-hover,var(--bg-control-accent-alpha-hover,#2764d924))}}
|
|
2
|
+
/*$vite$:1*/
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { buildCssVars as e, mergeClasses as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { useId as n, useRef as r } from "react";
|
|
3
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
var o = {
|
|
5
|
+
sectionLabel: "_sectionLabel_7wog3_1",
|
|
6
|
+
row: "_row_7wog3_5",
|
|
7
|
+
rowActive: "_rowActive_7wog3_12"
|
|
8
|
+
}, s = (e, t, n) => {
|
|
9
|
+
let r = e.length;
|
|
10
|
+
for (let i = 1; i <= r; i += 1) {
|
|
11
|
+
let a = (t + n * i + r) % r;
|
|
12
|
+
if (!e[a].disabled) return a;
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
}, c = (e) => e.findIndex((e) => !e.disabled), l = (e) => {
|
|
16
|
+
for (let t = e.length - 1; t >= 0; --t) if (!e[t].disabled) return t;
|
|
17
|
+
return -1;
|
|
18
|
+
}, u = ({ items: u, activeId: d, onSelect: f, sectionLabel: p, styles: m, className: h }) => {
|
|
19
|
+
let g = n(), _ = r(/* @__PURE__ */ new Map()), { sectionLabelClassName: v = "dial-h1-text", itemLabelClassName: y = "dial-small-text", activeItemLabelClassName: b = "dial-small-semi-text" } = m?.typography ?? {}, x = m?.colors, S = e({
|
|
20
|
+
"--sp-section-label-text": x?.sectionLabelText,
|
|
21
|
+
"--sp-row-text": x?.rowText,
|
|
22
|
+
"--sp-row-bg-hover": x?.rowBackgroundHover,
|
|
23
|
+
"--sp-active-row-bg": x?.activeRowBackground,
|
|
24
|
+
"--sp-active-row-bg-hover": x?.activeRowBackgroundHover,
|
|
25
|
+
"--sp-active-row-text": x?.activeRowText,
|
|
26
|
+
"--sp-row-focus-outline": x?.rowFocusOutline
|
|
27
|
+
}), C = u.findIndex((e) => e.id === d), w = (e) => {
|
|
28
|
+
if (e < 0 || e === C) return;
|
|
29
|
+
let t = u[e];
|
|
30
|
+
_.current.get(t.id)?.focus(), f(t.id);
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ a("div", {
|
|
33
|
+
className: t("flex flex-col gap-3 bg-layer-raised", h),
|
|
34
|
+
style: S,
|
|
35
|
+
children: [p && /* @__PURE__ */ i("div", {
|
|
36
|
+
className: "flex h-16 shrink-0 items-center px-4",
|
|
37
|
+
children: /* @__PURE__ */ i("span", {
|
|
38
|
+
id: g,
|
|
39
|
+
className: t(o.sectionLabel, v),
|
|
40
|
+
children: p
|
|
41
|
+
})
|
|
42
|
+
}), /* @__PURE__ */ i("div", {
|
|
43
|
+
role: "tablist",
|
|
44
|
+
"aria-orientation": "vertical",
|
|
45
|
+
"aria-labelledby": p ? g : void 0,
|
|
46
|
+
onKeyDown: (e) => {
|
|
47
|
+
switch (e.key) {
|
|
48
|
+
case "ArrowDown":
|
|
49
|
+
e.preventDefault(), w(s(u, C, 1));
|
|
50
|
+
break;
|
|
51
|
+
case "ArrowUp":
|
|
52
|
+
e.preventDefault(), w(s(u, C, -1));
|
|
53
|
+
break;
|
|
54
|
+
case "Home":
|
|
55
|
+
e.preventDefault(), w(c(u));
|
|
56
|
+
break;
|
|
57
|
+
case "End":
|
|
58
|
+
e.preventDefault(), w(l(u));
|
|
59
|
+
break;
|
|
60
|
+
default: break;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
tabIndex: -1,
|
|
64
|
+
className: "flex flex-col",
|
|
65
|
+
children: u.map((e) => {
|
|
66
|
+
let n = e.id === d, r = n && u.length > 1;
|
|
67
|
+
return /* @__PURE__ */ a("button", {
|
|
68
|
+
ref: (t) => {
|
|
69
|
+
t ? _.current.set(e.id, t) : _.current.delete(e.id);
|
|
70
|
+
},
|
|
71
|
+
type: "button",
|
|
72
|
+
role: "tab",
|
|
73
|
+
"aria-selected": n,
|
|
74
|
+
"aria-disabled": e.disabled || void 0,
|
|
75
|
+
disabled: e.disabled,
|
|
76
|
+
tabIndex: n ? 0 : -1,
|
|
77
|
+
onClick: () => {
|
|
78
|
+
!e.disabled && !n && f(e.id);
|
|
79
|
+
},
|
|
80
|
+
className: t("flex h-11 w-full items-center gap-2 rounded-lg px-3 text-start desktop:h-10", "focus-visible:outline focus-visible:-outline-offset-1", o.row, r && o.rowActive),
|
|
81
|
+
children: [e.icon, /* @__PURE__ */ i("span", {
|
|
82
|
+
className: t(r ? b : y, !r && "text-primary"),
|
|
83
|
+
children: e.label
|
|
84
|
+
})]
|
|
85
|
+
}, e.id);
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { u as SettingsPanel };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** One row rendered by {@link SettingsPanel}. */
|
|
3
|
+
export interface SettingsPanelItem {
|
|
4
|
+
/** Stable identifier, matched against `SettingsPanelProps.activeId`. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Already-localized row label. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Row icon, rendered before the label. */
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
/** Disabled rows cannot become active, render with a `not-allowed` cursor, and are skipped by keyboard navigation. Defaults to `false`. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Typography overrides for the {@link SettingsPanel} component. */
|
|
14
|
+
export interface SettingsPanelTypography {
|
|
15
|
+
/** Typography class applied to the section header. Defaults to `'dial-h1-text'`. */
|
|
16
|
+
sectionLabelClassName?: string;
|
|
17
|
+
/** Typography class applied to an inactive row's label. Defaults to `'dial-small-text'`. */
|
|
18
|
+
itemLabelClassName?: string;
|
|
19
|
+
/** Typography class applied to the active row's label. Defaults to `'dial-small-semi-text'`. */
|
|
20
|
+
activeItemLabelClassName?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Color overrides for the {@link SettingsPanel} component, applied as CSS custom properties. */
|
|
23
|
+
export interface SettingsPanelColors {
|
|
24
|
+
/** Label color of the section header. Defaults to `--text-primary`. */
|
|
25
|
+
sectionLabelText?: string;
|
|
26
|
+
/** Label and icon color of an inactive row (enabled or disabled). Defaults to `--text-secondary`. */
|
|
27
|
+
rowText?: string;
|
|
28
|
+
/** Background color of an enabled, inactive row on hover. Defaults to `--bg-control-accent-alpha-hover`. */
|
|
29
|
+
rowBackgroundHover?: string;
|
|
30
|
+
/** Background color of the active row. Defaults to `--bg-control-accent-alpha`. */
|
|
31
|
+
activeRowBackground?: string;
|
|
32
|
+
/** Background color of the active row on hover. Defaults to `--bg-control-accent-alpha-hover`. */
|
|
33
|
+
activeRowBackgroundHover?: string;
|
|
34
|
+
/** Label and icon color of the active row. Defaults to `--text-accent`. */
|
|
35
|
+
activeRowText?: string;
|
|
36
|
+
/** Keyboard focus ring color. Defaults to `--stroke-focus-black`. */
|
|
37
|
+
rowFocusOutline?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Style overrides for the {@link SettingsPanel} component. */
|
|
40
|
+
export interface SettingsPanelStyles {
|
|
41
|
+
/** Typography overrides. */
|
|
42
|
+
typography?: SettingsPanelTypography;
|
|
43
|
+
/** Color overrides applied as CSS custom properties. */
|
|
44
|
+
colors?: SettingsPanelColors;
|
|
45
|
+
}
|
|
46
|
+
/** Props for {@link SettingsPanel}. */
|
|
47
|
+
export interface SettingsPanelProps {
|
|
48
|
+
/** Rows to render, top to bottom. */
|
|
49
|
+
items: SettingsPanelItem[];
|
|
50
|
+
/** `id` of the currently selected item. */
|
|
51
|
+
activeId: string;
|
|
52
|
+
/** Fired with an item's `id` when the user selects an enabled row that is not already active. */
|
|
53
|
+
onSelect: (id: string) => void;
|
|
54
|
+
/** Already-localized header text rendered above the item list. Omit to render no header. */
|
|
55
|
+
sectionLabel?: string;
|
|
56
|
+
/** Style overrides. */
|
|
57
|
+
styles?: SettingsPanelStyles;
|
|
58
|
+
/** Additional CSS class applied to the root element. */
|
|
59
|
+
className?: string;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=settings-panel-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-panel-props.d.ts","sourceRoot":"","sources":["../../src/models/settings-panel-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,2IAA2I;IAC3I,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,oEAAoE;AACpE,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4FAA4F;IAC5F,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gGAAgG;IAChG,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,iGAAiG;AACjG,MAAM,WAAW,mBAAmB;IAClC,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qGAAqG;IACrG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4GAA4G;IAC5G,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mFAAmF;IACnF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kGAAkG;IAClG,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,wDAAwD;IACxD,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,iGAAiG;IACjG,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,4FAA4F;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@epam/ai-dial-settings-panel",
|
|
3
|
+
"description": "Presentational vertical settings navigation panel with icon-labeled rows and active-row highlighting",
|
|
4
|
+
"version": "1.1.0-dev.242",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./index.js",
|
|
8
|
+
"module": "./index.js",
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
"./package.json": "./package.json",
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"import": "./index.js",
|
|
15
|
+
"default": "./index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@epam/ai-dial-chat-shared": "1.1.0-dev.242",
|
|
20
|
+
"@epam/ai-dial-ui-kit": "^0.13.0-dev.64",
|
|
21
|
+
"@tabler/icons-react": "^3.44.0",
|
|
22
|
+
"react": "^19.2.7"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/epam/ai-dial-chat.git",
|
|
27
|
+
"directory": "libs/settings-panel"
|
|
28
|
+
}
|
|
29
|
+
}
|