@handijitcom/ui 3.6.1 → 3.8.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 +275 -36
- package/build/chat.cjs +3 -3
- package/build/chat.cjs.map +1 -1
- package/build/chat.css +1 -1
- package/build/chat.js +168 -160
- package/build/chat.js.map +1 -1
- 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/Alert/index.cjs +1 -1
- package/build/components/Alert/index.cjs.map +1 -1
- package/build/components/Alert/index.d.cts +7 -0
- package/build/components/Alert/index.d.ts +7 -0
- package/build/components/Alert/index.js +32 -19
- package/build/components/Alert/index.js.map +1 -1
- package/build/components/Alert/style.css +1 -1
- package/build/components/AppShell/style.css +1 -1
- package/build/components/AppliedFilters/style.css +1 -1
- 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/CommandPalette/style.css +1 -1
- package/build/components/Directory/style.css +1 -1
- package/build/components/EmptyState/style.css +1 -1
- package/build/components/FacetSection/index.cjs +1 -1
- package/build/components/FacetSection/index.cjs.map +1 -1
- package/build/components/FacetSection/index.js +145 -138
- package/build/components/FacetSection/index.js.map +1 -1
- package/build/components/FacetSection/style.css +1 -1
- package/build/components/FacetSidebar/index.cjs +1 -1
- package/build/components/FacetSidebar/index.cjs.map +1 -1
- package/build/components/FacetSidebar/index.js +22 -29
- package/build/components/FacetSidebar/index.js.map +1 -1
- package/build/components/Heading/index.cjs +2 -0
- package/build/components/Heading/index.cjs.map +1 -0
- package/build/components/Heading/index.d.cts +34 -0
- package/build/components/Heading/index.d.ts +34 -0
- package/build/components/Heading/index.js +44 -0
- package/build/components/Heading/index.js.map +1 -0
- package/build/components/Heading/style.css +1 -0
- package/build/components/MegaMenu/index.cjs +1 -1
- package/build/components/MegaMenu/index.cjs.map +1 -1
- package/build/components/MegaMenu/index.d.cts +5 -1
- package/build/components/MegaMenu/index.d.ts +5 -1
- package/build/components/MegaMenu/index.js +131 -111
- package/build/components/MegaMenu/index.js.map +1 -1
- package/build/components/MegaMenu/style.css +1 -1
- package/build/components/Modal/style.css +1 -1
- package/build/components/NotificationCenter/style.css +1 -1
- package/build/components/PageHeader/style.css +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/Price/index.cjs +1 -1
- package/build/components/Price/index.cjs.map +1 -1
- package/build/components/Price/index.d.cts +5 -1
- package/build/components/Price/index.d.ts +5 -1
- package/build/components/Price/index.js +31 -32
- package/build/components/Price/index.js.map +1 -1
- package/build/components/Price/style.css +1 -1
- 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/Radio/style.css +1 -1
- package/build/components/SectionHeader/style.css +1 -1
- 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/Stat/index.cjs +1 -1
- package/build/components/Stat/index.cjs.map +1 -1
- package/build/components/Stat/index.d.cts +7 -3
- package/build/components/Stat/index.d.ts +7 -3
- package/build/components/Stat/index.js +61 -66
- package/build/components/Stat/index.js.map +1 -1
- package/build/components/StatCard/StatDelta.cjs +2 -0
- package/build/components/StatCard/StatDelta.cjs.map +1 -0
- package/build/components/StatCard/StatDelta.d.cts +17 -0
- package/build/components/StatCard/StatDelta.d.ts +17 -0
- package/build/components/StatCard/StatDelta.js +45 -0
- package/build/components/StatCard/StatDelta.js.map +1 -0
- package/build/components/StatCard/index.cjs +2 -0
- package/build/components/StatCard/index.cjs.map +1 -0
- package/build/components/StatCard/index.d.cts +36 -0
- package/build/components/StatCard/index.d.ts +36 -0
- package/build/components/StatCard/index.js +60 -0
- package/build/components/StatCard/index.js.map +1 -0
- package/build/components/StatCard/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/Table/style.css +1 -1
- package/build/components/Tabs/index.cjs +1 -1
- package/build/components/Tabs/index.cjs.map +1 -1
- package/build/components/Tabs/index.d.cts +26 -1
- package/build/components/Tabs/index.d.ts +26 -1
- package/build/components/Tabs/index.js +140 -112
- package/build/components/Tabs/index.js.map +1 -1
- package/build/components/Tabs/style.css +1 -1
- package/build/components/Text/index.cjs +2 -0
- package/build/components/Text/index.cjs.map +1 -0
- package/build/components/Text/index.d.cts +49 -0
- package/build/components/Text/index.d.ts +49 -0
- package/build/components/Text/index.js +47 -0
- package/build/components/Text/index.js.map +1 -0
- package/build/components/Text/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/design/index.cjs +12 -2
- package/build/design/index.cjs.map +1 -1
- package/build/design/index.d.cts +1 -5
- package/build/design/index.d.mts +1 -5
- package/build/design/index.mjs +12 -2
- package/build/design/index.mjs.map +1 -1
- package/build/design/index.umd.cjs +1 -1
- package/build/design/index.umd.cjs.map +1 -1
- package/build/design/tokens.css +29 -4
- package/build/design/tokens.json +42 -2
- package/build/design/tokens.scss +55 -0
- package/build/helpers/text.helper.cjs +1 -1
- package/build/helpers/text.helper.cjs.map +1 -1
- package/build/helpers/text.helper.d.cts +5 -0
- package/build/helpers/text.helper.d.ts +5 -0
- package/build/helpers/text.helper.js +3 -2
- package/build/helpers/text.helper.js.map +1 -1
- package/build/index.cjs +1 -1
- package/build/index.d.cts +13 -2
- package/build/index.d.ts +13 -2
- package/build/index.js +203 -179
- package/build/index.js.map +1 -1
- package/build/scss/_mixins.scss +101 -13
- package/build/scss/_variables.scss +5 -1
- package/build/styles.css +43 -17
- package/build/types/chat/DescriptionList/index.d.cts +6 -0
- package/build/types/chat/DescriptionList/index.d.ts +6 -0
- package/build/types/stat.type.d.cts +2 -0
- package/build/types/stat.type.d.ts +2 -0
- package/build/types/theme.type.d.cts +25 -0
- package/build/types/theme.type.d.ts +25 -0
- package/build/types/types/theme.type.d.cts +25 -0
- package/build/types/types/theme.type.d.ts +25 -0
- package/package.json +111 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** One cross-reference: "OEM" · "IVECO" · "428959612". */
|
|
2
|
+
export type PartNumberItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
/** The kind of number ("OEM", "Muadil", "Üretici"). */
|
|
5
|
+
type: string;
|
|
6
|
+
brand: string;
|
|
7
|
+
number: string;
|
|
8
|
+
};
|
|
9
|
+
type Props = {
|
|
10
|
+
items: readonly PartNumberItem[];
|
|
11
|
+
/** The table's name ("Parça numaraları"), read by a screen reader. */
|
|
12
|
+
caption: string;
|
|
13
|
+
/** Headings instead of `labels.product` (`numberType`, `brand`, `number`). */
|
|
14
|
+
labels?: Partial<{
|
|
15
|
+
numberType: string;
|
|
16
|
+
brand: string;
|
|
17
|
+
number: string;
|
|
18
|
+
}>;
|
|
19
|
+
className?: string;
|
|
20
|
+
testId?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* PartNumberList (3.8) — the part numbers of a product in a table: kind · brand · number, the number
|
|
24
|
+
* in mono with a copy button. The kind is plain text (no "——" prefix, no ink pill): the three
|
|
25
|
+
* columns line up down the list, so OEM and equivalent numbers are told apart by reading.
|
|
26
|
+
* @example <PartNumberList caption="Parça numaraları" items={[{ id: '1', type: 'OEM', brand: 'IVECO', number: '428959612' }]} />
|
|
27
|
+
*/
|
|
28
|
+
declare const PartNumberList: ({ items, caption, labels: labelProps, className, testId }: Props) => import("react").JSX.Element | null;
|
|
29
|
+
declare const _default: typeof PartNumberList;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** One cross-reference: "OEM" · "IVECO" · "428959612". */
|
|
2
|
+
export type PartNumberItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
/** The kind of number ("OEM", "Muadil", "Üretici"). */
|
|
5
|
+
type: string;
|
|
6
|
+
brand: string;
|
|
7
|
+
number: string;
|
|
8
|
+
};
|
|
9
|
+
type Props = {
|
|
10
|
+
items: readonly PartNumberItem[];
|
|
11
|
+
/** The table's name ("Parça numaraları"), read by a screen reader. */
|
|
12
|
+
caption: string;
|
|
13
|
+
/** Headings instead of `labels.product` (`numberType`, `brand`, `number`). */
|
|
14
|
+
labels?: Partial<{
|
|
15
|
+
numberType: string;
|
|
16
|
+
brand: string;
|
|
17
|
+
number: string;
|
|
18
|
+
}>;
|
|
19
|
+
className?: string;
|
|
20
|
+
testId?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* PartNumberList (3.8) — the part numbers of a product in a table: kind · brand · number, the number
|
|
24
|
+
* in mono with a copy button. The kind is plain text (no "——" prefix, no ink pill): the three
|
|
25
|
+
* columns line up down the list, so OEM and equivalent numbers are told apart by reading.
|
|
26
|
+
* @example <PartNumberList caption="Parça numaraları" items={[{ id: '1', type: 'OEM', brand: 'IVECO', number: '428959612' }]} />
|
|
27
|
+
*/
|
|
28
|
+
declare const PartNumberList: ({ items, caption, labels: labelProps, className, testId }: Props) => import("react").JSX.Element | null;
|
|
29
|
+
declare const _default: typeof PartNumberList;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { memo as h } from "react";
|
|
4
|
+
import { cx as p } from "../../helpers/class-name.helper.js";
|
|
5
|
+
import { named as u } from "../../helpers/component.helper.js";
|
|
6
|
+
import { resolveLabel as b } from "../../helpers/label.helper.js";
|
|
7
|
+
import { useUi as N } from "../../theme/context.js";
|
|
8
|
+
import _ from "../CodeText/index.js";
|
|
9
|
+
const t = {"list":"ui-list-11FlO","list__type":"ui-list__type-KKVWQ","list__brand":"ui-list__brand-Z7-n1","list__number":"ui-list__number-kF8I2","srOnly":"ui-srOnly-tjFuj"};
|
|
10
|
+
const f = ({ items: l, caption: o, labels: s, className: a, testId: d }) => {
|
|
11
|
+
const { labels: c } = N();
|
|
12
|
+
if (l.length === 0) return null;
|
|
13
|
+
const n = (r) => {
|
|
14
|
+
var m;
|
|
15
|
+
return b(`PartNumberList.labels.${r}`, s == null ? void 0 : s[r], (m = c == null ? void 0 : c.product) == null ? void 0 : m[r]);
|
|
16
|
+
};
|
|
17
|
+
return /* @__PURE__ */ i("table", { className: p(t.list, a), "data-testid": d, children: [
|
|
18
|
+
/* @__PURE__ */ e("caption", { className: t.srOnly, children: o }),
|
|
19
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
|
|
20
|
+
/* @__PURE__ */ e("th", { scope: "col", className: t.list__type, children: n("numberType") }),
|
|
21
|
+
/* @__PURE__ */ e("th", { scope: "col", className: t.list__brand, children: n("brand") }),
|
|
22
|
+
/* @__PURE__ */ e("th", { scope: "col", children: n("number") })
|
|
23
|
+
] }) }),
|
|
24
|
+
/* @__PURE__ */ e("tbody", { children: l.map((r) => /* @__PURE__ */ i("tr", { children: [
|
|
25
|
+
/* @__PURE__ */ e("td", { className: t.list__type, children: r.type }),
|
|
26
|
+
/* @__PURE__ */ e("td", { className: t.list__brand, children: r.brand }),
|
|
27
|
+
/* @__PURE__ */ e("td", { className: t.list__number, children: /* @__PURE__ */ e(_, { code: r.number, isCopyable: !0, size: "md" }) })
|
|
28
|
+
] }, r.id)) })
|
|
29
|
+
] });
|
|
30
|
+
}, z = /* @__PURE__ */ h(
|
|
31
|
+
/* @__PURE__ */ u(f, "PartNumberList")
|
|
32
|
+
);
|
|
33
|
+
export {
|
|
34
|
+
z as default
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/PartNumberList/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport CodeText from '../CodeText';\n\nimport styles from './index.module.scss';\n\n/** One cross-reference: \"OEM\" · \"IVECO\" · \"428959612\". */\nexport type PartNumberItem = {\n id: string;\n /** The kind of number (\"OEM\", \"Muadil\", \"Üretici\"). */\n type: string;\n brand: string;\n number: string;\n};\n\ntype Props = {\n items: readonly PartNumberItem[];\n /** The table's name (\"Parça numaraları\"), read by a screen reader. */\n caption: string;\n /** Headings instead of `labels.product` (`numberType`, `brand`, `number`). */\n labels?: Partial<{ numberType: string; brand: string; number: string }>;\n className?: string;\n testId?: string;\n};\n\n/**\n * PartNumberList (3.8) — the part numbers of a product in a table: kind · brand · number, the number\n * in mono with a copy button. The kind is plain text (no \"——\" prefix, no ink pill): the three\n * columns line up down the list, so OEM and equivalent numbers are told apart by reading.\n * @example <PartNumberList caption=\"Parça numaraları\" items={[{ id: '1', type: 'OEM', brand: 'IVECO', number: '428959612' }]} />\n */\nconst PartNumberList = ({ items, caption, labels: labelProps, className, testId }: Props) => {\n const { labels } = useUi();\n if (items.length === 0) return null;\n\n const heading = (field: 'numberType' | 'brand' | 'number') =>\n resolveLabel(`PartNumberList.labels.${field}`, labelProps?.[field], labels?.product?.[field]);\n\n return (\n <table className={cx(styles.list, className)} data-testid={testId}>\n <caption className={styles.srOnly}>{caption}</caption>\n <thead>\n <tr>\n <th scope=\"col\" className={styles.list__type}>\n {heading('numberType')}\n </th>\n <th scope=\"col\" className={styles.list__brand}>\n {heading('brand')}\n </th>\n <th scope=\"col\">{heading('number')}</th>\n </tr>\n </thead>\n <tbody>\n {items.map(item => (\n <tr key={item.id}>\n <td className={styles.list__type}>{item.type}</td>\n <td className={styles.list__brand}>{item.brand}</td>\n <td className={styles.list__number}>\n <CodeText code={item.number} isCopyable size=\"md\" />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(PartNumberList, 'PartNumberList'),\n) as typeof PartNumberList;\n"],"names":["PartNumberList","items","caption","labelProps","className","testId","labels","useUi","heading","field","resolveLabel","_a","jsxs","cx","styles","jsx","item","CodeText","index","memo","named"],"mappings":";;;;;;;;;AAoCA,MAAMA,IAAiB,CAAC,EAAE,OAAAC,GAAO,SAAAC,GAAS,QAAQC,GAAY,WAAAC,GAAW,QAAAC,QAAoB;AAC3F,QAAM,EAAE,QAAAC,EAAA,IAAWC,EAAA;AACnB,MAAIN,EAAM,WAAW,EAAG,QAAO;AAE/B,QAAMO,IAAU,CAACC,MAAA;;AACf,WAAAC,EAAa,yBAAyBD,CAAK,IAAIN,KAAA,gBAAAA,EAAaM,KAAQE,IAAAL,KAAA,gBAAAA,EAAQ,YAAR,gBAAAK,EAAkBF,EAAM;AAAA;AAE9F,SACE,gBAAAG,EAAC,WAAM,WAAWC,EAAGC,EAAO,MAAMV,CAAS,GAAG,eAAaC,GACzD,UAAA;AAAA,IAAA,gBAAAU,EAAC,WAAA,EAAQ,WAAWD,EAAO,QAAS,UAAAZ,GAAQ;AAAA,IAC5C,gBAAAa,EAAC,SAAA,EACC,UAAA,gBAAAH,EAAC,MAAA,EACC,UAAA;AAAA,MAAA,gBAAAG,EAAC,MAAA,EAAG,OAAM,OAAM,WAAWD,EAAO,YAC/B,UAAAN,EAAQ,YAAY,EAAA,CACvB;AAAA,MACA,gBAAAO,EAAC,QAAG,OAAM,OAAM,WAAWD,EAAO,aAC/B,UAAAN,EAAQ,OAAO,EAAA,CAClB;AAAA,wBACC,MAAA,EAAG,OAAM,OAAO,UAAAA,EAAQ,QAAQ,EAAA,CAAE;AAAA,IAAA,EAAA,CACrC,EAAA,CACF;AAAA,sBACC,SAAA,EACE,UAAAP,EAAM,IAAI,CAAAe,wBACR,MAAA,EACC,UAAA;AAAA,MAAA,gBAAAD,EAAC,MAAA,EAAG,WAAWD,EAAO,YAAa,YAAK,MAAK;AAAA,wBAC5C,MAAA,EAAG,WAAWA,EAAO,aAAc,YAAK,OAAM;AAAA,MAC/C,gBAAAC,EAAC,MAAA,EAAG,WAAWD,EAAO,cACpB,UAAA,gBAAAC,EAACE,GAAA,EAAS,MAAMD,EAAK,QAAQ,YAAU,IAAC,MAAK,MAAK,EAAA,CACpD;AAAA,IAAA,KALOA,EAAK,EAMd,CACD,EAAA,CACH;AAAA,EAAA,GACF;AAEJ,GAEAE,IAA6B,gBAAAC;AAAA,EACb,gBAAAC,EAAMpB,GAAgB,gBAAgB;AACtD;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-list-11FlO{width:100%;border-collapse:collapse;font-size:var(--hd-type-small-size)}.ui-list-11FlO th,.ui-list-11FlO td{padding:var(--hd-space-2) var(--hd-space-3);border-block-end:1px solid var(--hd-border);text-align:start;vertical-align:middle}.ui-list-11FlO th:first-child,.ui-list-11FlO td:first-child{padding-inline-start:0}.ui-list-11FlO th{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);font-size:var(--hd-type-caption-size);white-space:nowrap}.ui-list-11FlO tbody tr:last-child td{border-block-end:none}.ui-list__type-KKVWQ{width:1%;white-space:nowrap;color:var(--hd-text-2)}.ui-list__brand-Z7-n1{width:30%;color:var(--hd-text);overflow-wrap:anywhere}.ui-list__number-kF8I2{min-width:0}.ui-srOnly-tjFuj{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),q=require("react"),d=require("../../helpers/class-name.helper.cjs"),I=require("../../helpers/label.helper.cjs"),S=require("../../theme/context.cjs"),s={default:{"price":"ui-price-Oc5Nr","price__current":"ui-price__current-2Xup2","price__currency":"ui-price__currency-32NLN","price__currency--prefix":"ui-price__currency--prefix-dlva8","price__list":"ui-price__list-MlQgT","price__discount":"ui-price__discount-5Yc6W","price--sm":"ui-price--sm-Hd8Oe","price--md":"ui-price--md-JMxlK","price--lg":"ui-price--lg-TFqIF","price--xl":"ui-price--xl-EJBYq","price--inherit":"ui-price--inherit-Ao5Jj"}},v="₺",m=/^[-\u2212]/,f="−",F=n=>m.test(n)?`${f}${n.slice(1)}`:n,M=({value:n,currency:p,currencyPosition:x,listValue:l,discountPercent:i,formatDiscount:_=r=>`%${r}`,isFormatted:h,size:N="md",className:j,testId:g})=>{const{labels:r}=S.useUi(),u=I.resolveLabel("Price.currency",p,r==null?void 0:r.currency),y=(x??(u===v?"prefix":"suffix"))==="prefix",b=c=>{if(!h||!(r!=null&&r.locale)||!/\d/.test(c))return c;const t=Number(c.replace(/[^\d.,-]/g,"").replace(/\.(?=\d{3}\b)/g,"").replace(",","."));if(!Number.isFinite(t))return c;try{return new Intl.NumberFormat(r.locale).format(t)}catch{return c}},a=c=>{const t=F(b(c));if(!y)return e.jsxs(e.Fragment,{children:[t,e.jsx("span",{className:s.default.price__currency,children:u})]});const o=m.test(t)?f:"";return e.jsxs(e.Fragment,{children:[o,e.jsx("span",{className:d.cx(s.default.price__currency,s.default["price__currency--prefix"]),children:u}),t.slice(o.length)]})};return e.jsxs("span",{className:d.cx(s.default.price,s.default[`price--${N}`],j),"data-testid":g,children:[e.jsx("span",{className:s.default.price__current,children:a(n)}),l&&e.jsx("s",{className:s.default.price__list,children:a(l)}),i!==void 0&&i>0&&e.jsx("span",{className:s.default.price__discount,children:_(i)})]})},$=q.memo(M);exports.default=$;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Price/index.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\n\nimport styles from './index.module.scss';\n\n/** `prefix`: \"₺2.649,57\". `suffix`: \"2.649,57₺\". */\nexport type PriceCurrencyPosition = 'prefix' | 'suffix';\n\ntype Props = {\n /** BİÇİMLENMİŞ tutar: \"1.299,90\". */\n value: string;\n /** Para birimi simgesi ya da kodu. */\n currency?: string;\n /**\n * Where the symbol sits. Default: `prefix` for \"₺\" — the ecosystem's lira format, as\n * `@handijitcom/tr` `formatLira` writes it (\"₺2.649,57\", \"-₺0,05\", no space) — and `suffix` for any\n * other symbol or code (\"2.649,57 TL\" style, as before 3.2.1).\n */\n currencyPosition?: PriceCurrencyPosition;\n /** Değeri `Intl.NumberFormat` ile biçimlendirir. */\n isFormatted?: boolean;\n /** Üstü çizili liste fiyatı; indirim varsa verilir (biçimlenmiş). */\n listValue?: string;\n /** İndirim oranı (tam sayı yüzde). */\n discountPercent?: number;\n /** İndirim rozetinin metnini üretir (\"%20\", \"-20%\"). */\n formatDiscount?: (percent: number) => string;\n size?: 'sm' | 'md' | 'lg' | 'xl';\n className?: string;\n testId?: string;\n};\n\n/** The lira sign: written before the amount by default (3.2.1). */\nconst LIRA_SIGN = '₺';\n/* A leading minus (ASCII or U+2212) stays in front of a prefixed symbol: \"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Price/index.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\n\nimport styles from './index.module.scss';\n\n/** `prefix`: \"₺2.649,57\". `suffix`: \"2.649,57₺\". */\nexport type PriceCurrencyPosition = 'prefix' | 'suffix';\n\ntype Props = {\n /** BİÇİMLENMİŞ tutar: \"1.299,90\". */\n value: string;\n /** Para birimi simgesi ya da kodu. */\n currency?: string;\n /**\n * Where the symbol sits. Default: `prefix` for \"₺\" — the ecosystem's lira format, as\n * `@handijitcom/tr` `formatLira` writes it (\"₺2.649,57\", \"-₺0,05\", no space) — and `suffix` for any\n * other symbol or code (\"2.649,57 TL\" style, as before 3.2.1).\n */\n currencyPosition?: PriceCurrencyPosition;\n /** Değeri `Intl.NumberFormat` ile biçimlendirir. */\n isFormatted?: boolean;\n /** Üstü çizili liste fiyatı; indirim varsa verilir (biçimlenmiş). */\n listValue?: string;\n /** İndirim oranı (tam sayı yüzde). */\n discountPercent?: number;\n /** İndirim rozetinin metnini üretir (\"%20\", \"-20%\"). */\n formatDiscount?: (percent: number) => string;\n /**\n * `inherit` (3.7) takes the size of the surrounding text: a price inside a `StatCard` value, a\n * `TotalsList` row or a table cell follows that slot instead of bringing its own size.\n */\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'inherit';\n className?: string;\n testId?: string;\n};\n\n/** The lira sign: written before the amount by default (3.2.1). */\nconst LIRA_SIGN = '₺';\n/* A leading minus (ASCII or U+2212) stays in front of a prefixed symbol: \"−₺0,05\". */\nconst SIGN = /^[-\\u2212]/;\n/*\n * 3.7: the minus is drawn as the typographic minus (U+2212), as wide as a digit and level with\n * the plus — \"−₺1.229,00\". The hyphen of \"-₺1.229,00\" was half a digit wide and sat low, so a\n * negative amount did not line up under a positive one and was easy to miss.\n */\nconst MINUS = '\\u2212';\nconst withMinus = (text: string): string => (SIGN.test(text) ? `${MINUS}${text.slice(1)}` : text);\n\n/** Tutar gösterimi. */\nconst Price: FC<Props> = ({\n value,\n currency,\n currencyPosition,\n listValue,\n discountPercent,\n formatDiscount = percent => `%${percent}`,\n isFormatted,\n size = 'md',\n className,\n testId,\n}) => {\n const { labels } = useUi();\n const symbol = resolveLabel('Price.currency', currency, labels?.currency);\n const isPrefix = (currencyPosition ?? (symbol === LIRA_SIGN ? 'prefix' : 'suffix')) === 'prefix';\n\n /* BICIMLENDIRME OPSIYONEL ve yerel ayara BAGLI. */\n const format = (raw: string): string => {\n if (!isFormatted || !labels?.locale) return raw;\n\n /* RAKAM ICERMEYEN deger biciMLENDIRILMEZ. */\n if (!/\\d/.test(raw)) return raw;\n\n const numeric = Number(\n raw\n .replace(/[^\\d.,-]/g, '')\n .replace(/\\.(?=\\d{3}\\b)/g, '')\n .replace(',', '.'),\n );\n if (!Number.isFinite(numeric)) return raw;\n\n try {\n return new Intl.NumberFormat(labels.locale).format(numeric);\n } catch {\n return raw;\n }\n };\n\n const amount = (raw: string): ReactNode => {\n const text = withMinus(format(raw));\n if (!isPrefix) {\n return (\n <>\n {text}\n <span className={styles.price__currency}>{symbol}</span>\n </>\n );\n }\n\n const sign = SIGN.test(text) ? MINUS : '';\n return (\n <>\n {sign}\n <span className={cx(styles.price__currency, styles['price__currency--prefix'])}>\n {symbol}\n </span>\n {text.slice(sign.length)}\n </>\n );\n };\n\n return (\n <span className={cx(styles.price, styles[`price--${size}`], className)} data-testid={testId}>\n <span className={styles.price__current}>{amount(value)}</span>\n\n {listValue && <s className={styles.price__list}>{amount(listValue)}</s>}\n\n {/* `isDefined` DEGIL acik karsilastirma: handy-utils'in koruyucusu\n `Exclude<any, …>` donuyor ve TypeScript'te daraltma uretmiyor. */}\n {discountPercent !== undefined && discountPercent > 0 && (\n <span className={styles.price__discount}>{formatDiscount(discountPercent)}</span>\n )}\n </span>\n );\n};\n\nexport default /*#__PURE__*/ memo(Price) as typeof Price;\n"],"names":["LIRA_SIGN","SIGN","MINUS","withMinus","text","Price","value","currency","currencyPosition","listValue","discountPercent","formatDiscount","percent","isFormatted","size","className","testId","labels","useUi","symbol","resolveLabel","isPrefix","format","raw","numeric","amount","jsxs","Fragment","jsx","styles","sign","cx","index"],"mappings":"wVAyCMA,EAAY,IAEZC,EAAO,aAMPC,EAAQ,IACRC,EAAaC,GAA0BH,EAAK,KAAKG,CAAI,EAAI,GAAGF,CAAK,GAAGE,EAAK,MAAM,CAAC,CAAC,GAAKA,EAGtFC,EAAmB,CAAC,CACxB,MAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,UAAAC,EACA,gBAAAC,EACA,eAAAC,EAAiBC,GAAW,IAAIA,CAAO,GACvC,YAAAC,EACA,KAAAC,EAAO,KACP,UAAAC,EACA,OAAAC,CACF,IAAM,CACJ,KAAM,CAAE,OAAAC,CAAA,EAAWC,QAAA,EACbC,EAASC,EAAAA,aAAa,iBAAkBb,EAAUU,GAAA,YAAAA,EAAQ,QAAQ,EAClEI,GAAYb,IAAqBW,IAAWnB,EAAY,SAAW,aAAe,SAGlFsB,EAAUC,GAAwB,CAItC,GAHI,CAACV,GAAe,EAACI,GAAA,MAAAA,EAAQ,SAGzB,CAAC,KAAK,KAAKM,CAAG,EAAG,OAAOA,EAE5B,MAAMC,EAAU,OACdD,EACG,QAAQ,YAAa,EAAE,EACvB,QAAQ,iBAAkB,EAAE,EAC5B,QAAQ,IAAK,GAAG,CAAA,EAErB,G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im rozetinin metnini üretir ("%20", "-20%"). */
|
|
22
22
|
formatDiscount?: (percent: number) => string;
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* `inherit` (3.7) takes the size of the surrounding text: a price inside a `StatCard` value, a
|
|
25
|
+
* `TotalsList` row or a table cell follows that slot instead of bringing its own size.
|
|
26
|
+
*/
|
|
27
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'inherit';
|
|
24
28
|
className?: string;
|
|
25
29
|
testId?: string;
|
|
26
30
|
};
|
|
@@ -20,7 +20,11 @@ type Props = {
|
|
|
20
20
|
discountPercent?: number;
|
|
21
21
|
/** İndirim rozetinin metnini üretir ("%20", "-20%"). */
|
|
22
22
|
formatDiscount?: (percent: number) => string;
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* `inherit` (3.7) takes the size of the surrounding text: a price inside a `StatCard` value, a
|
|
25
|
+
* `TotalsList` row or a table cell follows that slot instead of bringing its own size.
|
|
26
|
+
*/
|
|
27
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'inherit';
|
|
24
28
|
className?: string;
|
|
25
29
|
testId?: string;
|
|
26
30
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { memo as
|
|
2
|
+
import { jsxs as m, jsx as t, Fragment as u } from "react/jsx-runtime";
|
|
3
|
+
import { memo as S } from "react";
|
|
4
4
|
import { cx as f } from "../../helpers/class-name.helper.js";
|
|
5
|
-
import { resolveLabel as
|
|
6
|
-
import { useUi as
|
|
7
|
-
const c = {"price":"ui-price-Oc5Nr","price__current":"ui-price__current-2Xup2","price__currency":"ui-price__currency-32NLN","price__currency--prefix":"ui-price__currency--prefix-dlva8","price__list":"ui-price__list-MlQgT","price__discount":"ui-price__discount-5Yc6W","price--sm":"ui-price--sm-Hd8Oe","price--md":"ui-price--md-JMxlK","price--lg":"ui-price--lg-TFqIF","price--xl":"ui-price--xl-EJBYq"};
|
|
8
|
-
const
|
|
9
|
-
value:
|
|
10
|
-
currency:
|
|
11
|
-
currencyPosition:
|
|
12
|
-
listValue:
|
|
5
|
+
import { resolveLabel as j } from "../../helpers/label.helper.js";
|
|
6
|
+
import { useUi as v } from "../../theme/context.js";
|
|
7
|
+
const c = {"price":"ui-price-Oc5Nr","price__current":"ui-price__current-2Xup2","price__currency":"ui-price__currency-32NLN","price__currency--prefix":"ui-price__currency--prefix-dlva8","price__list":"ui-price__list-MlQgT","price__discount":"ui-price__discount-5Yc6W","price--sm":"ui-price--sm-Hd8Oe","price--md":"ui-price--md-JMxlK","price--lg":"ui-price--lg-TFqIF","price--xl":"ui-price--xl-EJBYq","price--inherit":"ui-price--inherit-Ao5Jj"};
|
|
8
|
+
const G = "₺", d = /^[-\u2212]/, _ = "−", L = (s) => d.test(s) ? `${_}${s.slice(1)}` : s, M = ({
|
|
9
|
+
value: s,
|
|
10
|
+
currency: N,
|
|
11
|
+
currencyPosition: h,
|
|
12
|
+
listValue: p,
|
|
13
13
|
discountPercent: i,
|
|
14
|
-
formatDiscount:
|
|
15
|
-
isFormatted:
|
|
16
|
-
size:
|
|
17
|
-
className:
|
|
18
|
-
testId:
|
|
14
|
+
formatDiscount: x = (r) => `%${r}`,
|
|
15
|
+
isFormatted: y,
|
|
16
|
+
size: g = "md",
|
|
17
|
+
className: I,
|
|
18
|
+
testId: $
|
|
19
19
|
}) => {
|
|
20
|
-
const { labels: r } =
|
|
21
|
-
if (!
|
|
20
|
+
const { labels: r } = v(), o = j("Price.currency", N, r == null ? void 0 : r.currency), b = (h ?? (o === G ? "prefix" : "suffix")) === "prefix", F = (e) => {
|
|
21
|
+
if (!y || !(r != null && r.locale) || !/\d/.test(e)) return e;
|
|
22
22
|
const n = Number(
|
|
23
23
|
e.replace(/[^\d.,-]/g, "").replace(/\.(?=\d{3}\b)/g, "").replace(",", ".")
|
|
24
24
|
);
|
|
@@ -28,27 +28,26 @@ const L = "₺", S = /^[-\u2212]/, $ = ({
|
|
|
28
28
|
} catch {
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
const n = F(e);
|
|
31
|
+
}, a = (e) => {
|
|
32
|
+
const n = L(F(e));
|
|
34
33
|
if (!b)
|
|
35
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ m(u, { children: [
|
|
36
35
|
n,
|
|
37
|
-
/* @__PURE__ */ t("span", { className: c.price__currency, children:
|
|
36
|
+
/* @__PURE__ */ t("span", { className: c.price__currency, children: o })
|
|
38
37
|
] });
|
|
39
|
-
const
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
-
|
|
42
|
-
/* @__PURE__ */ t("span", { className: f(c.price__currency, c["price__currency--prefix"]), children:
|
|
43
|
-
n.slice(
|
|
38
|
+
const l = d.test(n) ? _ : "";
|
|
39
|
+
return /* @__PURE__ */ m(u, { children: [
|
|
40
|
+
l,
|
|
41
|
+
/* @__PURE__ */ t("span", { className: f(c.price__currency, c["price__currency--prefix"]), children: o }),
|
|
42
|
+
n.slice(l.length)
|
|
44
43
|
] });
|
|
45
44
|
};
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */ t("span", { className: c.price__current, children:
|
|
48
|
-
|
|
49
|
-
i !== void 0 && i > 0 && /* @__PURE__ */ t("span", { className: c.price__discount, children:
|
|
45
|
+
return /* @__PURE__ */ m("span", { className: f(c.price, c[`price--${g}`], I), "data-testid": $, children: [
|
|
46
|
+
/* @__PURE__ */ t("span", { className: c.price__current, children: a(s) }),
|
|
47
|
+
p && /* @__PURE__ */ t("s", { className: c.price__list, children: a(p) }),
|
|
48
|
+
i !== void 0 && i > 0 && /* @__PURE__ */ t("span", { className: c.price__discount, children: x(i) })
|
|
50
49
|
] });
|
|
51
|
-
}, z = /* @__PURE__ */
|
|
50
|
+
}, z = /* @__PURE__ */ S(M);
|
|
52
51
|
export {
|
|
53
52
|
z as default
|
|
54
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Price/index.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\n\nimport styles from './index.module.scss';\n\n/** `prefix`: \"₺2.649,57\". `suffix`: \"2.649,57₺\". */\nexport type PriceCurrencyPosition = 'prefix' | 'suffix';\n\ntype Props = {\n /** BİÇİMLENMİŞ tutar: \"1.299,90\". */\n value: string;\n /** Para birimi simgesi ya da kodu. */\n currency?: string;\n /**\n * Where the symbol sits. Default: `prefix` for \"₺\" — the ecosystem's lira format, as\n * `@handijitcom/tr` `formatLira` writes it (\"₺2.649,57\", \"-₺0,05\", no space) — and `suffix` for any\n * other symbol or code (\"2.649,57 TL\" style, as before 3.2.1).\n */\n currencyPosition?: PriceCurrencyPosition;\n /** Değeri `Intl.NumberFormat` ile biçimlendirir. */\n isFormatted?: boolean;\n /** Üstü çizili liste fiyatı; indirim varsa verilir (biçimlenmiş). */\n listValue?: string;\n /** İndirim oranı (tam sayı yüzde). */\n discountPercent?: number;\n /** İndirim rozetinin metnini üretir (\"%20\", \"-20%\"). */\n formatDiscount?: (percent: number) => string;\n size?: 'sm' | 'md' | 'lg' | 'xl';\n className?: string;\n testId?: string;\n};\n\n/** The lira sign: written before the amount by default (3.2.1). */\nconst LIRA_SIGN = '₺';\n/* A leading minus (ASCII or U+2212) stays in front of a prefixed symbol: \"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Price/index.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\n\nimport styles from './index.module.scss';\n\n/** `prefix`: \"₺2.649,57\". `suffix`: \"2.649,57₺\". */\nexport type PriceCurrencyPosition = 'prefix' | 'suffix';\n\ntype Props = {\n /** BİÇİMLENMİŞ tutar: \"1.299,90\". */\n value: string;\n /** Para birimi simgesi ya da kodu. */\n currency?: string;\n /**\n * Where the symbol sits. Default: `prefix` for \"₺\" — the ecosystem's lira format, as\n * `@handijitcom/tr` `formatLira` writes it (\"₺2.649,57\", \"-₺0,05\", no space) — and `suffix` for any\n * other symbol or code (\"2.649,57 TL\" style, as before 3.2.1).\n */\n currencyPosition?: PriceCurrencyPosition;\n /** Değeri `Intl.NumberFormat` ile biçimlendirir. */\n isFormatted?: boolean;\n /** Üstü çizili liste fiyatı; indirim varsa verilir (biçimlenmiş). */\n listValue?: string;\n /** İndirim oranı (tam sayı yüzde). */\n discountPercent?: number;\n /** İndirim rozetinin metnini üretir (\"%20\", \"-20%\"). */\n formatDiscount?: (percent: number) => string;\n /**\n * `inherit` (3.7) takes the size of the surrounding text: a price inside a `StatCard` value, a\n * `TotalsList` row or a table cell follows that slot instead of bringing its own size.\n */\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'inherit';\n className?: string;\n testId?: string;\n};\n\n/** The lira sign: written before the amount by default (3.2.1). */\nconst LIRA_SIGN = '₺';\n/* A leading minus (ASCII or U+2212) stays in front of a prefixed symbol: \"−₺0,05\". */\nconst SIGN = /^[-\\u2212]/;\n/*\n * 3.7: the minus is drawn as the typographic minus (U+2212), as wide as a digit and level with\n * the plus — \"−₺1.229,00\". The hyphen of \"-₺1.229,00\" was half a digit wide and sat low, so a\n * negative amount did not line up under a positive one and was easy to miss.\n */\nconst MINUS = '\\u2212';\nconst withMinus = (text: string): string => (SIGN.test(text) ? `${MINUS}${text.slice(1)}` : text);\n\n/** Tutar gösterimi. */\nconst Price: FC<Props> = ({\n value,\n currency,\n currencyPosition,\n listValue,\n discountPercent,\n formatDiscount = percent => `%${percent}`,\n isFormatted,\n size = 'md',\n className,\n testId,\n}) => {\n const { labels } = useUi();\n const symbol = resolveLabel('Price.currency', currency, labels?.currency);\n const isPrefix = (currencyPosition ?? (symbol === LIRA_SIGN ? 'prefix' : 'suffix')) === 'prefix';\n\n /* BICIMLENDIRME OPSIYONEL ve yerel ayara BAGLI. */\n const format = (raw: string): string => {\n if (!isFormatted || !labels?.locale) return raw;\n\n /* RAKAM ICERMEYEN deger biciMLENDIRILMEZ. */\n if (!/\\d/.test(raw)) return raw;\n\n const numeric = Number(\n raw\n .replace(/[^\\d.,-]/g, '')\n .replace(/\\.(?=\\d{3}\\b)/g, '')\n .replace(',', '.'),\n );\n if (!Number.isFinite(numeric)) return raw;\n\n try {\n return new Intl.NumberFormat(labels.locale).format(numeric);\n } catch {\n return raw;\n }\n };\n\n const amount = (raw: string): ReactNode => {\n const text = withMinus(format(raw));\n if (!isPrefix) {\n return (\n <>\n {text}\n <span className={styles.price__currency}>{symbol}</span>\n </>\n );\n }\n\n const sign = SIGN.test(text) ? MINUS : '';\n return (\n <>\n {sign}\n <span className={cx(styles.price__currency, styles['price__currency--prefix'])}>\n {symbol}\n </span>\n {text.slice(sign.length)}\n </>\n );\n };\n\n return (\n <span className={cx(styles.price, styles[`price--${size}`], className)} data-testid={testId}>\n <span className={styles.price__current}>{amount(value)}</span>\n\n {listValue && <s className={styles.price__list}>{amount(listValue)}</s>}\n\n {/* `isDefined` DEGIL acik karsilastirma: handy-utils'in koruyucusu\n `Exclude<any, …>` donuyor ve TypeScript'te daraltma uretmiyor. */}\n {discountPercent !== undefined && discountPercent > 0 && (\n <span className={styles.price__discount}>{formatDiscount(discountPercent)}</span>\n )}\n </span>\n );\n};\n\nexport default /*#__PURE__*/ memo(Price) as typeof Price;\n"],"names":["LIRA_SIGN","SIGN","MINUS","withMinus","text","Price","value","currency","currencyPosition","listValue","discountPercent","formatDiscount","percent","isFormatted","size","className","testId","labels","useUi","symbol","resolveLabel","isPrefix","format","raw","numeric","amount","jsxs","Fragment","jsx","styles","sign","cx","index"],"mappings":";;;;;;;AAyCA,MAAMA,IAAY,KAEZC,IAAO,cAMPC,IAAQ,KACRC,IAAY,CAACC,MAA0BH,EAAK,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AwB,EAAAC,GAAA,EACG,UAAA;AAAA,MAAAG;AAAA,MACD,gBAAAF,EAAC,QAAA,EAAK,WAAWG,EAAGF,EAAO,iBAAiBA,EAAO,yBAAyB,CAAC,GAC1E,UAAAV,EAAA,CACH;AAAA,MACCf,EAAK,MAAM0B,EAAK,MAAM;AAAA,IAAA,GACzB;AAAA,EAEJ;AAEA,SACE,gBAAAJ,EAAC,QAAA,EAAK,WAAWK,EAAGF,EAAO,OAAOA,EAAO,UAAUf,CAAI,EAAE,GAAGC,CAAS,GAAG,eAAaC,GACnF,UAAA;AAAA,IAAA,gBAAAY,EAAC,UAAK,WAAWC,EAAO,gBAAiB,UAAAJ,EAAOnB,CAAK,GAAE;AAAA,IAEtDG,uBAAc,KAAA,EAAE,WAAWoB,EAAO,aAAc,UAAAJ,EAAOhB,CAAS,GAAE;AAAA,IAIlEC,MAAoB,UAAaA,IAAkB,KAClD,gBAAAkB,EAAC,QAAA,EAAK,WAAWC,EAAO,iBAAkB,UAAAlB,EAAeD,CAAe,EAAA,CAAE;AAAA,EAAA,GAE9E;AAEJ,GAEAsB,sBAAkC3B,CAAK;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer ui{.ui-price-Oc5Nr{display:inline-flex;align-items:baseline;flex-wrap:wrap;gap:var(--hd-space-2)}.ui-price__current-2Xup2{font-family:var(--hd-font-display);font-size:var(--hd-type-h4-size);font-weight:var(--hd-font-weight-bold);font-variant-numeric:tabular-nums;letter-spacing:var(--hd-type-h2-letter-spacing);white-space:nowrap;color:var(--hd-text)}.ui-price__currency-32NLN{font-size:.75em;font-weight:var(--hd-font-weight-semibold);margin-inline-start:2px}.ui-price__currency--prefix-dlva8{margin-inline:0}.ui-price__list-MlQgT{font-size:var(--hd-type-small-size);color:var(--hd-text-3);font-variant-numeric:tabular-nums;text-decoration-thickness:1px}.ui-price__discount-5Yc6W{font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-bold);color:var(--hd-danger-on-solid);background-color:var(--hd-danger-solid);border-radius:var(--hd-radius-xs);padding:2px var(--hd-space-1);line-height:1}.ui-price--sm-Hd8Oe .ui-price__current-2Xup2{font-size:var(--hd-type-body-size)}.ui-price--md-JMxlK .ui-price__current-2Xup2{font-size:var(--hd-type-h4-size)}.ui-price--lg-TFqIF .ui-price__current-2Xup2,.ui-price--xl-EJBYq .ui-price__current-2Xup2{font-size:var(--hd-type-h2-size)}}
|
|
1
|
+
@layer ui{.ui-price-Oc5Nr{display:inline-flex;align-items:baseline;flex-wrap:wrap;gap:var(--hd-space-2)}.ui-price__current-2Xup2{font-family:var(--hd-font-display);font-size:var(--hd-type-h4-size);font-weight:var(--hd-font-weight-bold);font-variant-numeric:tabular-nums;letter-spacing:var(--hd-type-h2-letter-spacing);white-space:nowrap;color:var(--hd-text)}.ui-price__currency-32NLN{font-size:.75em;font-weight:var(--hd-font-weight-semibold);margin-inline-start:2px}.ui-price__currency--prefix-dlva8{margin-inline:0}.ui-price__list-MlQgT{font-size:var(--hd-type-small-size);color:var(--hd-text-3);font-variant-numeric:tabular-nums;text-decoration-thickness:1px}.ui-price__discount-5Yc6W{font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-bold);color:var(--hd-danger-on-solid);background-color:var(--hd-danger-solid);border-radius:var(--hd-radius-xs);padding:2px var(--hd-space-1);line-height:1}.ui-price--sm-Hd8Oe .ui-price__current-2Xup2{font-size:var(--hd-type-body-size)}.ui-price--md-JMxlK .ui-price__current-2Xup2{font-size:var(--hd-type-h4-size)}.ui-price--lg-TFqIF .ui-price__current-2Xup2,.ui-price--xl-EJBYq .ui-price__current-2Xup2{font-size:var(--hd-type-h2-size)}.ui-price--inherit-Ao5Jj .ui-price__current-2Xup2{font-family:inherit;font-size:inherit;font-weight:inherit;letter-spacing:inherit}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),N=require("react"),p=require("../../helpers/class-name.helper.cjs"),q=require("../../helpers/component.helper.cjs"),v=require("../CodeText/index.cjs"),y=require("../Heading/index.cjs"),n=require("../Link/index.cjs"),C=require("../VehicleTypeList/index.cjs"),a={default:{"card":"ui-card-TTAoP","card__media":"ui-card__media-tPiQl","card__body":"ui-card__body-ziNkF","card__meta":"ui-card__meta-XekAt","card__brand":"ui-card__brand-LC7g0","card__badges":"ui-card__badges-QTBfN","card__name":"ui-card__name-Uh0c0","card__link":"ui-card__link-jZICj","card__code":"ui-card__code-mUbX4","card__foot":"ui-card__foot-c9WvK","card__price":"ui-card__price-M3q0R","card__action":"ui-card__action-g2OI6"}},b=({name:c,href:t,linkProps:l,partNumber:u,image:_,brand:d,badges:s,vehicleTypes:o=[],stock:r,price:m,signIn:x,action:i,headingLevel:f=3,className:j,testId:h})=>e.jsxs("article",{className:p.cx(a.default.card,j),"data-testid":h,children:[e.jsx(n.default,{...l,href:t,className:a.default.card__media,tabIndex:-1,"aria-hidden":!0,children:_}),e.jsxs("div",{className:a.default.card__body,children:[(d||s)&&e.jsxs("div",{className:a.default.card__meta,children:[d&&e.jsx("span",{className:a.default.card__brand,children:d}),s&&e.jsx("span",{className:a.default.card__badges,children:s})]}),e.jsx(y.default,{level:f,size:"xs",maxLines:2,title:c,className:a.default.card__name,children:e.jsx(n.default,{...l,href:t,className:a.default.card__link,children:c})}),e.jsx(v.default,{code:u,isCopyable:!0,size:"sm",isMuted:!0,className:a.default.card__code}),e.jsx(C.default,{types:o}),e.jsxs("div",{className:a.default.card__foot,children:[r&&e.jsx("div",{className:a.default.card__stock,children:r}),e.jsx("div",{className:a.default.card__price,children:m??x}),i&&e.jsx("div",{className:a.default.card__action,children:i})]})]})]}),M=N.memo(q.named(b,"ProductCard"));exports.default=M;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/ProductCard/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport type { UiLinkExtraProps } from '../../types/link.type';\nimport CodeText from '../CodeText';\nimport Heading from '../Heading';\nimport UiLink from '../Link';\nimport VehicleTypeList from '../VehicleTypeList';\n\nimport styles from './index.module.scss';\n\ntype Props = {\n /** The product's name; two lines at most, the rest in its tooltip. */\n name: string;\n /** The product page. The image and the name link to it; the card itself is not one link. */\n href: string;\n linkProps?: UiLinkExtraProps;\n /** The part number, mono and copyable (\"428959612\"). */\n partNumber: string;\n /** The image (`<img alt=\"\">` or the framework's image), drawn `contain` in a fixed-ratio box. */\n image?: ReactNode;\n /** The brand line over the name (\"IVECO\"), with room for a mark. */\n brand?: ReactNode;\n /** Small badges beside the brand (\"Orijinal\", \"Muadil\"): one line. */\n badges?: ReactNode;\n /** Compatible vehicle types; the first two, then \"+N\". */\n vehicleTypes?: readonly string[];\n /** The stock line: a `StockStatus`. */\n stock?: ReactNode;\n /**\n * The price block: a `Price` with `listValue` and `discountPercent` for net / list / discount.\n * Without it the card shows `signIn`.\n */\n price?: ReactNode;\n /** What a visitor sees instead of the price (\"Fiyat için giriş yapın\" + a link). */\n signIn?: ReactNode;\n /** The action row at the card's foot: an `AddToCart`. */\n action?: ReactNode;\n /** The name's heading level in the page's outline; default 3. */\n headingLevel?: 2 | 3 | 4;\n className?: string;\n testId?: string;\n};\n\n/**\n * ProductCard (3.8) — a B2B product in a grid: a fixed-ratio image, the brand and badges, the name\n * (two lines), the copyable part number, the vehicle types (two + \"+N\"), then at the foot the stock,\n * the price (or the visitor's sign-in prompt) and the add-to-cart row. Every card of a row is as\n * tall as the row and its foot sits at the bottom, so prices and buttons line up across the grid.\n * @example\n * <ProductCard\n * name=\"Ön far (sol) – Stralis / S-Way\"\n * href=\"/parca/on-far-sol\"\n * partNumber=\"428959612\"\n * image={<img src={url} alt=\"\" />}\n * brand=\"IVECO\"\n * vehicleTypes={['Stralis', 'S-Way', 'Trakker']}\n * stock={<StockStatus tone=\"available\" label=\"Stokta (24)\" />}\n * price={<Price value=\"1.229,00\" listValue=\"1.450,00\" discountPercent={15} />}\n * action={<AddToCart productName=\"Ön far (sol)\" onAdd={add} />}\n * />\n */\nconst ProductCard = ({\n name,\n href,\n linkProps,\n partNumber,\n image,\n brand,\n badges,\n vehicleTypes = [],\n stock,\n price,\n signIn,\n action,\n headingLevel = 3,\n className,\n testId,\n}: Props) => (\n <article className={cx(styles.card, className)} data-testid={testId}>\n {/* The name is the link a screen reader meets; the image repeats it for the pointer only. */}\n <UiLink {...linkProps} href={href} className={styles.card__media} tabIndex={-1} aria-hidden>\n {image}\n </UiLink>\n\n <div className={styles.card__body}>\n {(brand || badges) && (\n <div className={styles.card__meta}>\n {brand && <span className={styles.card__brand}>{brand}</span>}\n {badges && <span className={styles.card__badges}>{badges}</span>}\n </div>\n )}\n\n <Heading\n level={headingLevel}\n size=\"xs\"\n maxLines={2}\n title={name}\n className={styles.card__name}\n >\n <UiLink {...linkProps} href={href} className={styles.card__link}>\n {name}\n </UiLink>\n </Heading>\n\n <CodeText code={partNumber} isCopyable size=\"sm\" isMuted className={styles.card__code} />\n\n <VehicleTypeList types={vehicleTypes} />\n\n <div className={styles.card__foot}>\n {stock && <div className={styles.card__stock}>{stock}</div>}\n <div className={styles.card__price}>{price ?? signIn}</div>\n {action && <div className={styles.card__action}>{action}</div>}\n </div>\n </div>\n </article>\n);\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(ProductCard, 'ProductCard'),\n) as typeof ProductCard;\n"],"names":["ProductCard","name","href","linkProps","partNumber","image","brand","badges","vehicleTypes","stock","price","signIn","action","headingLevel","className","testId","jsxs","cx","styles","jsx","UiLink","Heading","CodeText","VehicleTypeList","index","memo","named"],"mappings":"wbA+DMA,EAAc,CAAC,CACnB,KAAAC,EACA,KAAAC,EACA,UAAAC,EACA,WAAAC,EACA,MAAAC,EACA,MAAAC,EACA,OAAAC,EACA,aAAAC,EAAe,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,EAAAA,QAAO,YAAc,YAASP,EAAO,EACpDC,GAAUO,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAAA,QAAO,aAAe,SAAAN,CAAA,CAAO,CAAA,CAAA,CAC1D,CAAA,CAAA,CACF,CAAA,EACF,EAGFY,EAA6BC,EAAAA,KACbC,EAAAA,MAAM1B,EAAa,aAAa,CAChD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { UiLinkExtraProps } from '../../types/link.type.cjs';
|
|
3
|
+
type Props = {
|
|
4
|
+
/** The product's name; two lines at most, the rest in its tooltip. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** The product page. The image and the name link to it; the card itself is not one link. */
|
|
7
|
+
href: string;
|
|
8
|
+
linkProps?: UiLinkExtraProps;
|
|
9
|
+
/** The part number, mono and copyable ("428959612"). */
|
|
10
|
+
partNumber: string;
|
|
11
|
+
/** The image (`<img alt="">` or the framework's image), drawn `contain` in a fixed-ratio box. */
|
|
12
|
+
image?: ReactNode;
|
|
13
|
+
/** The brand line over the name ("IVECO"), with room for a mark. */
|
|
14
|
+
brand?: ReactNode;
|
|
15
|
+
/** Small badges beside the brand ("Orijinal", "Muadil"): one line. */
|
|
16
|
+
badges?: ReactNode;
|
|
17
|
+
/** Compatible vehicle types; the first two, then "+N". */
|
|
18
|
+
vehicleTypes?: readonly string[];
|
|
19
|
+
/** The stock line: a `StockStatus`. */
|
|
20
|
+
stock?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The price block: a `Price` with `listValue` and `discountPercent` for net / list / discount.
|
|
23
|
+
* Without it the card shows `signIn`.
|
|
24
|
+
*/
|
|
25
|
+
price?: ReactNode;
|
|
26
|
+
/** What a visitor sees instead of the price ("Fiyat için giriş yapın" + a link). */
|
|
27
|
+
signIn?: ReactNode;
|
|
28
|
+
/** The action row at the card's foot: an `AddToCart`. */
|
|
29
|
+
action?: ReactNode;
|
|
30
|
+
/** The name's heading level in the page's outline; default 3. */
|
|
31
|
+
headingLevel?: 2 | 3 | 4;
|
|
32
|
+
className?: string;
|
|
33
|
+
testId?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* ProductCard (3.8) — a B2B product in a grid: a fixed-ratio image, the brand and badges, the name
|
|
37
|
+
* (two lines), the copyable part number, the vehicle types (two + "+N"), then at the foot the stock,
|
|
38
|
+
* the price (or the visitor's sign-in prompt) and the add-to-cart row. Every card of a row is as
|
|
39
|
+
* tall as the row and its foot sits at the bottom, so prices and buttons line up across the grid.
|
|
40
|
+
* @example
|
|
41
|
+
* <ProductCard
|
|
42
|
+
* name="Ön far (sol) – Stralis / S-Way"
|
|
43
|
+
* href="/parca/on-far-sol"
|
|
44
|
+
* partNumber="428959612"
|
|
45
|
+
* image={<img src={url} alt="" />}
|
|
46
|
+
* brand="IVECO"
|
|
47
|
+
* vehicleTypes={['Stralis', 'S-Way', 'Trakker']}
|
|
48
|
+
* stock={<StockStatus tone="available" label="Stokta (24)" />}
|
|
49
|
+
* price={<Price value="1.229,00" listValue="1.450,00" discountPercent={15} />}
|
|
50
|
+
* action={<AddToCart productName="Ön far (sol)" onAdd={add} />}
|
|
51
|
+
* />
|
|
52
|
+
*/
|
|
53
|
+
declare const ProductCard: ({ name, href, linkProps, partNumber, image, brand, badges, vehicleTypes, stock, price, signIn, action, headingLevel, className, testId, }: Props) => import("react").JSX.Element;
|
|
54
|
+
declare const _default: typeof ProductCard;
|
|
55
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { UiLinkExtraProps } from '../../types/link.type.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
/** The product's name; two lines at most, the rest in its tooltip. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** The product page. The image and the name link to it; the card itself is not one link. */
|
|
7
|
+
href: string;
|
|
8
|
+
linkProps?: UiLinkExtraProps;
|
|
9
|
+
/** The part number, mono and copyable ("428959612"). */
|
|
10
|
+
partNumber: string;
|
|
11
|
+
/** The image (`<img alt="">` or the framework's image), drawn `contain` in a fixed-ratio box. */
|
|
12
|
+
image?: ReactNode;
|
|
13
|
+
/** The brand line over the name ("IVECO"), with room for a mark. */
|
|
14
|
+
brand?: ReactNode;
|
|
15
|
+
/** Small badges beside the brand ("Orijinal", "Muadil"): one line. */
|
|
16
|
+
badges?: ReactNode;
|
|
17
|
+
/** Compatible vehicle types; the first two, then "+N". */
|
|
18
|
+
vehicleTypes?: readonly string[];
|
|
19
|
+
/** The stock line: a `StockStatus`. */
|
|
20
|
+
stock?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The price block: a `Price` with `listValue` and `discountPercent` for net / list / discount.
|
|
23
|
+
* Without it the card shows `signIn`.
|
|
24
|
+
*/
|
|
25
|
+
price?: ReactNode;
|
|
26
|
+
/** What a visitor sees instead of the price ("Fiyat için giriş yapın" + a link). */
|
|
27
|
+
signIn?: ReactNode;
|
|
28
|
+
/** The action row at the card's foot: an `AddToCart`. */
|
|
29
|
+
action?: ReactNode;
|
|
30
|
+
/** The name's heading level in the page's outline; default 3. */
|
|
31
|
+
headingLevel?: 2 | 3 | 4;
|
|
32
|
+
className?: string;
|
|
33
|
+
testId?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* ProductCard (3.8) — a B2B product in a grid: a fixed-ratio image, the brand and badges, the name
|
|
37
|
+
* (two lines), the copyable part number, the vehicle types (two + "+N"), then at the foot the stock,
|
|
38
|
+
* the price (or the visitor's sign-in prompt) and the add-to-cart row. Every card of a row is as
|
|
39
|
+
* tall as the row and its foot sits at the bottom, so prices and buttons line up across the grid.
|
|
40
|
+
* @example
|
|
41
|
+
* <ProductCard
|
|
42
|
+
* name="Ön far (sol) – Stralis / S-Way"
|
|
43
|
+
* href="/parca/on-far-sol"
|
|
44
|
+
* partNumber="428959612"
|
|
45
|
+
* image={<img src={url} alt="" />}
|
|
46
|
+
* brand="IVECO"
|
|
47
|
+
* vehicleTypes={['Stralis', 'S-Way', 'Trakker']}
|
|
48
|
+
* stock={<StockStatus tone="available" label="Stokta (24)" />}
|
|
49
|
+
* price={<Price value="1.229,00" listValue="1.450,00" discountPercent={15} />}
|
|
50
|
+
* action={<AddToCart productName="Ön far (sol)" onAdd={add} />}
|
|
51
|
+
* />
|
|
52
|
+
*/
|
|
53
|
+
declare const ProductCard: ({ name, href, linkProps, partNumber, image, brand, badges, vehicleTypes, stock, price, signIn, action, headingLevel, className, testId, }: Props) => import("react").JSX.Element;
|
|
54
|
+
declare const _default: typeof ProductCard;
|
|
55
|
+
export default _default;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsxs as r, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { memo as v } from "react";
|
|
3
|
+
import { cx as y } from "../../helpers/class-name.helper.js";
|
|
4
|
+
import { named as C } from "../../helpers/component.helper.js";
|
|
5
|
+
import L from "../CodeText/index.js";
|
|
6
|
+
import j from "../Heading/index.js";
|
|
7
|
+
import o from "../Link/index.js";
|
|
8
|
+
import z from "../VehicleTypeList/index.js";
|
|
9
|
+
const e = {"card":"ui-card-TTAoP","card__media":"ui-card__media-tPiQl","card__body":"ui-card__body-ziNkF","card__meta":"ui-card__meta-XekAt","card__brand":"ui-card__brand-LC7g0","card__badges":"ui-card__badges-QTBfN","card__name":"ui-card__name-Uh0c0","card__link":"ui-card__link-jZICj","card__code":"ui-card__code-mUbX4","card__foot":"ui-card__foot-c9WvK","card__price":"ui-card__price-M3q0R","card__action":"ui-card__action-g2OI6"};
|
|
10
|
+
const T = ({
|
|
11
|
+
name: i,
|
|
12
|
+
href: s,
|
|
13
|
+
linkProps: m,
|
|
14
|
+
partNumber: _,
|
|
15
|
+
image: n,
|
|
16
|
+
brand: c,
|
|
17
|
+
badges: d,
|
|
18
|
+
vehicleTypes: p = [],
|
|
19
|
+
stock: l,
|
|
20
|
+
price: h,
|
|
21
|
+
signIn: N,
|
|
22
|
+
action: t,
|
|
23
|
+
headingLevel: f = 3,
|
|
24
|
+
className: x,
|
|
25
|
+
testId: u
|
|
26
|
+
}) => /* @__PURE__ */ r("article", { className: y(e.card, x), "data-testid": u, children: [
|
|
27
|
+
/* @__PURE__ */ a(o, { ...m, href: s, className: e.card__media, tabIndex: -1, "aria-hidden": !0, children: n }),
|
|
28
|
+
/* @__PURE__ */ r("div", { className: e.card__body, children: [
|
|
29
|
+
(c || d) && /* @__PURE__ */ r("div", { className: e.card__meta, children: [
|
|
30
|
+
c && /* @__PURE__ */ a("span", { className: e.card__brand, children: c }),
|
|
31
|
+
d && /* @__PURE__ */ a("span", { className: e.card__badges, children: d })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ a(
|
|
34
|
+
j,
|
|
35
|
+
{
|
|
36
|
+
level: f,
|
|
37
|
+
size: "xs",
|
|
38
|
+
maxLines: 2,
|
|
39
|
+
title: i,
|
|
40
|
+
className: e.card__name,
|
|
41
|
+
children: /* @__PURE__ */ a(o, { ...m, href: s, className: e.card__link, children: i })
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ a(L, { code: _, isCopyable: !0, size: "sm", isMuted: !0, className: e.card__code }),
|
|
45
|
+
/* @__PURE__ */ a(z, { types: p }),
|
|
46
|
+
/* @__PURE__ */ r("div", { className: e.card__foot, children: [
|
|
47
|
+
l && /* @__PURE__ */ a("div", { className: e.card__stock, children: l }),
|
|
48
|
+
/* @__PURE__ */ a("div", { className: e.card__price, children: h ?? N }),
|
|
49
|
+
t && /* @__PURE__ */ a("div", { className: e.card__action, children: t })
|
|
50
|
+
] })
|
|
51
|
+
] })
|
|
52
|
+
] }), q = /* @__PURE__ */ v(
|
|
53
|
+
/* @__PURE__ */ C(T, "ProductCard")
|
|
54
|
+
);
|
|
55
|
+
export {
|
|
56
|
+
q as default
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/ProductCard/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport type { UiLinkExtraProps } from '../../types/link.type';\nimport CodeText from '../CodeText';\nimport Heading from '../Heading';\nimport UiLink from '../Link';\nimport VehicleTypeList from '../VehicleTypeList';\n\nimport styles from './index.module.scss';\n\ntype Props = {\n /** The product's name; two lines at most, the rest in its tooltip. */\n name: string;\n /** The product page. The image and the name link to it; the card itself is not one link. */\n href: string;\n linkProps?: UiLinkExtraProps;\n /** The part number, mono and copyable (\"428959612\"). */\n partNumber: string;\n /** The image (`<img alt=\"\">` or the framework's image), drawn `contain` in a fixed-ratio box. */\n image?: ReactNode;\n /** The brand line over the name (\"IVECO\"), with room for a mark. */\n brand?: ReactNode;\n /** Small badges beside the brand (\"Orijinal\", \"Muadil\"): one line. */\n badges?: ReactNode;\n /** Compatible vehicle types; the first two, then \"+N\". */\n vehicleTypes?: readonly string[];\n /** The stock line: a `StockStatus`. */\n stock?: ReactNode;\n /**\n * The price block: a `Price` with `listValue` and `discountPercent` for net / list / discount.\n * Without it the card shows `signIn`.\n */\n price?: ReactNode;\n /** What a visitor sees instead of the price (\"Fiyat için giriş yapın\" + a link). */\n signIn?: ReactNode;\n /** The action row at the card's foot: an `AddToCart`. */\n action?: ReactNode;\n /** The name's heading level in the page's outline; default 3. */\n headingLevel?: 2 | 3 | 4;\n className?: string;\n testId?: string;\n};\n\n/**\n * ProductCard (3.8) — a B2B product in a grid: a fixed-ratio image, the brand and badges, the name\n * (two lines), the copyable part number, the vehicle types (two + \"+N\"), then at the foot the stock,\n * the price (or the visitor's sign-in prompt) and the add-to-cart row. Every card of a row is as\n * tall as the row and its foot sits at the bottom, so prices and buttons line up across the grid.\n * @example\n * <ProductCard\n * name=\"Ön far (sol) – Stralis / S-Way\"\n * href=\"/parca/on-far-sol\"\n * partNumber=\"428959612\"\n * image={<img src={url} alt=\"\" />}\n * brand=\"IVECO\"\n * vehicleTypes={['Stralis', 'S-Way', 'Trakker']}\n * stock={<StockStatus tone=\"available\" label=\"Stokta (24)\" />}\n * price={<Price value=\"1.229,00\" listValue=\"1.450,00\" discountPercent={15} />}\n * action={<AddToCart productName=\"Ön far (sol)\" onAdd={add} />}\n * />\n */\nconst ProductCard = ({\n name,\n href,\n linkProps,\n partNumber,\n image,\n brand,\n badges,\n vehicleTypes = [],\n stock,\n price,\n signIn,\n action,\n headingLevel = 3,\n className,\n testId,\n}: Props) => (\n <article className={cx(styles.card, className)} data-testid={testId}>\n {/* The name is the link a screen reader meets; the image repeats it for the pointer only. */}\n <UiLink {...linkProps} href={href} className={styles.card__media} tabIndex={-1} aria-hidden>\n {image}\n </UiLink>\n\n <div className={styles.card__body}>\n {(brand || badges) && (\n <div className={styles.card__meta}>\n {brand && <span className={styles.card__brand}>{brand}</span>}\n {badges && <span className={styles.card__badges}>{badges}</span>}\n </div>\n )}\n\n <Heading\n level={headingLevel}\n size=\"xs\"\n maxLines={2}\n title={name}\n className={styles.card__name}\n >\n <UiLink {...linkProps} href={href} className={styles.card__link}>\n {name}\n </UiLink>\n </Heading>\n\n <CodeText code={partNumber} isCopyable size=\"sm\" isMuted className={styles.card__code} />\n\n <VehicleTypeList types={vehicleTypes} />\n\n <div className={styles.card__foot}>\n {stock && <div className={styles.card__stock}>{stock}</div>}\n <div className={styles.card__price}>{price ?? signIn}</div>\n {action && <div className={styles.card__action}>{action}</div>}\n </div>\n </div>\n </article>\n);\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(ProductCard, 'ProductCard'),\n) as typeof ProductCard;\n"],"names":["ProductCard","name","href","linkProps","partNumber","image","brand","badges","vehicleTypes","stock","price","signIn","action","headingLevel","className","testId","jsxs","cx","styles","jsx","UiLink","Heading","CodeText","VehicleTypeList","index","memo","named"],"mappings":";;;;;;;;;AA+DA,MAAMA,IAAc,CAAC;AAAA,EACnB,MAAAC;AAAA,EACA,MAAAC;AAAA,EAC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,CAAc;AAAA,IAEtC,gBAAAQ,EAAC,OAAA,EAAI,WAAWE,EAAO,YACpB,UAAA;AAAA,MAAAT,KAAS,gBAAAU,EAAC,OAAA,EAAI,WAAWD,EAAO,aAAc,UAAAT,GAAM;AAAA,wBACpD,OAAA,EAAI,WAAWS,EAAO,aAAc,eAASP,GAAO;AAAA,MACpDC,KAAU,gBAAAO,EAAC,OAAA,EAAI,WAAWD,EAAO,cAAe,UAAAN,EAAA,CAAO;AAAA,IAAA,EAAA,CAC1D;AAAA,EAAA,EAAA,CACF;AAAA,GACF,GAGFY,IAA6B,gBAAAC;AAAA,EACb,gBAAAC,EAAM1B,GAAa,aAAa;AAChD;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-card-TTAoP{display:flex;flex-direction:column;height:100%;min-width:0;overflow:hidden;border:1px solid var(--hd-border);border-radius:var(--hd-radius-md);background-color:var(--hd-bg-surface);transition:border-color var(--hd-duration-fast) var(--hd-ease-standard)}.ui-card-TTAoP:hover{border-color:var(--hd-border-strong)}@media (prefers-reduced-motion: reduce){.ui-card-TTAoP{transition:none}}.ui-card__media-tPiQl{display:flex;align-items:center;justify-content:center;aspect-ratio:4/3;padding:var(--hd-space-3);background-color:var(--hd-bg-raised)}.ui-card__media-tPiQl>img,.ui-card__media-tPiQl>picture,.ui-card__media-tPiQl>svg{width:100%;height:100%;object-fit:contain}.ui-card__body-ziNkF{display:flex;flex:1;flex-direction:column;gap:var(--hd-space-2);min-width:0;padding:var(--hd-space-4)}.ui-card__meta-XekAt{display:flex;align-items:center;gap:var(--hd-space-2);min-width:0;min-height:1lh;font-size:var(--hd-type-caption-size);line-height:var(--hd-type-h4-line-height)}.ui-card__brand-LC7g0{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;display:block;font-weight:var(--hd-font-weight-semibold);color:var(--hd-text-2)}.ui-card__badges-QTBfN{display:inline-flex;flex-shrink:0;gap:var(--hd-space-1);margin-inline-start:auto}.ui-card__name-Uh0c0{min-height:2lh}.ui-card__link-jZICj{color:var(--hd-text);text-decoration:none;border-radius:var(--hd-radius-xs)}.ui-card__link-jZICj:hover{color:var(--hd-primary-text);text-decoration:underline;text-underline-offset:2px}.ui-card__link-jZICj:focus-visible{outline:var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--hd-focus));outline-offset:var(--ui-ring-offset, 2px)}.ui-card__code-mUbX4{align-self:flex-start;max-width:100%}.ui-card__foot-c9WvK{display:flex;flex-direction:column;gap:var(--hd-space-2);margin-top:auto;padding-top:var(--hd-space-2)}.ui-card__price-M3q0R{min-height:1.75rem;min-width:0}.ui-card__action-g2OI6{padding-top:var(--hd-space-1)}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),m=require("../CodeText/index.cjs"),a={default:{"row":"ui-row-hRssp","row__main":"ui-row__main-9U8-X","row__brand":"ui-row__brand-FPANJ","row__stock":"ui-row__stock-R0vkG","row__price":"ui-row__price-Xc0rY","row__access":"ui-row__access-90GUv","row__action":"ui-row__action-BLUhd","thumb":"ui-thumb-keewu","identity":"ui-identity-KJkMD","identity__name":"ui-identity__name-HOwle","truncate":"ui-truncate-5ux8b","column__image":"ui-column__image-80B8g","column__code":"ui-column__code-WqdqI","column__name":"ui-column__name-XArN-","column__brand":"ui-column__brand-kZOvm","column__stock":"ui-column__stock-TFp2x","column__price":"ui-column__price-O6HlG","column__access":"ui-column__access-anXj-","column__action":"ui-column__action-v67xi","srOnly":"ui-srOnly-tMxZI"}},n=require("./parts.cjs"),o=({product:s,signIn:t,action:u,labels:d={},omit:i=[]})=>{const l=(e,c=!1)=>r.jsx(n.ProductColumnLabel,{field:e,text:d[e],isHidden:c});return[{field:"image",key:"image",label:l("image",!0),className:a.default.column__image,render:e=>r.jsx(n.ProductThumb,{image:s(e).image})},{field:"partNumber",key:"partNumber",label:l("partNumber"),isAlwaysVisible:!0,className:a.default.column__code,render:e=>r.jsx(m.default,{code:s(e).partNumber,isCopyable:!0,size:"sm"})},{field:"name",key:"name",label:l("name"),className:a.default.column__name,render:e=>r.jsx(n.ProductIdentity,{...s(e)})},{field:"brand",key:"brand",label:l("brand"),className:a.default.column__brand,render:e=>r.jsx("span",{className:a.default.truncate,children:s(e).brand})},...t?[{field:"access",key:"access",label:l("access"),className:a.default.column__access,render:e=>t(e)}]:[{field:"stock",key:"stock",label:l("stock"),className:a.default.column__stock,render:e=>s(e).stock},{field:"price",key:"price",label:l("price"),isNumeric:!0,className:a.default.column__price,render:e=>s(e).price}],...u?[{field:"action",key:"action",label:l("action",!0),align:"end",className:a.default.column__action,render:e=>u(e)}]:[]].filter(e=>!i.includes(e.field)).map(({field:e,...c})=>c)};exports.default=o;
|
|
2
|
+
//# sourceMappingURL=columns.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.cjs","sources":["../../../src/components/ProductRow/columns.tsx"],"sourcesContent":["import { type ReactNode } from 'react';\n\nimport CodeText from '../CodeText';\nimport type { DataTableColumn } from '../DataTable';\n\nimport styles from './index.module.scss';\nimport {\n type ProductField,\n ProductColumnLabel,\n ProductIdentity,\n type ProductRowData,\n ProductThumb,\n} from './parts';\n\nexport type ProductColumnsOptions<T> = {\n /** The product of a row. */\n product: (row: T) => ProductRowData;\n /**\n * A visitor's table: the stock and price columns become ONE column with this cell (\"Fiyat ve\n * stok için giriş yapın\"). Leave it out for a dealer.\n */\n signIn?: (row: T) => ReactNode;\n /** The last column: an `AddToCart size=\"sm\"`. */\n action?: (row: T) => ReactNode;\n /** Headings instead of `labels.product`. */\n labels?: Partial<Record<ProductField, string>>;\n /** Columns to leave out (\"brand\" in a one-brand catalogue). */\n omit?: readonly ProductField[];\n};\n\n/**\n * productColumns (3.8) — the B2B product table's columns for `DataTable`: image 40px · part number\n * (mono, copyable, never hidden) · name and vehicle types · brand · stock · price (end, tabular) ·\n * add to cart. With `signIn` (a visitor) stock and price merge into one sign-in column, so a\n * visitor and a dealer see the same table.\n * @example <DataTable rows={items} rowKey={item => item.id} columns={productColumns({ product: toRow, action: item => <AddToCart size=\"sm\" onAdd={…} /> })} />\n */\nconst productColumns = <T,>({\n product,\n signIn,\n action,\n labels = {},\n omit = [],\n}: ProductColumnsOptions<T>): DataTableColumn<T>[] => {\n const heading = (field: ProductField, isHidden = false) => (\n <ProductColumnLabel field={field} text={labels[field]} isHidden={isHidden} />\n );\n\n const columns: (DataTableColumn<T> & { field: ProductField })[] = [\n {\n field: 'image',\n key: 'image',\n label: heading('image', true),\n className: styles.column__image,\n render: row => <ProductThumb image={product(row).image} />,\n },\n {\n field: 'partNumber',\n key: 'partNumber',\n label: heading('partNumber'),\n isAlwaysVisible: true,\n className: styles.column__code,\n render: row => <CodeText code={product(row).partNumber} isCopyable size=\"sm\" />,\n },\n {\n field: 'name',\n key: 'name',\n label: heading('name'),\n className: styles.column__name,\n render: row => <ProductIdentity {...product(row)} />,\n },\n {\n field: 'brand',\n key: 'brand',\n label: heading('brand'),\n className: styles.column__brand,\n render: row => <span className={styles.truncate}>{product(row).brand}</span>,\n },\n ...(signIn\n ? [\n {\n field: 'access' as const,\n key: 'access',\n label: heading('access'),\n className: styles.column__access,\n render: (row: T) => signIn(row),\n },\n ]\n : [\n {\n field: 'stock' as const,\n key: 'stock',\n label: heading('stock'),\n className: styles.column__stock,\n render: (row: T) => product(row).stock,\n },\n {\n field: 'price' as const,\n key: 'price',\n label: heading('price'),\n isNumeric: true,\n className: styles.column__price,\n render: (row: T) => product(row).price,\n },\n ]),\n ...(action\n ? [\n {\n field: 'action' as const,\n key: 'action',\n label: heading('action', true),\n align: 'end' as const,\n className: styles.column__action,\n render: (row: T) => action(row),\n },\n ]\n : []),\n ];\n\n return columns\n .filter(column => !omit.includes(column.field))\n .map(({ field: _field, ...column }) => column);\n};\n\nexport default productColumns;\n"],"names":["productColumns","product","signIn","action","labels","omit","heading","field","isHidden","jsx","ProductCol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