@net-advantage/nabs-ui-toolbar 0.69.0 → 0.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nabs-ui-toolbar.cjs +1 -1
- package/dist/nabs-ui-toolbar.js +44 -20
- package/dist/toolbar.model.d.ts +3 -0
- package/dist/toolbar.model.test.d.ts +1 -0
- package/dist/toolbar.utils.d.ts +1 -3
- package/dist/toolbar.view-model.d.ts +14 -0
- package/dist/toolbar.view-model.test.d.ts +1 -0
- package/package.json +8 -3
package/dist/nabs-ui-toolbar.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime");var n={left:`nabs-ui-toolbar__content--label-left`,right:`nabs-ui-toolbar__content--label-right`,top:`nabs-ui-toolbar__content--label-top`,bottom:`nabs-ui-toolbar__content--label-bottom`};function r(e){return e||`right`}
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime");var n={left:`nabs-ui-toolbar__content--label-left`,right:`nabs-ui-toolbar__content--label-right`,top:`nabs-ui-toolbar__content--label-top`,bottom:`nabs-ui-toolbar__content--label-bottom`};function r(e){return e||`right`}function i(e){return[`nabs-ui-toolbar`,e??``].filter(Boolean).join(` `)}function a(e){return[`nabs-ui-toolbar__content`,e].filter(Boolean).join(` `)}function o({isActive:e,hasLabel:t,buttonClassName:n}){return[`nabs-ui-toolbar__button`,e?`nabs-ui-toolbar__button--active`:``,t?``:`nabs-ui-toolbar__button--icon-only`,n??``].filter(Boolean).join(` `)}function s(e){return[`nabs-ui-toolbar__icon`,e??``].filter(Boolean).join(` `)}function c(e){return[`nabs-ui-toolbar__label`,e??``].filter(Boolean).join(` `)}function l(e,t){return typeof e==`string`?e:t}var u=(0,e.forwardRef)(function({items:e,activeItemId:u,className:d=``,buttonClassName:f=``,iconClassName:p=``,labelClassName:m=``,onItemSelect:h,...g},_){return(0,t.jsx)(`div`,{ref:_,className:i(d),role:`toolbar`,...g,children:e.map(e=>{let i=e.icon,d=!!e.label,g=e.id===u||e.pressed===!0,_=a(n[r(e.labelPosition)]),v=o({isActive:g,hasLabel:d,buttonClassName:f}),y=s(p),b=c(m),x=l(e.label,e.title);return(0,t.jsx)(`button`,{type:`button`,className:v,disabled:e.disabled,title:e.title,"aria-label":x,"aria-pressed":typeof e.pressed==`boolean`?e.pressed:void 0,onClick:t=>{h?.({itemId:e.id,item:e,event:t})},children:(0,t.jsxs)(`span`,{className:_,children:[i?(0,t.jsx)(i,{className:y,"aria-hidden":`true`,focusable:`false`}):null,e.label?(0,t.jsx)(`span`,{className:b,children:e.label}):null]})},e.id)})})});u.displayName=`Toolbar`,exports.Toolbar=u;
|
package/dist/nabs-ui-toolbar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef as e } from "react";
|
|
2
2
|
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
-
//#region src/toolbar.
|
|
3
|
+
//#region src/toolbar.model.ts
|
|
4
4
|
var r = {
|
|
5
5
|
left: "nabs-ui-toolbar__content--label-left",
|
|
6
6
|
right: "nabs-ui-toolbar__content--label-right",
|
|
@@ -11,42 +11,66 @@ function i(e) {
|
|
|
11
11
|
return e || "right";
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
|
+
//#region src/toolbar.view-model.ts
|
|
15
|
+
function a(e) {
|
|
16
|
+
return ["nabs-ui-toolbar", e ?? ""].filter(Boolean).join(" ");
|
|
17
|
+
}
|
|
18
|
+
function o(e) {
|
|
19
|
+
return ["nabs-ui-toolbar__content", e].filter(Boolean).join(" ");
|
|
20
|
+
}
|
|
21
|
+
function s({ isActive: e, hasLabel: t, buttonClassName: n }) {
|
|
22
|
+
return [
|
|
23
|
+
"nabs-ui-toolbar__button",
|
|
24
|
+
e ? "nabs-ui-toolbar__button--active" : "",
|
|
25
|
+
t ? "" : "nabs-ui-toolbar__button--icon-only",
|
|
26
|
+
n ?? ""
|
|
27
|
+
].filter(Boolean).join(" ");
|
|
28
|
+
}
|
|
29
|
+
function c(e) {
|
|
30
|
+
return ["nabs-ui-toolbar__icon", e ?? ""].filter(Boolean).join(" ");
|
|
31
|
+
}
|
|
32
|
+
function l(e) {
|
|
33
|
+
return ["nabs-ui-toolbar__label", e ?? ""].filter(Boolean).join(" ");
|
|
34
|
+
}
|
|
35
|
+
function u(e, t) {
|
|
36
|
+
return typeof e == "string" ? e : t;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
14
39
|
//#region src/Toolbar.tsx
|
|
15
|
-
var
|
|
40
|
+
var d = e(function({ items: e, activeItemId: d, className: f = "", buttonClassName: p = "", iconClassName: m = "", labelClassName: h = "", onItemSelect: g, ..._ }, v) {
|
|
16
41
|
return /* @__PURE__ */ t("div", {
|
|
17
|
-
ref:
|
|
18
|
-
className:
|
|
42
|
+
ref: v,
|
|
43
|
+
className: a(f),
|
|
19
44
|
role: "toolbar",
|
|
20
|
-
...
|
|
45
|
+
..._,
|
|
21
46
|
children: e.map((e) => {
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
].filter(Boolean).join(" "), h = ["nabs-ui-toolbar__icon", c].filter(Boolean).join(" "), g = ["nabs-ui-toolbar__label", l].filter(Boolean).join(" "), _ = typeof e.label == "string" ? e.label : e.title;
|
|
47
|
+
let a = e.icon, f = !!e.label, _ = e.id === d || e.pressed === !0, v = o(r[i(e.labelPosition)]), y = s({
|
|
48
|
+
isActive: _,
|
|
49
|
+
hasLabel: f,
|
|
50
|
+
buttonClassName: p
|
|
51
|
+
}), b = c(m), x = l(h), S = u(e.label, e.title);
|
|
28
52
|
return /* @__PURE__ */ t("button", {
|
|
29
53
|
type: "button",
|
|
30
|
-
className:
|
|
54
|
+
className: y,
|
|
31
55
|
disabled: e.disabled,
|
|
32
56
|
title: e.title,
|
|
33
|
-
"aria-label":
|
|
57
|
+
"aria-label": S,
|
|
34
58
|
"aria-pressed": typeof e.pressed == "boolean" ? e.pressed : void 0,
|
|
35
59
|
onClick: (t) => {
|
|
36
|
-
|
|
60
|
+
g?.({
|
|
37
61
|
itemId: e.id,
|
|
38
62
|
item: e,
|
|
39
63
|
event: t
|
|
40
64
|
});
|
|
41
65
|
},
|
|
42
66
|
children: /* @__PURE__ */ n("span", {
|
|
43
|
-
className:
|
|
44
|
-
children: [
|
|
45
|
-
className:
|
|
67
|
+
className: v,
|
|
68
|
+
children: [a ? /* @__PURE__ */ t(a, {
|
|
69
|
+
className: b,
|
|
46
70
|
"aria-hidden": "true",
|
|
47
71
|
focusable: "false"
|
|
48
72
|
}) : null, e.label ? /* @__PURE__ */ t("span", {
|
|
49
|
-
className:
|
|
73
|
+
className: x,
|
|
50
74
|
children: e.label
|
|
51
75
|
}) : null]
|
|
52
76
|
})
|
|
@@ -54,6 +78,6 @@ var a = e(function({ items: e, activeItemId: a, className: o = "", buttonClassNa
|
|
|
54
78
|
})
|
|
55
79
|
});
|
|
56
80
|
});
|
|
57
|
-
|
|
81
|
+
d.displayName = "Toolbar";
|
|
58
82
|
//#endregion
|
|
59
|
-
export {
|
|
83
|
+
export { d as Toolbar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/toolbar.utils.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const labelPositionClasses: Record<ToolbarLabelPosition, string>;
|
|
3
|
-
export declare function normalizeLabelPosition(position: ToolbarLabelPosition | undefined): ToolbarLabelPosition;
|
|
1
|
+
export { labelPositionClasses, normalizeLabelPosition, } from './toolbar.model';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function buildToolbarClassName(className?: string): string;
|
|
2
|
+
export declare function buildToolbarContentClassName(labelPositionClass: string): string;
|
|
3
|
+
export declare function buildToolbarButtonClassName({ isActive, hasLabel, buttonClassName, }: {
|
|
4
|
+
isActive: boolean;
|
|
5
|
+
hasLabel: boolean;
|
|
6
|
+
buttonClassName?: string;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function buildToolbarIconClassName(iconClassName?: string): string;
|
|
9
|
+
export declare function buildToolbarLabelClassName(labelClassName?: string): string;
|
|
10
|
+
export declare function resolveToolbarAriaLabel(label: unknown, title: string | undefined): string | undefined;
|
|
11
|
+
export declare function toToolbarStateLabel({ active, itemCount, }: {
|
|
12
|
+
active: string | undefined;
|
|
13
|
+
itemCount: number;
|
|
14
|
+
}): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@net-advantage/nabs-ui-toolbar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.0",
|
|
4
4
|
"description": "Reusable toolbar control for the Nabs UI library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/nabs-ui-toolbar.cjs",
|
|
@@ -28,11 +28,16 @@
|
|
|
28
28
|
"@types/react": "^19.0.0",
|
|
29
29
|
"@types/react-dom": "^19.0.0",
|
|
30
30
|
"@vitejs/plugin-react": "^6.0.1",
|
|
31
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
31
32
|
"react-dom": "^19.2.6",
|
|
32
|
-
"vite": "^8.0.12"
|
|
33
|
+
"vite": "^8.0.12",
|
|
34
|
+
"vitest": "^3.2.4"
|
|
33
35
|
},
|
|
34
36
|
"scripts": {
|
|
35
37
|
"build": "vite build",
|
|
36
|
-
"dev": "vite"
|
|
38
|
+
"dev": "vite",
|
|
39
|
+
"test:unit": "vitest run",
|
|
40
|
+
"test:unit:watch": "vitest",
|
|
41
|
+
"test:unit:coverage": "vitest run --coverage --coverage.reporter=html --coverage.reporter=json-summary --coverage.reporter=text-summary"
|
|
37
42
|
}
|
|
38
43
|
}
|