@handijitcom/ui 3.7.0 → 3.9.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/README.md +121 -2
- package/build/components/AddToCart/index.cjs +2 -0
- package/build/components/AddToCart/index.cjs.map +1 -0
- package/build/components/AddToCart/index.d.cts +31 -0
- package/build/components/AddToCart/index.d.ts +31 -0
- package/build/components/AddToCart/index.js +62 -0
- package/build/components/AddToCart/index.js.map +1 -0
- package/build/components/AddToCart/style.css +1 -0
- package/build/components/CodeText/index.cjs.map +1 -1
- package/build/components/CodeText/index.js +11 -11
- package/build/components/CodeText/index.js.map +1 -1
- package/build/components/Heading/index.cjs +1 -1
- package/build/components/Heading/index.cjs.map +1 -1
- package/build/components/Heading/index.js +7 -7
- package/build/components/Heading/index.js.map +1 -1
- package/build/components/PartNumberList/index.cjs +2 -0
- package/build/components/PartNumberList/index.cjs.map +1 -0
- package/build/components/PartNumberList/index.d.cts +30 -0
- package/build/components/PartNumberList/index.d.ts +30 -0
- package/build/components/PartNumberList/index.js +36 -0
- package/build/components/PartNumberList/index.js.map +1 -0
- package/build/components/PartNumberList/style.css +1 -0
- package/build/components/ProductCard/index.cjs +2 -0
- package/build/components/ProductCard/index.cjs.map +1 -0
- package/build/components/ProductCard/index.d.cts +55 -0
- package/build/components/ProductCard/index.d.ts +55 -0
- package/build/components/ProductCard/index.js +58 -0
- package/build/components/ProductCard/index.js.map +1 -0
- package/build/components/ProductCard/style.css +1 -0
- package/build/components/ProductRow/columns.cjs +2 -0
- package/build/components/ProductRow/columns.cjs.map +1 -0
- package/build/components/ProductRow/columns.d.cts +27 -0
- package/build/components/ProductRow/columns.d.ts +27 -0
- package/build/components/ProductRow/columns.js +83 -0
- package/build/components/ProductRow/columns.js.map +1 -0
- package/build/components/ProductRow/index.cjs +2 -0
- package/build/components/ProductRow/index.cjs.map +1 -0
- package/build/components/ProductRow/index.d.cts +25 -0
- package/build/components/ProductRow/index.d.ts +25 -0
- package/build/components/ProductRow/index.js +43 -0
- package/build/components/ProductRow/index.js.map +1 -0
- package/build/components/ProductRow/parts.cjs +2 -0
- package/build/components/ProductRow/parts.cjs.map +1 -0
- package/build/components/ProductRow/parts.d.cts +32 -0
- package/build/components/ProductRow/parts.d.ts +32 -0
- package/build/components/ProductRow/parts.js +31 -0
- package/build/components/ProductRow/parts.js.map +1 -0
- package/build/components/ProductRow/style.css +1 -0
- package/build/components/QuantityStepper/index.cjs +1 -1
- package/build/components/QuantityStepper/index.cjs.map +1 -1
- package/build/components/QuantityStepper/index.js +28 -28
- package/build/components/QuantityStepper/index.js.map +1 -1
- package/build/components/SearchField/index.cjs +2 -0
- package/build/components/SearchField/index.cjs.map +1 -0
- package/build/components/SearchField/index.d.cts +84 -0
- package/build/components/SearchField/index.d.ts +84 -0
- package/build/components/SearchField/index.js +209 -0
- package/build/components/SearchField/index.js.map +1 -0
- package/build/components/SearchField/style.css +1 -0
- package/build/components/SpecTable/index.cjs +2 -0
- package/build/components/SpecTable/index.cjs.map +1 -0
- package/build/components/SpecTable/index.d.cts +25 -0
- package/build/components/SpecTable/index.d.ts +25 -0
- package/build/components/SpecTable/index.js +25 -0
- package/build/components/SpecTable/index.js.map +1 -0
- package/build/components/SpecTable/style.css +1 -0
- package/build/components/StatusCell/index.cjs +2 -0
- package/build/components/StatusCell/index.cjs.map +1 -0
- package/build/components/StatusCell/index.d.cts +28 -0
- package/build/components/StatusCell/index.d.ts +28 -0
- package/build/components/StatusCell/index.js +24 -0
- package/build/components/StatusCell/index.js.map +1 -0
- package/build/components/StatusCell/style.css +1 -0
- package/build/components/StockStatus/index.cjs +2 -0
- package/build/components/StockStatus/index.cjs.map +1 -0
- package/build/components/StockStatus/index.d.cts +28 -0
- package/build/components/StockStatus/index.d.ts +28 -0
- package/build/components/StockStatus/index.js +36 -0
- package/build/components/StockStatus/index.js.map +1 -0
- package/build/components/StockStatus/style.css +1 -0
- package/build/components/Tooltip/index.cjs +1 -1
- package/build/components/Tooltip/index.cjs.map +1 -1
- package/build/components/Tooltip/index.js +27 -27
- package/build/components/Tooltip/index.js.map +1 -1
- package/build/components/VehicleTypeList/index.cjs +2 -0
- package/build/components/VehicleTypeList/index.cjs.map +1 -0
- package/build/components/VehicleTypeList/index.d.cts +17 -0
- package/build/components/VehicleTypeList/index.d.ts +17 -0
- package/build/components/VehicleTypeList/index.js +47 -0
- package/build/components/VehicleTypeList/index.js.map +1 -0
- package/build/components/VehicleTypeList/style.css +1 -0
- package/build/index.cjs +1 -1
- package/build/index.d.cts +9 -0
- package/build/index.d.ts +9 -0
- package/build/index.js +143 -123
- package/build/index.js.map +1 -1
- package/build/styles.css +22 -0
- package/build/types/theme.type.d.cts +34 -0
- package/build/types/theme.type.d.ts +34 -0
- package/build/types/types/theme.type.d.cts +34 -0
- package/build/types/types/theme.type.d.ts +34 -0
- package/package.json +91 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as u, jsx as i, Fragment as oe } from "react/jsx-runtime";
|
|
3
|
+
import { memo as ce, useId as le, useRef as B, useState as C, useEffect as U, createElement as de } from "react";
|
|
4
|
+
import { Search as me, XLg as fe } from "react-bootstrap-icons";
|
|
5
|
+
import { cx as M } from "../../helpers/class-name.helper.js";
|
|
6
|
+
import { named as ue } from "../../helpers/component.helper.js";
|
|
7
|
+
import { resolveLabel as j, resolveFormatter as he } from "../../helpers/label.helper.js";
|
|
8
|
+
import { useUi as pe } from "../../theme/context.js";
|
|
9
|
+
import _e from "../IconButton/index.js";
|
|
10
|
+
import we from "../Kbd/index.js";
|
|
11
|
+
import ve from "../Link/index.js";
|
|
12
|
+
import Ne from "../Spinner/index.js";
|
|
13
|
+
const n = {"search":"ui-search-Abzqh","search__field":"ui-search__field-MzkYm","search__icon":"ui-search__icon-m1IlV","search__input":"ui-search__input-RgrxP","search__clear":"ui-search__clear--CN6D","search__hint":"ui-search__hint--ZH5p","search--lg":"ui-search--lg-pVRxQ","panel":"ui-panel-R34tt","panel__list":"ui-panel__list-qIxEJ","panel__state":"ui-panel__state-MCdll","panel__footer":"ui-panel__footer-ZsdOn","group":"ui-group-i-uv3","group__label":"ui-group__label-UhHAP","option":"ui-option-50fEl","option--active":"ui-option--active-v0s-d","option__media":"ui-option__media-x9T0F","option__media--image":"ui-option__media--image-RUh5j","option__text":"ui-option__text-FUX-q","option__label":"ui-option__label-ECvUx","option__description":"ui-option__description-i3O-z","option__mark":"ui-option__mark-E7qwn","srOnly":"ui-srOnly-eUiCZ"};
|
|
14
|
+
const ke = (a) => a instanceof HTMLElement && (a.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(a.tagName)), ye = (a, g) => {
|
|
15
|
+
const h = g.trim().toLocaleLowerCase("tr"), c = h ? a.toLocaleLowerCase("tr").indexOf(h) : -1;
|
|
16
|
+
return c < 0 ? a : /* @__PURE__ */ u(oe, { children: [
|
|
17
|
+
a.slice(0, c),
|
|
18
|
+
/* @__PURE__ */ i("mark", { className: n.option__mark, children: a.slice(c, c + h.length) }),
|
|
19
|
+
a.slice(c + h.length)
|
|
20
|
+
] });
|
|
21
|
+
}, Ee = ({
|
|
22
|
+
label: a,
|
|
23
|
+
name: g = "q",
|
|
24
|
+
action: h,
|
|
25
|
+
query: c,
|
|
26
|
+
defaultQuery: X = "",
|
|
27
|
+
onQueryChange: p,
|
|
28
|
+
debounceMs: q = 0,
|
|
29
|
+
placeholder: G,
|
|
30
|
+
groups: z = [],
|
|
31
|
+
highlight: J,
|
|
32
|
+
isLoading: N = !1,
|
|
33
|
+
emptyMessage: D,
|
|
34
|
+
footer: I,
|
|
35
|
+
onSelect: K,
|
|
36
|
+
onSubmit: L,
|
|
37
|
+
hasShortcut: k = !1,
|
|
38
|
+
size: V = "md",
|
|
39
|
+
labels: s,
|
|
40
|
+
id: W,
|
|
41
|
+
className: Y,
|
|
42
|
+
testId: Z
|
|
43
|
+
}) => {
|
|
44
|
+
const { labels: F } = pe(), r = F == null ? void 0 : F.searchField, w = le(), b = W ?? `${w}-input`, H = `${w}-list`, T = B(null), $ = B(null), A = B(void 0), [Q, P] = C(X), [x, l] = C(!1), [v, y] = C(-1), _ = c ?? Q, d = z.flatMap((e) => e.items.map((t) => ({ item: t, group: e }))), ee = _.trim() !== "", te = !N && d.length === 0, m = x && ee && (N || d.length > 0 || D !== void 0 || I !== void 0), O = (e) => `${w}-option-${e}`;
|
|
45
|
+
U(() => () => window.clearTimeout(A.current), []), U(() => {
|
|
46
|
+
if (!x) return;
|
|
47
|
+
const e = (t) => {
|
|
48
|
+
var o;
|
|
49
|
+
(o = T.current) != null && o.contains(t.target) || l(!1);
|
|
50
|
+
};
|
|
51
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
52
|
+
}, [x]), U(() => {
|
|
53
|
+
if (!k) return;
|
|
54
|
+
const e = (t) => {
|
|
55
|
+
var E;
|
|
56
|
+
const o = (t.metaKey || t.ctrlKey) && t.key.toLowerCase() === "k", f = t.key === "/" && !t.metaKey && !t.ctrlKey && !ke(t.target);
|
|
57
|
+
!o && !f || (t.preventDefault(), (E = $.current) == null || E.focus());
|
|
58
|
+
};
|
|
59
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
60
|
+
}, [k]);
|
|
61
|
+
const R = (e) => {
|
|
62
|
+
c === void 0 && P(e), y(-1), window.clearTimeout(A.current), q > 0 ? A.current = window.setTimeout(() => p == null ? void 0 : p(e), q) : p == null || p(e);
|
|
63
|
+
}, ne = (e) => {
|
|
64
|
+
l(!0), R(e.target.value);
|
|
65
|
+
}, ie = () => {
|
|
66
|
+
var e;
|
|
67
|
+
R(""), (e = $.current) == null || e.focus();
|
|
68
|
+
}, ae = (e) => {
|
|
69
|
+
var t;
|
|
70
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
71
|
+
if (e.preventDefault(), l(!0), d.length === 0) return;
|
|
72
|
+
const o = e.key === "ArrowDown" ? 1 : -1;
|
|
73
|
+
y(
|
|
74
|
+
(f) => f < 0 && o < 0 ? d.length - 1 : (f + o + d.length) % d.length
|
|
75
|
+
);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (e.key === "Enter" && m && v >= 0) {
|
|
79
|
+
e.preventDefault(), (t = document.getElementById(O(v))) == null || t.click();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
e.key === "Escape" && (m ? (e.preventDefault(), l(!1), y(-1)) : _ !== "" && (e.preventDefault(), R("")));
|
|
83
|
+
}, se = (e) => {
|
|
84
|
+
var t;
|
|
85
|
+
(t = T.current) != null && t.contains(e.relatedTarget) || l(!1);
|
|
86
|
+
}, re = J ?? _;
|
|
87
|
+
let S = -1;
|
|
88
|
+
return /* @__PURE__ */ u(
|
|
89
|
+
"form",
|
|
90
|
+
{
|
|
91
|
+
ref: T,
|
|
92
|
+
role: "search",
|
|
93
|
+
method: "get",
|
|
94
|
+
action: h,
|
|
95
|
+
className: M(n.search, n[`search--${V}`], Y),
|
|
96
|
+
"data-testid": Z,
|
|
97
|
+
onSubmit: (e) => L == null ? void 0 : L(_, e),
|
|
98
|
+
onBlur: se,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ u("div", { className: n.search__field, children: [
|
|
101
|
+
/* @__PURE__ */ i(me, { "aria-hidden": !0, className: n.search__icon }),
|
|
102
|
+
/* @__PURE__ */ i(
|
|
103
|
+
"input",
|
|
104
|
+
{
|
|
105
|
+
ref: $,
|
|
106
|
+
id: b,
|
|
107
|
+
type: "search",
|
|
108
|
+
name: g,
|
|
109
|
+
value: _,
|
|
110
|
+
placeholder: G,
|
|
111
|
+
"aria-label": a,
|
|
112
|
+
role: "combobox",
|
|
113
|
+
"aria-autocomplete": "list",
|
|
114
|
+
"aria-expanded": m,
|
|
115
|
+
"aria-controls": m ? H : void 0,
|
|
116
|
+
"aria-activedescendant": m && v >= 0 ? O(v) : void 0,
|
|
117
|
+
"aria-keyshortcuts": k ? "/ Control+K Meta+K" : void 0,
|
|
118
|
+
autoComplete: "off",
|
|
119
|
+
enterKeyHint: "search",
|
|
120
|
+
className: n.search__input,
|
|
121
|
+
onChange: ne,
|
|
122
|
+
onFocus: () => l(!0),
|
|
123
|
+
onClick: () => l(!0),
|
|
124
|
+
onKeyDown: ae
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
_ !== "" ? /* @__PURE__ */ i(
|
|
128
|
+
_e,
|
|
129
|
+
{
|
|
130
|
+
icon: /* @__PURE__ */ i(fe, { "aria-hidden": !0 }),
|
|
131
|
+
label: j("SearchField.labels.clear", s == null ? void 0 : s.clear, r == null ? void 0 : r.clear),
|
|
132
|
+
size: "sm",
|
|
133
|
+
className: n.search__clear,
|
|
134
|
+
onClick: ie
|
|
135
|
+
}
|
|
136
|
+
) : k && /* @__PURE__ */ i(we, { keys: ["/"], "aria-hidden": !0, className: n.search__hint })
|
|
137
|
+
] }),
|
|
138
|
+
/* @__PURE__ */ i("span", { role: "status", className: n.srOnly, children: m && (N ? j("SearchField.labels.loading", s == null ? void 0 : s.loading, r == null ? void 0 : r.loading) : he(
|
|
139
|
+
"SearchField.labels.results",
|
|
140
|
+
(s == null ? void 0 : s.results) ?? (r == null ? void 0 : r.results),
|
|
141
|
+
d.length
|
|
142
|
+
)) }),
|
|
143
|
+
m && /* @__PURE__ */ u("div", { className: n.panel, children: [
|
|
144
|
+
d.length > 0 && /* @__PURE__ */ i("div", { id: H, role: "listbox", "aria-label": a, className: n.panel__list, children: z.filter((e) => e.items.length > 0).map((e) => /* @__PURE__ */ u(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
role: "group",
|
|
148
|
+
"aria-labelledby": `${w}-group-${e.id}`,
|
|
149
|
+
className: n.group,
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ i("span", { id: `${w}-group-${e.id}`, className: n.group__label, children: e.label }),
|
|
152
|
+
e.items.map((t) => {
|
|
153
|
+
S += 1;
|
|
154
|
+
const o = S, f = o === v;
|
|
155
|
+
return /* @__PURE__ */ de(
|
|
156
|
+
ve,
|
|
157
|
+
{
|
|
158
|
+
...t.linkProps,
|
|
159
|
+
key: t.id,
|
|
160
|
+
id: O(o),
|
|
161
|
+
href: t.href,
|
|
162
|
+
role: "option",
|
|
163
|
+
"aria-selected": f,
|
|
164
|
+
tabIndex: -1,
|
|
165
|
+
className: M(n.option, f && n["option--active"]),
|
|
166
|
+
onMouseDown: (E) => E.preventDefault(),
|
|
167
|
+
onMouseMove: () => y(o),
|
|
168
|
+
onClick: () => {
|
|
169
|
+
K == null || K(t, e), l(!1);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
(t.image ?? t.icon) && /* @__PURE__ */ i(
|
|
173
|
+
"span",
|
|
174
|
+
{
|
|
175
|
+
"aria-hidden": !0,
|
|
176
|
+
className: M(
|
|
177
|
+
n.option__media,
|
|
178
|
+
t.image !== void 0 && n["option__media--image"]
|
|
179
|
+
),
|
|
180
|
+
children: t.image ?? t.icon
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ u("span", { className: n.option__text, children: [
|
|
184
|
+
/* @__PURE__ */ i("span", { className: n.option__label, children: ye(t.label, re) }),
|
|
185
|
+
t.description && /* @__PURE__ */ i("span", { className: n.option__description, children: t.description })
|
|
186
|
+
] })
|
|
187
|
+
);
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
e.id
|
|
192
|
+
)) }),
|
|
193
|
+
N && /* @__PURE__ */ u("p", { className: n.panel__state, children: [
|
|
194
|
+
/* @__PURE__ */ i(Ne, { size: "sm", label: "" }),
|
|
195
|
+
j("SearchField.labels.loading", s == null ? void 0 : s.loading, r == null ? void 0 : r.loading)
|
|
196
|
+
] }),
|
|
197
|
+
te && D !== void 0 && /* @__PURE__ */ i("p", { className: n.panel__state, children: D }),
|
|
198
|
+
I !== void 0 && /* @__PURE__ */ i("div", { className: n.panel__footer, children: I })
|
|
199
|
+
] })
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
}, Be = /* @__PURE__ */ ce(
|
|
204
|
+
/* @__PURE__ */ ue(Ee, "SearchField")
|
|
205
|
+
);
|
|
206
|
+
export {
|
|
207
|
+
Be as default
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/SearchField/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ChangeEvent,\n type FocusEvent,\n type FormEvent,\n type KeyboardEvent,\n memo,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { Search, XLg } from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { UiLinkExtraProps } from '../../types/link.type';\nimport type { Formatter } from '../../types/theme.type';\nimport IconButton from '../IconButton';\nimport Kbd from '../Kbd';\nimport UiLink from '../Link';\nimport Spinner from '../Spinner';\n\nimport styles from './index.module.scss';\n\n/** One suggestion: a part number, a product, a category, a vehicle type. */\nexport type SearchFieldItem = {\n id: string;\n label: string;\n /** One line under the label (\"IVECO · 428959612\"). */\n description?: string;\n href: string;\n /** A small icon before the label. */\n icon?: ReactNode;\n /** A 32px thumbnail (an `<img alt=\"\">`); wins over `icon`. */\n image?: ReactNode;\n linkProps?: UiLinkExtraProps;\n};\n\n/** A titled group of suggestions (\"Parça numaraları\", \"Ürünler\", \"Kategoriler\"). */\nexport type SearchFieldGroup = {\n id: string;\n label: string;\n items: SearchFieldItem[];\n};\n\nexport type SearchFieldLabels = {\n /** The clear button (\"Aramayı temizle\"). */\n clear: string;\n /** Read and shown while suggestions load (\"Aranıyor…\"). */\n loading: string;\n /** Read when suggestions arrive, e.g. `count => count + ' öneri'`. */\n results: Formatter<[count: number]>;\n};\n\ntype Props = {\n /** The field's accessible name (\"Parça ara\"); not shown — the placeholder and icon say it. */\n label: string;\n /** The query parameter of the GET form; default `q`. */\n name?: string;\n /** The results page the form submits to (`/arama`); the current page by default. */\n action?: string;\n /** Controlled query. */\n query?: string;\n /** Uncontrolled starting query (the `q` of the current results page). */\n defaultQuery?: string;\n /** Called as the query changes — after `debounceMs` of quiet when that is given. */\n onQueryChange?: (query: string) => void;\n /** Waits this long after the last keystroke before `onQueryChange`. Default 0 (every change). */\n debounceMs?: number;\n placeholder?: string;\n /** The suggestions; empty groups are not drawn. */\n groups?: SearchFieldGroup[];\n /** The text marked in each label; the typed query by default. */\n highlight?: string;\n isLoading?: boolean;\n /** Shown in the panel when a query has no suggestion (\"Sonuç yok\"). */\n emptyMessage?: ReactNode;\n /** Under the suggestions: \"Tüm sonuçları gör\". */\n footer?: ReactNode;\n /** A suggestion was chosen (before its link navigates). */\n onSelect?: (item: SearchFieldItem, group: SearchFieldGroup) => void;\n /**\n * The form is submitted with the typed query (Enter without a chosen suggestion). Call\n * `event.preventDefault()` to route it yourself; otherwise the browser loads `action?name=query`.\n */\n onSubmit?: (query: string, event: FormEvent<HTMLFormElement>) => void;\n /** \"/\" and Ctrl/⌘ K focus the field; a \"/\" hint shows while it is empty. */\n hasShortcut?: boolean;\n /** `md` 40px (default), `lg` 48px for a storefront header. */\n size?: 'md' | 'lg';\n labels?: Partial<SearchFieldLabels>;\n id?: string;\n className?: string;\n testId?: string;\n};\n\ntype Entry = { item: SearchFieldItem; group: SearchFieldGroup };\n\nconst isEditable = (target: EventTarget | null): boolean =>\n target instanceof HTMLElement &&\n (target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName));\n\n/** The label with the first match of `term` marked (Turkish case rules: \"i\" finds \"İ\"). */\nconst highlighted = (label: string, term: string): ReactNode => {\n const needle = term.trim().toLocaleLowerCase('tr');\n const start = needle ? label.toLocaleLowerCase('tr').indexOf(needle) : -1;\n if (start < 0) return label;\n\n return (\n <>\n {label.slice(0, start)}\n <mark className={styles.option__mark}>{label.slice(start, start + needle.length)}</mark>\n {label.slice(start + needle.length)}\n </>\n );\n};\n\n/**\n * SearchField (3.9) — a storefront's search: a search field (icon, clear button, no caret) in a\n * GET form that works without JavaScript, with grouped suggestions in a raised panel under it.\n * A combobox: ↑/↓ move through every group, Enter opens the active suggestion or submits the\n * query, Escape closes the panel and then clears the field; a press outside or leaving it closes.\n * @example\n * <SearchField label=\"Parça ara\" action=\"/arama\" placeholder=\"Parça no, ürün, araç tipi\"\n * groups={groups} isLoading={isLoading} onQueryChange={setQuery} debounceMs={200}\n * emptyMessage=\"Sonuç yok\" footer={<TextLink href={`/arama?q=${query}`}>Tüm sonuçları gör</TextLink>} hasShortcut />\n */\nconst SearchField = ({\n label,\n name = 'q',\n action,\n query: controlled,\n defaultQuery = '',\n onQueryChange,\n debounceMs = 0,\n placeholder,\n groups = [],\n highlight,\n isLoading = false,\n emptyMessage,\n footer,\n onSelect,\n onSubmit,\n hasShortcut = false,\n size = 'md',\n labels: labelProps,\n id,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const text = config?.searchField;\n const baseId = useId();\n const inputId = id ?? `${baseId}-input`;\n const listId = `${baseId}-list`;\n const rootRef = useRef<HTMLFormElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const timerRef = useRef<number | undefined>(undefined);\n\n const [own, setOwn] = useState(defaultQuery);\n const [isOpen, setIsOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n const value = controlled ?? own;\n\n const entries: Entry[] = groups.flatMap(group => group.items.map(item => ({ item, group })));\n const hasQuery = value.trim() !== '';\n const isEmpty = !isLoading && entries.length === 0;\n const isShown =\n isOpen &&\n hasQuery &&\n (isLoading || entries.length > 0 || emptyMessage !== undefined || footer !== undefined);\n const optionId = (index: number) => `${baseId}-option-${index}`;\n\n useEffect(() => () => window.clearTimeout(timerRef.current), []);\n\n /* A press outside the field and its panel closes the panel. */\n useEffect(() => {\n if (!isOpen) return;\n\n const handlePointerDown = (event: PointerEvent) => {\n if (!rootRef.current?.contains(event.target as Node)) setIsOpen(false);\n };\n document.addEventListener('pointerdown', handlePointerDown);\n\n return () => document.removeEventListener('pointerdown', handlePointerDown);\n }, [isOpen]);\n\n /* \"/\" (outside another field) and Ctrl/⌘ K bring the focus here. */\n useEffect(() => {\n if (!hasShortcut) return;\n\n const handleKeyDown = (event: globalThis.KeyboardEvent) => {\n const isCommand = (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k';\n const isSlash =\n event.key === '/' && !event.metaKey && !event.ctrlKey && !isEditable(event.target);\n if (!isCommand && !isSlash) return;\n\n event.preventDefault();\n inputRef.current?.focus();\n };\n document.addEventListener('keydown', handleKeyDown);\n\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [hasShortcut]);\n\n const change = (next: string) => {\n if (controlled === undefined) setOwn(next);\n setActiveIndex(-1);\n window.clearTimeout(timerRef.current);\n if (debounceMs > 0)\n timerRef.current = window.setTimeout(() => onQueryChange?.(next), debounceMs);\n else onQueryChange?.(next);\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setIsOpen(true);\n change(event.target.value);\n };\n\n const clear = () => {\n change('');\n inputRef.current?.focus();\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n setIsOpen(true);\n if (entries.length === 0) return;\n const step = event.key === 'ArrowDown' ? 1 : -1;\n setActiveIndex(current =>\n current < 0 && step < 0\n ? entries.length - 1\n : (current + step + entries.length) % entries.length,\n );\n return;\n }\n\n if (event.key === 'Enter' && isShown && activeIndex >= 0) {\n /* The suggestion's own link navigates (through the app's router link, when it has one). */\n event.preventDefault();\n document.getElementById(optionId(activeIndex))?.click();\n return;\n }\n\n if (event.key === 'Escape') {\n if (isShown) {\n event.preventDefault();\n setIsOpen(false);\n setActiveIndex(-1);\n } else if (value !== '') {\n event.preventDefault();\n change('');\n }\n }\n };\n\n /* Leaving the field and its panel (Tab) closes the panel. */\n const handleBlur = (event: FocusEvent<HTMLFormElement>) => {\n if (!rootRef.current?.contains(event.relatedTarget as Node | null)) setIsOpen(false);\n };\n\n const term = highlight ?? value;\n let index = -1;\n\n return (\n <form\n ref={rootRef}\n role=\"search\"\n method=\"get\"\n action={action}\n className={cx(styles.search, styles[`search--${size}`], className)}\n data-testid={testId}\n onSubmit={event => onSubmit?.(value, event)}\n onBlur={handleBlur}\n >\n <div className={styles.search__field}>\n <Search aria-hidden className={styles.search__icon} />\n <input\n ref={inputRef}\n id={inputId}\n type=\"search\"\n name={name}\n value={value}\n placeholder={placeholder}\n aria-label={label}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={isShown}\n aria-controls={isShown ? listId : undefined}\n aria-activedescendant={isShown && activeIndex >= 0 ? optionId(activeIndex) : undefined}\n aria-keyshortcuts={hasShortcut ? '/ Control+K Meta+K' : undefined}\n autoComplete=\"off\"\n enterKeyHint=\"search\"\n className={styles.search__input}\n onChange={handleChange}\n onFocus={() => setIsOpen(true)}\n onClick={() => setIsOpen(true)}\n onKeyDown={handleKeyDown}\n />\n {value !== '' ? (\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('SearchField.labels.clear', labelProps?.clear, text?.clear)}\n size=\"sm\"\n className={styles.search__clear}\n onClick={clear}\n />\n ) : (\n hasShortcut && <Kbd keys={['/']} aria-hidden className={styles.search__hint} />\n )}\n </div>\n\n <span role=\"status\" className={styles.srOnly}>\n {isShown &&\n (isLoading\n ? resolveLabel('SearchField.labels.loading', labelProps?.loading, text?.loading)\n : resolveFormatter(\n 'SearchField.labels.results',\n labelProps?.results ?? text?.results,\n entries.length,\n ))}\n </span>\n\n {isShown && (\n <div className={styles.panel}>\n {entries.length > 0 && (\n <div id={listId} role=\"listbox\" aria-label={label} className={styles.panel__list}>\n {groups\n .filter(group => group.items.length > 0)\n .map(group => (\n <div\n key={group.id}\n role=\"group\"\n aria-labelledby={`${baseId}-group-${group.id}`}\n className={styles.group}\n >\n <span id={`${baseId}-group-${group.id}`} className={styles.group__label}>\n {group.label}\n </span>\n {group.items.map(item => {\n index += 1;\n const position = index;\n const isActive = position === activeIndex;\n\n return (\n <UiLink\n {...item.linkProps}\n key={item.id}\n id={optionId(position)}\n href={item.href}\n role=\"option\"\n aria-selected={isActive}\n tabIndex={-1}\n className={cx(styles.option, isActive && styles['option--active'])}\n /* The focus stays in the field: the list is driven from there. */\n onMouseDown={(event: { preventDefault: () => void }) =>\n event.preventDefault()\n }\n onMouseMove={() => setActiveIndex(position)}\n onClick={() => {\n onSelect?.(item, group);\n setIsOpen(false);\n }}\n >\n {(item.image ?? item.icon) && (\n <span\n aria-hidden\n className={cx(\n styles.option__media,\n item.image !== undefined && styles['option__media--image'],\n )}\n >\n {item.image ?? item.icon}\n </span>\n )}\n <span className={styles.option__text}>\n <span className={styles.option__label}>\n {highlighted(item.label, term)}\n </span>\n {item.description && (\n <span className={styles.option__description}>{item.description}</span>\n )}\n </span>\n </UiLink>\n );\n })}\n </div>\n ))}\n </div>\n )}\n\n {isLoading && (\n <p className={styles.panel__state}>\n <Spinner size=\"sm\" label=\"\" />\n {resolveLabel('SearchField.labels.loading', labelProps?.loading, text?.loading)}\n </p>\n )}\n {isEmpty && emptyMessage !== undefined && (\n <p className={styles.panel__state}>{emptyMessage}</p>\n )}\n {footer !== undefined && <div className={styles.panel__footer}>{footer}</div>}\n </div>\n )}\n </form>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(SearchField, 'SearchField'),\n) as typeof SearchField;\n"],"names":["isEditable","target","highlighted","label","term","needle","start","jsxs","Fragment","jsx","styles","SearchField","name","action","controlled","defaultQuery","onQueryChange","debounceMs","placeholder","groups","highlight","isLoading","emptyMessage","footer","onSelect","onSubmit","hasShortcut","size","labelProps","id","className","testId","config","useUi","text","baseId","useId","inputId","listId","rootRef","useRef","inputRef","timerRef","own","setOwn","useState","isOpen","setIsOpen","activeIndex","setActiveIndex","value","entries","group","item","hasQuery","isEmpty","isShown","optionId","index","useEffect","handlePointerDown","event","_a","handleKeyDown","isCommand","isSlash","change","next","handleChange","clear","step","current","handleBlur","cx","Search","IconButton","XLg","resolveLabel","Kbd","resolveFormatter","position","isActive","createElement","UiLink","Spinner","memo","named"],"mappings":";;;;;;;;;;;;;AAuGA,MAAMA,KAAa,CAACC,MAClBA,aAAkB,gBACjBA,EAAO,qBAAqB,CAAC,SAAS,YAAY,QAAQ,EAAE,SAASA,EAAO,OAAO,IAGhFC,KAAc,CAACC,GAAeC,MAA4B;AAC9D,QAAMC,IAASD,EAAK,KAAA,EAAO,kBAAkB,IAAI,GAC3CE,IAAQD,IAASF,EAAM,kBAAkB,IAAI,EAAE,QAAQE,CAAM,IAAI;AACvE,SAAIC,IAAQ,IAAUH,IAGpB,gBAAAI,EAAAC,IAAA,EACG,UAAA;AAAA,IAAAL,EAAM,MAAM,GAAGG,CAAK;AAAA,IACrB,gBAAAG,EAAC,QAAA,EAAK,WAAWC,EAAO,cAAe,UAAAP,EAAM,MAAMG,GAAOA,IAAQD,EAAO,MAAM,EAAA,CAAE;AAAA,IAChFF,EAAM,MAAMG,IAAQD,EAAO,MAAM;AAAA,EAAA,GACpC;AAEJ,GAYMM,KAAc,CAAC;AAAA,EACnB,OAAAR;AAAA,EACA,MAAAS,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,OAAOC;AAAA,EACP,cAAAC,IAAe;AAAA,EACf,eAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,aAAAC;AAAA,EACA,QAAAC,IAAS,CAAA;AAAA,EACT,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,cAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAAC,IAAO;AAAA,EACP,QAAQC;AAAA,EACR,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC;A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AC/B;AAAA,sBACCiD,EAAK,eACJ,gBAAA5C,EAAC,QAAA,EAAK,WAAWC,EAAO,qBAAsB,YAAK,YAAA,CAAY;AAAA,oBAAA,EAAA,CAEnE;AAAA,kBAAA;AAAA,gBAGN,CAAC;AAAA,cAAA;AAAA,YAAA;AAAA,YAtDI0C,EAAM;AAAA,UAAA,CAwDd,GACL;AAAA,UAGD/B,KACC,gBAAAd,EAAC,KAAA,EAAE,WAAWG,EAAO,cACnB,UAAA;AAAA,YAAA,gBAAAD,EAAC2E,IAAA,EAAQ,MAAK,MAAK,OAAM,IAAG;AAAA,YAC3BP,EAAa,8BAA8BjD,KAAA,gBAAAA,EAAY,SAASM,KAAA,gBAAAA,EAAM,OAAO;AAAA,UAAA,GAChF;AAAA,UAEDqB,MAAWjC,MAAiB,UAC3B,gBAAAb,EAAC,OAAE,WAAWC,EAAO,cAAe,UAAAY,EAAA,CAAa;AAAA,UAElDC,MAAW,UAAa,gBAAAd,EAAC,SAAI,WAAWC,EAAO,eAAgB,UAAAa,EAAA,CAAO;AAAA,QAAA,EAAA,CACzE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,GAEAmC,KAA6B,gBAAA2B;AAAA,EACb,gBAAAC,GAAM3E,IAAa,aAAa;AAChD;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-search-Abzqh{position:relative;width:100%;min-width:0;margin:0}.ui-search__field-MzkYm{position:relative;display:flex;align-items:center}.ui-search__icon-m1IlV{position:absolute;inset-inline-start:var(--hd-space-3);font-size:18px;color:var(--hd-text-2);pointer-events:none}.ui-search__input-RgrxP{width:100%;font-family:var(--hd-font-body);font-size:var(--hd-type-body-size);line-height:var(--hd-type-h4-line-height);color:var(--hd-text);background-color:var(--hd-bg-surface);border:1px solid var(--hd-border-control);border-radius:var(--hd-radius-sm);padding:var(--hd-space-2) var(--hd-space-3);min-height:40px}@media (max-width: 640px){.ui-search__input-RgrxP{min-height:44px;font-size:max(16px,var(--hd-type-body-size))}}@media (hover: none) and (pointer: coarse){.ui-search__input-RgrxP{min-height:44px;font-size:max(16px,var(--hd-type-body-size))}}.ui-search__input-RgrxP{transition:border-color var(--hd-duration-fast) var(--hd-ease-standard),box-shadow var(--hd-duration-fast) var(--hd-ease-standard)}.ui-search__input-RgrxP::placeholder{color:var(--ui-placeholder, var(--hd-text-3))}.ui-search__input-RgrxP:hover:not(:disabled):not([aria-invalid=true]){border-color:color-mix(in oklab,var(--hd-border-control),var(--hd-text) 40%)}.ui-search__input-RgrxP:focus{outline:none;border-color:var(--ui-ring-color, var(--hd-focus));box-shadow:0 0 0 3px color-mix(in srgb,var(--hd-focus) 32%,transparent)}.ui-search__input-RgrxP:disabled{background-color:var(--hd-bg-raised);border-color:var(--hd-border);cursor:not-allowed;color:var(--hd-text-3)}@media (forced-colors: active){.ui-search__input-RgrxP:disabled{color:GrayText;border-color:GrayText}}.ui-search__input-RgrxP[aria-invalid=true]{border-color:var(--hd-danger-solid)}.ui-search__input-RgrxP[aria-invalid=true]:focus{box-shadow:0 0 0 3px color-mix(in srgb,var(--hd-danger-solid) 28%,transparent)}@media (prefers-reduced-motion: reduce){.ui-search__input-RgrxP{transition:none}}.ui-search__input-RgrxP{padding-inline:calc(var(--hd-space-3) + 18px + var(--hd-space-2)) calc(var(--hd-space-2) + 32px);-webkit-appearance:none;-moz-appearance:none;appearance:none}.ui-search__input-RgrxP::-webkit-search-cancel-button,.ui-search__input-RgrxP::-webkit-search-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}.ui-search__clear--CN6D,.ui-search__hint--ZH5p{position:absolute;inset-inline-end:var(--hd-space-2)}.ui-search__field-MzkYm:focus-within .ui-search__hint--ZH5p{display:none}.ui-search--lg-pVRxQ .ui-search__input-RgrxP{min-height:48px;font-size:max(16px,var(--hd-type-body-size))}.ui-panel-R34tt{position:absolute;inset-inline-start:0;top:calc(100% + var(--hd-space-1));z-index:var(--hd-z-dropdown);width:100%;min-width:min(20rem,100vw - 32px);max-height:min(70vh,30rem);overflow-y:auto;overscroll-behavior:contain;border:1px solid var(--hd-border);border-radius:var(--hd-radius-md);background-color:var(--hd-bg-overlay);box-shadow:var(--hd-shadow-2);animation:var(--ui-anim-fade-in-down) var(--hd-duration-fast) var(--hd-ease-enter);scrollbar-width:thin;scrollbar-color:var(--hd-border-strong) transparent}.ui-panel-R34tt::-webkit-scrollbar{width:8px;height:8px}.ui-panel-R34tt::-webkit-scrollbar-track{background:transparent}.ui-panel-R34tt::-webkit-scrollbar-thumb{background-color:var(--hd-border-strong);border-radius:var(--hd-radius-pill);border:2px solid transparent;background-clip:content-box}.ui-panel-R34tt::-webkit-scrollbar-thumb:hover{background-color:var(--hd-text-3)}@media (prefers-reduced-motion: reduce){.ui-panel-R34tt{animation:none}}.ui-panel__list-qIxEJ{display:flex;flex-direction:column;gap:var(--hd-space-2);padding:var(--hd-space-2)}.ui-panel__state-MCdll{display:flex;align-items:center;gap:var(--hd-space-2);margin:0;padding:var(--hd-space-3) var(--hd-space-4);font-size:var(--hd-type-small-size);color:var(--hd-text-2)}.ui-panel__footer-ZsdOn{padding:var(--hd-space-3) var(--hd-space-4);border-block-start:1px solid var(--hd-border);font-size:var(--hd-type-small-size)}.ui-group-i-uv3{display:flex;flex-direction:column;gap:2px}.ui-group__label-UhHAP{font-family:var(--ui-overline-font, var(--hd-font-body));font-size:var(--hd-type-small-size);font-weight:var(--hd-font-weight-semibold);line-height:var(--hd-type-h4-line-height);letter-spacing:var(--ui-overline-tracking, normal);text-transform:var(--ui-overline-transform, none);color:var(--hd-text-2);padding:var(--hd-space-1) var(--hd-space-2);font-size:var(--hd-type-caption-size)}.ui-option-50fEl{display:flex;align-items:center;gap:var(--hd-space-3);min-height:40px;padding:var(--hd-space-2);border-radius:var(--hd-radius-sm);color:var(--hd-text);font-size:var(--hd-type-small-size);text-decoration:none;cursor:pointer}.ui-option--active-v0s-d{background-color:color-mix(in srgb,var(--hd-text) 8%,transparent)}.ui-option__media-x9T0F{display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;width:20px;color:var(--hd-text-2);font-size:16px}.ui-option__media--image-RUh5j{width:32px;height:32px;overflow:hidden;border-radius:var(--hd-radius-xs);background-color:var(--hd-bg-raised)}.ui-option__media--image-RUh5j>img{width:100%;height:100%;object-fit:contain}.ui-option__text-FUX-q{display:flex;flex:1;flex-direction:column;min-width:0}.ui-option__label-ECvUx,.ui-option__description-i3O-z{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;display:block}.ui-option__description-i3O-z{font-size:var(--hd-type-caption-size);color:var(--hd-text-2)}.ui-option__mark-E7qwn{background:none;color:inherit;font-weight:var(--hd-font-weight-semibold)}@media (forced-colors: active){.ui-option--active-v0s-d{forced-color-adjust:none;background-color:Highlight;color:HighlightText}}.ui-srOnly-eUiCZ{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),d=require("react"),s=require("../../helpers/class-name.helper.cjs"),o=require("../../helpers/component.helper.cjs"),e={default:{"spec":"ui-spec-f8gOH","spec__caption":"ui-spec__caption-5uQ30","spec__row":"ui-spec__row-H1Mp5","spec__label":"ui-spec__label-PqkyV","spec__value":"ui-spec__value-3jDI7","spec__value--technical":"ui-spec__value--technical-8yySN","srOnly":"ui-srOnly-UYQ78"}},i=({items:c,caption:t,isCaptionVisible:r=!1,className:n,testId:u})=>c.length===0?null:l.jsxs("table",{className:s.cx(e.default.spec,n),"data-testid":u,children:[l.jsx("caption",{className:s.cx(e.default.spec__caption,!r&&e.default.srOnly),children:t}),l.jsx("tbody",{children:c.map(a=>l.jsxs("tr",{className:e.default.spec__row,children:[l.jsx("th",{scope:"row",className:e.default.spec__label,children:a.label}),l.jsx("td",{className:s.cx(e.default.spec__value,a.isTechnical&&e.default["spec__value--technical"]),children:a.value})]},a.label))})]}),p=d.memo(o.named(i,"SpecTable"));exports.default=p;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/SpecTable/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\n\nimport styles from './index.module.scss';\n\n/** One specification: \"Gerilim\" · \"24 V\". */\nexport type SpecItem = {\n label: string;\n value: ReactNode;\n /** A code or a measured value in mono (\"H7\", \"12 V 55 W\"): tabular, breaks anywhere. */\n isTechnical?: boolean;\n};\n\ntype Props = {\n items: readonly SpecItem[];\n /** The table's name (\"Teknik özellikler\"); read by a screen reader, shown only with `isCaptionVisible`. */\n caption: string;\n isCaptionVisible?: boolean;\n className?: string;\n testId?: string;\n};\n\n/**\n * SpecTable (3.8) — key → value specifications in two aligned columns: the key in secondary text at\n * a fixed share of the width, the value in the text colour, a hairline between rows, no zebra. A\n * native table, so a screen reader reads each value with its key.\n * @example <SpecTable caption=\"Teknik özellikler\" items={[{ label: 'Gerilim', value: '24 V' }, { label: 'Ampul', value: 'H7', isTechnical: true }]} />\n */\nconst SpecTable = ({ items, caption, isCaptionVisible = false, className, testId }: Props) => {\n if (items.length === 0) return null;\n\n return (\n <table className={cx(styles.spec, className)} data-testid={testId}>\n <caption className={cx(styles.spec__caption, !isCaptionVisible && styles.srOnly)}>\n {caption}\n </caption>\n <tbody>\n {items.map(item => (\n <tr key={item.label} className={styles.spec__row}>\n <th scope=\"row\" className={styles.spec__label}>\n {item.label}\n </th>\n <td\n className={cx(\n styles.spec__value,\n item.isTechnical && styles['spec__value--technical'],\n )}\n >\n {item.value}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(SpecTable, 'SpecTable')) as typeof SpecTable;\n"],"names":["SpecTable","items","caption","isCaptionVisible","className","testId","jsxs","cx","styles","jsx","item","index","memo","named"],"mappings":"0SA8BMA,EAAY,CAAC,CAAE,MAAAC,EAAO,QAAAC,EAAS,iBAAAC,EAAmB,GAAO,UAAAC,EAAW,OAAAC,KACpEJ,EAAM,SAAW,EAAU,KAG7BK,OAAC,SAAM,UAAWC,EAAAA,GAAGC,EAAAA,QAAO,KAAMJ,CAAS,EAAG,cAAaC,EACzD,SAAA,CAAAI,EAAAA,IAAC,UAAA,CAAQ,UAAWF,EAAAA,GAAGC,EAAAA,QAAO,cAAe,CAACL,GAAoBK,EAAAA,QAAO,MAAM,EAC5E,SAAAN,CAAA,CACH,EACAO,EAAAA,IAAC,SACE,SAAAR,EAAM,OACLK,EAAAA,KAAC,KAAA,CAAoB,UAAWE,EAAAA,QAAO,UACrC,SAAA,CAAAC,EAAAA,IAAC,MAAG,MAAM,MAAM,UAAWD,EAAAA,QAAO,YAC/B,WAAK,KAAA,CACR,EACAC,EAAAA,IAAC,KAAA,CACC,UAAWF,EAAAA,GACTC,EAAAA,QAAO,YACPE,EAAK,aAAeF,EAAAA,QAAO,wBAAwB,CAAA,EAGpD,SAAAE,EAAK,KAAA,CAAA,CACR,GAXOA,EAAK,KAYd,CACD,CAAA,CACH,CAAA,EACF,EAIJC,EAA6BC,OAAmBC,EAAAA,MAAMb,EAAW,WAAW,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** One specification: "Gerilim" · "24 V". */
|
|
3
|
+
export type SpecItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: ReactNode;
|
|
6
|
+
/** A code or a measured value in mono ("H7", "12 V 55 W"): tabular, breaks anywhere. */
|
|
7
|
+
isTechnical?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type Props = {
|
|
10
|
+
items: readonly SpecItem[];
|
|
11
|
+
/** The table's name ("Teknik özellikler"); read by a screen reader, shown only with `isCaptionVisible`. */
|
|
12
|
+
caption: string;
|
|
13
|
+
isCaptionVisible?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
testId?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* SpecTable (3.8) — key → value specifications in two aligned columns: the key in secondary text at
|
|
19
|
+
* a fixed share of the width, the value in the text colour, a hairline between rows, no zebra. A
|
|
20
|
+
* native table, so a screen reader reads each value with its key.
|
|
21
|
+
* @example <SpecTable caption="Teknik özellikler" items={[{ label: 'Gerilim', value: '24 V' }, { label: 'Ampul', value: 'H7', isTechnical: true }]} />
|
|
22
|
+
*/
|
|
23
|
+
declare const SpecTable: ({ items, caption, isCaptionVisible, className, testId }: Props) => import("react").JSX.Element | null;
|
|
24
|
+
declare const _default: typeof SpecTable;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** One specification: "Gerilim" · "24 V". */
|
|
3
|
+
export type SpecItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: ReactNode;
|
|
6
|
+
/** A code or a measured value in mono ("H7", "12 V 55 W"): tabular, breaks anywhere. */
|
|
7
|
+
isTechnical?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type Props = {
|
|
10
|
+
items: readonly SpecItem[];
|
|
11
|
+
/** The table's name ("Teknik özellikler"); read by a screen reader, shown only with `isCaptionVisible`. */
|
|
12
|
+
caption: string;
|
|
13
|
+
isCaptionVisible?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
testId?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* SpecTable (3.8) — key → value specifications in two aligned columns: the key in secondary text at
|
|
19
|
+
* a fixed share of the width, the value in the text colour, a hairline between rows, no zebra. A
|
|
20
|
+
* native table, so a screen reader reads each value with its key.
|
|
21
|
+
* @example <SpecTable caption="Teknik özellikler" items={[{ label: 'Gerilim', value: '24 V' }, { label: 'Ampul', value: 'H7', isTechnical: true }]} />
|
|
22
|
+
*/
|
|
23
|
+
declare const SpecTable: ({ items, caption, isCaptionVisible, className, testId }: Props) => import("react").JSX.Element | null;
|
|
24
|
+
declare const _default: typeof SpecTable;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs as r, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { memo as i } from "react";
|
|
3
|
+
import { cx as c } from "../../helpers/class-name.helper.js";
|
|
4
|
+
import { named as m } from "../../helpers/component.helper.js";
|
|
5
|
+
const e = {"spec":"ui-spec-f8gOH","spec__caption":"ui-spec__caption-5uQ30","spec__row":"ui-spec__row-H1Mp5","spec__label":"ui-spec__label-PqkyV","spec__value":"ui-spec__value-3jDI7","spec__value--technical":"ui-spec__value--technical-8yySN","srOnly":"ui-srOnly-UYQ78"};
|
|
6
|
+
const d = ({ items: s, caption: o, isCaptionVisible: t = !1, className: n, testId: p }) => s.length === 0 ? null : /* @__PURE__ */ r("table", { className: c(e.spec, n), "data-testid": p, children: [
|
|
7
|
+
/* @__PURE__ */ a("caption", { className: c(e.spec__caption, !t && e.srOnly), children: o }),
|
|
8
|
+
/* @__PURE__ */ a("tbody", { children: s.map((l) => /* @__PURE__ */ r("tr", { className: e.spec__row, children: [
|
|
9
|
+
/* @__PURE__ */ a("th", { scope: "row", className: e.spec__label, children: l.label }),
|
|
10
|
+
/* @__PURE__ */ a(
|
|
11
|
+
"td",
|
|
12
|
+
{
|
|
13
|
+
className: c(
|
|
14
|
+
e.spec__value,
|
|
15
|
+
l.isTechnical && e["spec__value--technical"]
|
|
16
|
+
),
|
|
17
|
+
children: l.value
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
] }, l.label)) })
|
|
21
|
+
] }), x = /* @__PURE__ */ i(/* @__PURE__ */ m(d, "SpecTable"));
|
|
22
|
+
export {
|
|
23
|
+
x as default
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/SpecTable/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\n\nimport styles from './index.module.scss';\n\n/** One specification: \"Gerilim\" · \"24 V\". */\nexport type SpecItem = {\n label: string;\n value: ReactNode;\n /** A code or a measured value in mono (\"H7\", \"12 V 55 W\"): tabular, breaks anywhere. */\n isTechnical?: boolean;\n};\n\ntype Props = {\n items: readonly SpecItem[];\n /** The table's name (\"Teknik özellikler\"); read by a screen reader, shown only with `isCaptionVisible`. */\n caption: string;\n isCaptionVisible?: boolean;\n className?: string;\n testId?: string;\n};\n\n/**\n * SpecTable (3.8) — key → value specifications in two aligned columns: the key in secondary text at\n * a fixed share of the width, the value in the text colour, a hairline between rows, no zebra. A\n * native table, so a screen reader reads each value with its key.\n * @example <SpecTable caption=\"Teknik özellikler\" items={[{ label: 'Gerilim', value: '24 V' }, { label: 'Ampul', value: 'H7', isTechnical: true }]} />\n */\nconst SpecTable = ({ items, caption, isCaptionVisible = false, className, testId }: Props) => {\n if (items.length === 0) return null;\n\n return (\n <table className={cx(styles.spec, className)} data-testid={testId}>\n <caption className={cx(styles.spec__caption, !isCaptionVisible && styles.srOnly)}>\n {caption}\n </caption>\n <tbody>\n {items.map(item => (\n <tr key={item.label} className={styles.spec__row}>\n <th scope=\"row\" className={styles.spec__label}>\n {item.label}\n </th>\n <td\n className={cx(\n styles.spec__value,\n item.isTechnical && styles['spec__value--technical'],\n )}\n >\n {item.value}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(SpecTable, 'SpecTable')) as typeof SpecTable;\n"],"names":["SpecTable","items","caption","isCaptionVisible","className","testId","jsxs","cx","styles","jsx","item","index","memo","named"],"mappings":";;;;;AA8BA,MAAMA,IAAY,CAAC,EAAE,OAAAC,GAAO,SAAAC,GAAS,kBAAAC,IAAmB,IAAO,WAAAC,GAAW,QAAAC,QACpEJ,EAAM,WAAW,IAAU,OAG7B,gBAAAK,EAAC,WAAM,WAAWC,EAAGC,EAAO,MAAMJ,CAAS,GAAG,eAAaC,GACzD,UAAA;AAAA,EAAA,gBAAAI,EAAC,WAAA,EAAQ,WAAWF,EAAGC,EAAO,eAAe,CAACL,KAAoBK,EAAO,MAAM,GAC5E,UAAAN,EAAA,CACH;AAAA,EACA,gBAAAO,EAAC,WACE,UAAAR,EAAM,IAAI,OACT,gBAAAK,EAAC,MAAA,EAAoB,WAAWE,EAAO,WACrC,UAAA;AAAA,IAAA,gBAAAC,EAAC,QAAG,OAAM,OAAM,WAAWD,EAAO,aAC/B,YAAK,MAAA,CACR;AAAA,IACA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWF;AAAA,UACTC,EAAO;AAAA,UACPE,EAAK,eAAeF,EAAO,wBAAwB;AAAA,QAAA;AAAA,QAGpD,UAAAE,EAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EACR,KAXOA,EAAK,KAYd,CACD,EAAA,CACH;AAAA,GACF,GAIJC,IAA6B,gBAAAC,EAAmB,gBAAAC,EAAMb,GAAW,WAAW,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-spec-f8gOH{width:100%;border-collapse:collapse;font-size:var(--hd-type-small-size);line-height:var(--hd-type-body-line-height)}.ui-spec__caption-5uQ30{font-family:var(--hd-font-body);font-size:var(--hd-type-body-size);font-weight:var(--hd-font-weight-semibold);line-height:var(--hd-type-h4-line-height);letter-spacing:normal;color:var(--hd-text);padding-block-end:var(--hd-space-3);text-align:start}.ui-spec__row-H1Mp5{border-block-end:1px solid var(--hd-border)}.ui-spec__row-H1Mp5:last-child{border-block-end:none}.ui-spec__label-PqkyV,.ui-spec__value-3jDI7{padding:var(--hd-space-2) 0;vertical-align:top;text-align:start}.ui-spec__label-PqkyV{width:40%;min-width:9rem;padding-inline-end:var(--hd-space-4);font-weight:var(--hd-font-weight-regular);color:var(--hd-text-2)}.ui-spec__value-3jDI7{min-width:0;font-weight:var(--hd-font-weight-medium);color:var(--hd-text);overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.ui-spec__value--technical-8yySN{font-family:var(--hd-font-mono);font-size:var(--hd-type-small-size);letter-spacing:.02em;font-variant-numeric:tabular-nums}@media (max-width: 640px){.ui-spec__label-PqkyV{width:45%;min-width:0}}.ui-srOnly-UYQ78{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),c=require("react"),n=require("../../helpers/class-name.helper.cjs"),i=require("../../helpers/component.helper.cjs"),u=require("../Tooltip/index.cjs"),l={default:{"cell":"ui-cell-2fptK","flag":"ui-flag-iwCGx","flag--danger":"ui-flag--danger-McGO0","flag--info":"ui-flag--info-LleFX","flag--ink":"ui-flag--ink-Yq0PB"}},d=({status:s,flags:a=[],className:o,testId:r})=>t.jsxs("span",{className:n.cx(l.default.cell,o),"data-testid":r,children:[s,a.map(e=>t.jsx(u.default,{content:e.label,children:t.jsx("span",{role:"img","aria-label":e.label,className:n.cx(l.default.flag,l.default[`flag--${e.tone??"ink"}`]),children:e.icon})},e.id))]}),m=c.memo(i.named(d,"StatusCell"));exports.default=m;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/StatusCell/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport Tooltip from '../Tooltip';\n\nimport styles from './index.module.scss';\n\n/** `danger` a fault (limit exceeded) · `info` cobalt · `ink` the emphatic neutral (a warning). */\nexport type StatusFlagTone = 'danger' | 'info' | 'ink';\n\n/** A secondary state of a row: an icon with its words in a tooltip and for a screen reader. */\nexport type StatusFlag = {\n id: string;\n icon: ReactNode;\n /** \"Limit aşımı\" — the tooltip and the text a screen reader reads. */\n label: string;\n tone?: StatusFlagTone;\n};\n\ntype Props = {\n /** The one primary state, usually a `Badge` (\"Onay bekliyor\"). */\n status: ReactNode;\n /** Secondary states, as icons after it. */\n flags?: readonly StatusFlag[];\n className?: string;\n testId?: string;\n};\n\n/**\n * StatusCell (3.8) — the status rule of a table: ONE primary state per cell (a badge), any second\n * state (\"Limit aşımı\") an icon with its words in a tooltip. Two stacked badges doubled the row's\n * height and read as two equal states. One line, never wraps.\n * @example <StatusCell status={<Badge tone=\"info\">Onay bekliyor</Badge>} flags={[{ id: 'limit', icon: <ExclamationTriangle />, label: 'Limit aşımı', tone: 'danger' }]} />\n */\nconst StatusCell = ({ status, flags = [], className, testId }: Props) => (\n <span className={cx(styles.cell, className)} data-testid={testId}>\n {status}\n {flags.map(flag => (\n <Tooltip key={flag.id} content={flag.label}>\n <span\n role=\"img\"\n aria-label={flag.label}\n className={cx(styles.flag, styles[`flag--${flag.tone ?? 'ink'}`])}\n >\n {flag.icon}\n </span>\n </Tooltip>\n ))}\n </span>\n);\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(StatusCell, 'StatusCell'),\n) as typeof StatusCell;\n"],"names":["StatusCell","status","flags","className","testId","jsxs","cx","styles","flag","Tooltip","jsx","index","memo","named"],"mappings":"4UAmCMA,EAAa,CAAC,CAAE,OAAAC,EAAQ,MAAAC,EAAQ,CAAA,EAAI,UAAAC,EAAW,OAAAC,CAAA,IACnDC,OAAC,OAAA,CAAK,UAAWC,EAAAA,GAAGC,EAAAA,QAAO,KAAMJ,CAAS,EAAG,cAAaC,EACvD,SAAA,CAAAH,EACAC,EAAM,IAAIM,SACRC,EAAAA,QAAA,CAAsB,QAASD,EAAK,MACnC,SAAAE,EAAAA,IAAC,OAAA,CACC,KAAK,MACL,aAAYF,EAAK,MACjB,UAAWF,EAAAA,GAAGC,UAAO,KAAMA,EAAAA,QAAO,SAASC,EAAK,MAAQ,KAAK,EAAE,CAAC,EAE/D,SAAAA,EAAK,IAAA,CAAA,CACR,EAPYA,EAAK,EAQnB,CACD,CAAA,EACH,EAGFG,EAA6BC,EAAAA,KACbC,EAAAA,MAAMb,EAAY,YAAY,CAC9C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** `danger` a fault (limit exceeded) · `info` cobalt · `ink` the emphatic neutral (a warning). */
|
|
3
|
+
export type StatusFlagTone = 'danger' | 'info' | 'ink';
|
|
4
|
+
/** A secondary state of a row: an icon with its words in a tooltip and for a screen reader. */
|
|
5
|
+
export type StatusFlag = {
|
|
6
|
+
id: string;
|
|
7
|
+
icon: ReactNode;
|
|
8
|
+
/** "Limit aşımı" — the tooltip and the text a screen reader reads. */
|
|
9
|
+
label: string;
|
|
10
|
+
tone?: StatusFlagTone;
|
|
11
|
+
};
|
|
12
|
+
type Props = {
|
|
13
|
+
/** The one primary state, usually a `Badge` ("Onay bekliyor"). */
|
|
14
|
+
status: ReactNode;
|
|
15
|
+
/** Secondary states, as icons after it. */
|
|
16
|
+
flags?: readonly StatusFlag[];
|
|
17
|
+
className?: string;
|
|
18
|
+
testId?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* StatusCell (3.8) — the status rule of a table: ONE primary state per cell (a badge), any second
|
|
22
|
+
* state ("Limit aşımı") an icon with its words in a tooltip. Two stacked badges doubled the row's
|
|
23
|
+
* height and read as two equal states. One line, never wraps.
|
|
24
|
+
* @example <StatusCell status={<Badge tone="info">Onay bekliyor</Badge>} flags={[{ id: 'limit', icon: <ExclamationTriangle />, label: 'Limit aşımı', tone: 'danger' }]} />
|
|
25
|
+
*/
|
|
26
|
+
declare const StatusCell: ({ status, flags, className, testId }: Props) => import("react").JSX.Element;
|
|
27
|
+
declare const _default: typeof StatusCell;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** `danger` a fault (limit exceeded) · `info` cobalt · `ink` the emphatic neutral (a warning). */
|
|
3
|
+
export type StatusFlagTone = 'danger' | 'info' | 'ink';
|
|
4
|
+
/** A secondary state of a row: an icon with its words in a tooltip and for a screen reader. */
|
|
5
|
+
export type StatusFlag = {
|
|
6
|
+
id: string;
|
|
7
|
+
icon: ReactNode;
|
|
8
|
+
/** "Limit aşımı" — the tooltip and the text a screen reader reads. */
|
|
9
|
+
label: string;
|
|
10
|
+
tone?: StatusFlagTone;
|
|
11
|
+
};
|
|
12
|
+
type Props = {
|
|
13
|
+
/** The one primary state, usually a `Badge` ("Onay bekliyor"). */
|
|
14
|
+
status: ReactNode;
|
|
15
|
+
/** Secondary states, as icons after it. */
|
|
16
|
+
flags?: readonly StatusFlag[];
|
|
17
|
+
className?: string;
|
|
18
|
+
testId?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* StatusCell (3.8) — the status rule of a table: ONE primary state per cell (a badge), any second
|
|
22
|
+
* state ("Limit aşımı") an icon with its words in a tooltip. Two stacked badges doubled the row's
|
|
23
|
+
* height and read as two equal states. One line, never wraps.
|
|
24
|
+
* @example <StatusCell status={<Badge tone="info">Onay bekliyor</Badge>} flags={[{ id: 'limit', icon: <ExclamationTriangle />, label: 'Limit aşımı', tone: 'danger' }]} />
|
|
25
|
+
*/
|
|
26
|
+
declare const StatusCell: ({ status, flags, className, testId }: Props) => import("react").JSX.Element;
|
|
27
|
+
declare const _default: typeof StatusCell;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { memo as n } from "react";
|
|
3
|
+
import { cx as l } from "../../helpers/class-name.helper.js";
|
|
4
|
+
import { named as c } from "../../helpers/component.helper.js";
|
|
5
|
+
import p from "../Tooltip/index.js";
|
|
6
|
+
const t = {"cell":"ui-cell-2fptK","flag":"ui-flag-iwCGx","flag--danger":"ui-flag--danger-McGO0","flag--info":"ui-flag--info-LleFX","flag--ink":"ui-flag--ink-Yq0PB"};
|
|
7
|
+
const d = ({ status: m, flags: r = [], className: a, testId: i }) => /* @__PURE__ */ s("span", { className: l(t.cell, a), "data-testid": i, children: [
|
|
8
|
+
m,
|
|
9
|
+
r.map((o) => /* @__PURE__ */ e(p, { content: o.label, children: /* @__PURE__ */ e(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
role: "img",
|
|
13
|
+
"aria-label": o.label,
|
|
14
|
+
className: l(t.flag, t[`flag--${o.tone ?? "ink"}`]),
|
|
15
|
+
children: o.icon
|
|
16
|
+
}
|
|
17
|
+
) }, o.id))
|
|
18
|
+
] }), C = /* @__PURE__ */ n(
|
|
19
|
+
/* @__PURE__ */ c(d, "StatusCell")
|
|
20
|
+
);
|
|
21
|
+
export {
|
|
22
|
+
C as default
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/StatusCell/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport Tooltip from '../Tooltip';\n\nimport styles from './index.module.scss';\n\n/** `danger` a fault (limit exceeded) · `info` cobalt · `ink` the emphatic neutral (a warning). */\nexport type StatusFlagTone = 'danger' | 'info' | 'ink';\n\n/** A secondary state of a row: an icon with its words in a tooltip and for a screen reader. */\nexport type StatusFlag = {\n id: string;\n icon: ReactNode;\n /** \"Limit aşımı\" — the tooltip and the text a screen reader reads. */\n label: string;\n tone?: StatusFlagTone;\n};\n\ntype Props = {\n /** The one primary state, usually a `Badge` (\"Onay bekliyor\"). */\n status: ReactNode;\n /** Secondary states, as icons after it. */\n flags?: readonly StatusFlag[];\n className?: string;\n testId?: string;\n};\n\n/**\n * StatusCell (3.8) — the status rule of a table: ONE primary state per cell (a badge), any second\n * state (\"Limit aşımı\") an icon with its words in a tooltip. Two stacked badges doubled the row's\n * height and read as two equal states. One line, never wraps.\n * @example <StatusCell status={<Badge tone=\"info\">Onay bekliyor</Badge>} flags={[{ id: 'limit', icon: <ExclamationTriangle />, label: 'Limit aşımı', tone: 'danger' }]} />\n */\nconst StatusCell = ({ status, flags = [], className, testId }: Props) => (\n <span className={cx(styles.cell, className)} data-testid={testId}>\n {status}\n {flags.map(flag => (\n <Tooltip key={flag.id} content={flag.label}>\n <span\n role=\"img\"\n aria-label={flag.label}\n className={cx(styles.flag, styles[`flag--${flag.tone ?? 'ink'}`])}\n >\n {flag.icon}\n </span>\n </Tooltip>\n ))}\n </span>\n);\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(StatusCell, 'StatusCell'),\n) as typeof StatusCell;\n"],"names":["StatusCell","status","flags","className","testId","jsxs","cx","styles","flag","Tooltip","jsx","index","memo","named"],"mappings":";;;;;;AAmCA,MAAMA,IAAa,CAAC,EAAE,QAAAC,GAAQ,OAAAC,IAAQ,CAAA,GAAI,WAAAC,GAAW,QAAAC,EAAA,MACnD,gBAAAC,EAAC,QAAA,EAAK,WAAWC,EAAGC,EAAO,MAAMJ,CAAS,GAAG,eAAaC,GACvD,UAAA;AAAA,EAAAH;AAAA,EACAC,EAAM,IAAI,CAAAM,wBACRC,GAAA,EAAsB,SAASD,EAAK,OACnC,UAAA,gBAAAE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAYF,EAAK;AAAA,MACjB,WAAWF,EAAGC,EAAO,MAAMA,EAAO,SAASC,EAAK,QAAQ,KAAK,EAAE,CAAC;AAAA,MAE/D,UAAAA,EAAK;AAAA,IAAA;AAAA,EAAA,EACR,GAPYA,EAAK,EAQnB,CACD;AAAA,GACH,GAGFG,IAA6B,gBAAAC;AAAA,EACb,gBAAAC,EAAMb,GAAY,YAAY;AAC9C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-cell-2fptK{display:inline-flex;align-items:center;gap:var(--hd-space-2);max-width:100%;white-space:nowrap}.ui-flag-iwCGx{display:inline-flex;flex-shrink:0;font-size:16px}.ui-flag-iwCGx>svg{display:block}.ui-flag--danger-McGO0{color:var(--hd-danger-fg)}.ui-flag--info-LleFX{color:var(--hd-info-fg)}.ui-flag--ink-Yq0PB{color:var(--hd-text-2)}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("react"),i=require("../../helpers/class-name.helper.cjs"),_=require("../../helpers/component.helper.cjs"),m=require("../Tooltip/index.cjs"),s={default:{"stock":"ui-stock-5lVkX","stock__dot":"ui-stock__dot-UjW-T","stock__label":"ui-stock__label-TQ5Ci","stock--available":"ui-stock--available-7dfJO","stock--limited":"ui-stock--limited-ZN9v8","stock--unavailable":"ui-stock--unavailable-8qF7O","breakdown":"ui-breakdown-q7J66","breakdown__row":"ui-breakdown__row-TlBme","breakdown__value":"ui-breakdown__value-jKf9J"}},p=({tone:r,label:a,breakdown:n=[],className:o,testId:d})=>{const l=n.length>0,c=e.jsxs("span",{className:i.cx(s.default.stock,s.default[`stock--${r}`],o),title:l?void 0:a,"data-testid":d,children:[e.jsx("span",{"aria-hidden":!0,className:s.default.stock__dot}),e.jsx("span",{className:s.default.stock__label,children:a})]});return l?e.jsx(m.default,{content:e.jsx("span",{className:s.default.breakdown,children:n.map(t=>e.jsxs("span",{className:s.default.breakdown__row,children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:s.default.breakdown__value,children:t.value})]},t.label))}),children:c}):c},x=u.memo(_.named(p,"StockStatus"));exports.default=x;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/StockStatus/index.tsx"],"sourcesContent":["import { type FC, memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport Tooltip from '../Tooltip';\n\nimport styles from './index.module.scss';\n\n/**\n * `available` in stock (cobalt, a filled dot) · `limited` low or on supply (ink, a ring) ·\n * `unavailable` out of stock (red, a filled dot). The shape and the words carry it as well.\n */\nexport type StockTone = 'available' | 'limited' | 'unavailable';\n\n/** One line of the warehouse breakdown: \"İstanbul\" · \"24\". */\nexport type StockBreakdownItem = { label: string; value: ReactNode };\n\ntype Props = {\n tone: StockTone;\n /** The words: \"Stokta (24)\", \"Son 3 adet\", \"2 günde tedarik\", \"Stokta yok\". */\n label: string;\n /** Per-warehouse stock, shown in a tooltip on the status (hover, focus, long press). */\n breakdown?: StockBreakdownItem[];\n className?: string;\n testId?: string;\n};\n\n/**\n * StockStatus (3.8) — a stock state in colour, shape AND words, on one line: a dot and the label,\n * with the warehouse breakdown in a tooltip. The same in a card, a table row and a product page.\n * @example <StockStatus tone=\"available\" label=\"Stokta (24)\" breakdown={[{ label: 'İstanbul', value: 20 }, { label: 'Ankara', value: 4 }]} />\n */\nconst StockStatus: FC<Props> = ({ tone, label, breakdown = [], className, testId }) => {\n const hasBreakdown = breakdown.length > 0;\n const status = (\n <span\n className={cx(styles.stock, styles[`stock--${tone}`], className)}\n title={hasBreakdown ? undefined : label}\n data-testid={testId}\n >\n <span aria-hidden className={styles.stock__dot} />\n <span className={styles.stock__label}>{label}</span>\n </span>\n );\n\n if (!hasBreakdown) return status;\n\n return (\n <Tooltip\n content={\n <span className={styles.breakdown}>\n {breakdown.map(item => (\n <span key={item.label} className={styles.breakdown__row}>\n <span>{item.label}</span>\n <span className={styles.breakdown__value}>{item.value}</span>\n </span>\n ))}\n </span>\n }\n >\n {status}\n </Tooltip>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(StockStatus, 'StockStatus'),\n) as typeof StockStatus;\n"],"names":["StockStatus","tone","label","breakdown","className","testId","hasBreakdown","status","jsxs","cx","styles","jsx","Tooltip","item","index","memo","named"],"mappings":"4UAgCMA,EAAyB,CAAC,CAAE,KAAAC,EAAM,MAAAC,EAAO,UAAAC,EAAY,GAAI,UAAAC,EAAW,OAAAC,KAAa,CACrF,MAAMC,EAAeH,EAAU,OAAS,EAClCI,EACJC,EAAAA,KAAC,OAAA,CACC,UAAWC,EAAAA,GAAGC,EAAAA,QAAO,MAAOA,EAAAA,QAAO,UAAUT,CAAI,EAAE,EAAGG,CAAS,EAC/D,MAAOE,EAAe,OAAYJ,EAClC,cAAaG,EAEb,SAAA,CAAAM,EAAAA,IAAC,OAAA,CAAK,cAAW,GAAC,UAAWD,EAAAA,QAAO,WAAY,EAChDC,EAAAA,IAAC,OAAA,CAAK,UAAWD,EAAAA,QAAO,aAAe,SAAAR,CAAA,CAAM,CAAA,CAAA,CAAA,EAIjD,OAAKI,EAGHK,EAAAA,IAACC,EAAAA,QAAA,CACC,QACED,EAAAA,IAAC,OAAA,CAAK,UAAWD,UAAO,UACrB,SAAAP,EAAU,IAAIU,GACbL,EAAAA,KAAC,OAAA,CAAsB,UAAWE,EAAAA,QAAO,eACvC,SAAA,CAAAC,EAAAA,IAAC,OAAA,CAAM,WAAK,KAAA,CAAM,QACjB,OAAA,CAAK,UAAWD,EAAAA,QAAO,iBAAmB,WAAK,KAAA,CAAM,CAAA,CAAA,EAF7CG,EAAK,KAGhB,CACD,EACH,EAGD,SAAAN,CAAA,CAAA,EAfqBA,CAkB5B,EAEAO,EAA6BC,EAAAA,KACbC,EAAAA,MAAMhB,EAAa,aAAa,CAChD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `available` in stock (cobalt, a filled dot) · `limited` low or on supply (ink, a ring) ·
|
|
4
|
+
* `unavailable` out of stock (red, a filled dot). The shape and the words carry it as well.
|
|
5
|
+
*/
|
|
6
|
+
export type StockTone = 'available' | 'limited' | 'unavailable';
|
|
7
|
+
/** One line of the warehouse breakdown: "İstanbul" · "24". */
|
|
8
|
+
export type StockBreakdownItem = {
|
|
9
|
+
label: string;
|
|
10
|
+
value: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type Props = {
|
|
13
|
+
tone: StockTone;
|
|
14
|
+
/** The words: "Stokta (24)", "Son 3 adet", "2 günde tedarik", "Stokta yok". */
|
|
15
|
+
label: string;
|
|
16
|
+
/** Per-warehouse stock, shown in a tooltip on the status (hover, focus, long press). */
|
|
17
|
+
breakdown?: StockBreakdownItem[];
|
|
18
|
+
className?: string;
|
|
19
|
+
testId?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* StockStatus (3.8) — a stock state in colour, shape AND words, on one line: a dot and the label,
|
|
23
|
+
* with the warehouse breakdown in a tooltip. The same in a card, a table row and a product page.
|
|
24
|
+
* @example <StockStatus tone="available" label="Stokta (24)" breakdown={[{ label: 'İstanbul', value: 20 }, { label: 'Ankara', value: 4 }]} />
|
|
25
|
+
*/
|
|
26
|
+
declare const StockStatus: FC<Props>;
|
|
27
|
+
declare const _default: typeof StockStatus;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `available` in stock (cobalt, a filled dot) · `limited` low or on supply (ink, a ring) ·
|
|
4
|
+
* `unavailable` out of stock (red, a filled dot). The shape and the words carry it as well.
|
|
5
|
+
*/
|
|
6
|
+
export type StockTone = 'available' | 'limited' | 'unavailable';
|
|
7
|
+
/** One line of the warehouse breakdown: "İstanbul" · "24". */
|
|
8
|
+
export type StockBreakdownItem = {
|
|
9
|
+
label: string;
|
|
10
|
+
value: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type Props = {
|
|
13
|
+
tone: StockTone;
|
|
14
|
+
/** The words: "Stokta (24)", "Son 3 adet", "2 günde tedarik", "Stokta yok". */
|
|
15
|
+
label: string;
|
|
16
|
+
/** Per-warehouse stock, shown in a tooltip on the status (hover, focus, long press). */
|
|
17
|
+
breakdown?: StockBreakdownItem[];
|
|
18
|
+
className?: string;
|
|
19
|
+
testId?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* StockStatus (3.8) — a stock state in colour, shape AND words, on one line: a dot and the label,
|
|
23
|
+
* with the warehouse breakdown in a tooltip. The same in a card, a table row and a product page.
|
|
24
|
+
* @example <StockStatus tone="available" label="Stokta (24)" breakdown={[{ label: 'İstanbul', value: 20 }, { label: 'Ankara', value: 4 }]} />
|
|
25
|
+
*/
|
|
26
|
+
declare const StockStatus: FC<Props>;
|
|
27
|
+
declare const _default: typeof StockStatus;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { memo as i } from "react";
|
|
3
|
+
import { cx as p } from "../../helpers/class-name.helper.js";
|
|
4
|
+
import { named as h } from "../../helpers/component.helper.js";
|
|
5
|
+
import k from "../Tooltip/index.js";
|
|
6
|
+
const s = {"stock":"ui-stock-5lVkX","stock__dot":"ui-stock__dot-UjW-T","stock__label":"ui-stock__label-TQ5Ci","stock--available":"ui-stock--available-7dfJO","stock--limited":"ui-stock--limited-ZN9v8","stock--unavailable":"ui-stock--unavailable-8qF7O","breakdown":"ui-breakdown-q7J66","breakdown__row":"ui-breakdown__row-TlBme","breakdown__value":"ui-breakdown__value-jKf9J"};
|
|
7
|
+
const u = ({ tone: l, label: o, breakdown: e = [], className: m, testId: d }) => {
|
|
8
|
+
const r = e.length > 0, n = /* @__PURE__ */ c(
|
|
9
|
+
"span",
|
|
10
|
+
{
|
|
11
|
+
className: p(s.stock, s[`stock--${l}`], m),
|
|
12
|
+
title: r ? void 0 : o,
|
|
13
|
+
"data-testid": d,
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ a("span", { "aria-hidden": !0, className: s.stock__dot }),
|
|
16
|
+
/* @__PURE__ */ a("span", { className: s.stock__label, children: o })
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
return r ? /* @__PURE__ */ a(
|
|
21
|
+
k,
|
|
22
|
+
{
|
|
23
|
+
content: /* @__PURE__ */ a("span", { className: s.breakdown, children: e.map((t) => /* @__PURE__ */ c("span", { className: s.breakdown__row, children: [
|
|
24
|
+
/* @__PURE__ */ a("span", { children: t.label }),
|
|
25
|
+
/* @__PURE__ */ a("span", { className: s.breakdown__value, children: t.value })
|
|
26
|
+
] }, t.label)) }),
|
|
27
|
+
children: n
|
|
28
|
+
}
|
|
29
|
+
) : n;
|
|
30
|
+
}, S = /* @__PURE__ */ i(
|
|
31
|
+
/* @__PURE__ */ h(u, "StockStatus")
|
|
32
|
+
);
|
|
33
|
+
export {
|
|
34
|
+
S as default
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.js.map
|