@handijitcom/ui 3.0.0 → 3.2.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 +209 -9
- package/build/components/AppShell/Nav.cjs +2 -0
- package/build/components/AppShell/Nav.cjs.map +1 -0
- package/build/components/AppShell/Nav.d.cts +75 -0
- package/build/components/AppShell/Nav.d.ts +75 -0
- package/build/components/AppShell/Nav.js +189 -0
- package/build/components/AppShell/Nav.js.map +1 -0
- package/build/components/AppShell/context.cjs +2 -0
- package/build/components/AppShell/context.cjs.map +1 -0
- package/build/components/AppShell/context.d.cts +29 -0
- package/build/components/AppShell/context.d.ts +29 -0
- package/build/components/AppShell/context.js +13 -0
- package/build/components/AppShell/context.js.map +1 -0
- package/build/components/AppShell/index.cjs +2 -0
- package/build/components/AppShell/index.cjs.map +1 -0
- package/build/components/AppShell/index.d.cts +39 -0
- package/build/components/AppShell/index.d.ts +39 -0
- package/build/components/AppShell/index.js +130 -0
- package/build/components/AppShell/index.js.map +1 -0
- package/build/components/AppShell/style.css +1 -0
- package/build/components/Avatar/index.cjs +1 -1
- package/build/components/Avatar/index.cjs.map +1 -1
- package/build/components/Avatar/index.js +18 -18
- package/build/components/Avatar/index.js.map +1 -1
- package/build/components/BulkPasteInput/index.cjs +2 -0
- package/build/components/BulkPasteInput/index.cjs.map +1 -0
- package/build/components/BulkPasteInput/index.d.cts +26 -0
- package/build/components/BulkPasteInput/index.d.ts +26 -0
- package/build/components/BulkPasteInput/index.js +80 -0
- package/build/components/BulkPasteInput/index.js.map +1 -0
- package/build/components/BulkPasteInput/style.css +1 -0
- package/build/components/Checkbox/index.cjs +1 -1
- package/build/components/Checkbox/index.cjs.map +1 -1
- package/build/components/Checkbox/index.js +6 -6
- package/build/components/Checkbox/index.js.map +1 -1
- package/build/components/DataTable/context.cjs +2 -0
- package/build/components/DataTable/context.cjs.map +1 -0
- package/build/components/DataTable/context.d.cts +17 -0
- package/build/components/DataTable/context.d.ts +17 -0
- package/build/components/DataTable/context.js +7 -0
- package/build/components/DataTable/context.js.map +1 -0
- package/build/components/DataTable/index.cjs +1 -1
- package/build/components/DataTable/index.cjs.map +1 -1
- package/build/components/DataTable/index.d.cts +46 -5
- package/build/components/DataTable/index.d.ts +46 -5
- package/build/components/DataTable/index.js +236 -93
- package/build/components/DataTable/index.js.map +1 -1
- package/build/components/DataTable/style.css +1 -1
- package/build/components/DataTableColumnMenu/index.cjs +2 -0
- package/build/components/DataTableColumnMenu/index.cjs.map +1 -0
- package/build/components/DataTableColumnMenu/index.d.cts +13 -0
- package/build/components/DataTableColumnMenu/index.d.ts +13 -0
- package/build/components/DataTableColumnMenu/index.js +69 -0
- package/build/components/DataTableColumnMenu/index.js.map +1 -0
- package/build/components/DataTableColumnMenu/style.css +1 -0
- package/build/components/Drawer/index.cjs +1 -1
- package/build/components/Drawer/index.cjs.map +1 -1
- package/build/components/Drawer/index.js +33 -33
- package/build/components/Drawer/index.js.map +1 -1
- package/build/components/Gallery/index.cjs +2 -0
- package/build/components/Gallery/index.cjs.map +1 -0
- package/build/components/Gallery/index.d.cts +56 -0
- package/build/components/Gallery/index.d.ts +56 -0
- package/build/components/Gallery/index.js +253 -0
- package/build/components/Gallery/index.js.map +1 -0
- package/build/components/Gallery/style.css +1 -0
- package/build/components/Menu/index.cjs +1 -1
- package/build/components/Menu/index.cjs.map +1 -1
- package/build/components/Menu/index.js +48 -48
- package/build/components/Menu/index.js.map +1 -1
- package/build/components/NotificationCenter/index.cjs +2 -0
- package/build/components/NotificationCenter/index.cjs.map +1 -0
- package/build/components/NotificationCenter/index.d.cts +45 -0
- package/build/components/NotificationCenter/index.d.ts +45 -0
- package/build/components/NotificationCenter/index.js +124 -0
- package/build/components/NotificationCenter/index.js.map +1 -0
- package/build/components/NotificationCenter/style.css +1 -0
- package/build/components/Popover/index.cjs +1 -1
- package/build/components/Popover/index.cjs.map +1 -1
- package/build/components/Popover/index.js +16 -16
- package/build/components/Popover/index.js.map +1 -1
- package/build/components/TreeSelect/index.cjs +2 -0
- package/build/components/TreeSelect/index.cjs.map +1 -0
- package/build/components/TreeSelect/index.d.cts +40 -0
- package/build/components/TreeSelect/index.d.ts +40 -0
- package/build/components/TreeSelect/index.js +175 -0
- package/build/components/TreeSelect/index.js.map +1 -0
- package/build/components/TreeSelect/style.css +1 -0
- package/build/components/UserMenu/index.cjs +2 -0
- package/build/components/UserMenu/index.cjs.map +1 -0
- package/build/components/UserMenu/index.d.cts +21 -0
- package/build/components/UserMenu/index.d.ts +21 -0
- package/build/components/UserMenu/index.js +36 -0
- package/build/components/UserMenu/index.js.map +1 -0
- package/build/components/UserMenu/style.css +1 -0
- package/build/helpers/app-shell.helper.cjs +2 -0
- package/build/helpers/app-shell.helper.cjs.map +1 -0
- package/build/helpers/app-shell.helper.d.cts +12 -0
- package/build/helpers/app-shell.helper.d.ts +12 -0
- package/build/helpers/app-shell.helper.js +18 -0
- package/build/helpers/app-shell.helper.js.map +1 -0
- package/build/helpers/bulk-paste.helper.cjs +2 -0
- package/build/helpers/bulk-paste.helper.cjs.map +1 -0
- package/build/helpers/bulk-paste.helper.d.cts +38 -0
- package/build/helpers/bulk-paste.helper.d.ts +38 -0
- package/build/helpers/bulk-paste.helper.js +37 -0
- package/build/helpers/bulk-paste.helper.js.map +1 -0
- package/build/index.cjs +1 -1
- package/build/index.d.cts +9 -1
- package/build/index.d.ts +9 -1
- package/build/index.js +138 -118
- package/build/index.js.map +1 -1
- package/build/styles.css +17 -1
- package/build/types/theme.type.d.cts +71 -0
- package/build/types/theme.type.d.ts +71 -0
- package/build/types/types/theme.type.d.cts +71 -0
- package/build/types/types/theme.type.d.ts +71 -0
- package/package.json +71 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as n, jsxs as T } from "react/jsx-runtime";
|
|
3
|
+
import { memo as k, useContext as w } from "react";
|
|
4
|
+
import { ArrowUp as y, ArrowDown as M, LayoutThreeColumns as g } from "react-bootstrap-icons";
|
|
5
|
+
import { named as U } from "../../helpers/component.helper.js";
|
|
6
|
+
import { resolveLabel as x, resolveFormatter as f } from "../../helpers/label.helper.js";
|
|
7
|
+
import { useUi as A } from "../../theme/context.js";
|
|
8
|
+
import N from "../Checkbox/index.js";
|
|
9
|
+
import _ from "../DataTable/context.js";
|
|
10
|
+
import r from "../IconButton/index.js";
|
|
11
|
+
import z from "../Popover/index.js";
|
|
12
|
+
const i = {"columnMenu":"ui-columnMenu-MSpeh","columnMenu__item":"ui-columnMenu__item-NPI--","columnMenu__check":"ui-columnMenu__check-F-AK4"};
|
|
13
|
+
const j = (e) => e.srLabel ?? (typeof e.label == "string" ? e.label : e.key), V = ({ labels: e }) => {
|
|
14
|
+
var d, p, C;
|
|
15
|
+
const { labels: o } = A(), l = w(_);
|
|
16
|
+
if (!l) return null;
|
|
17
|
+
const { columns: s, hidden: h, toggleColumn: v, moveColumn: c } = l, u = x(
|
|
18
|
+
"DataTableColumnMenu.labels.columns",
|
|
19
|
+
e == null ? void 0 : e.columns,
|
|
20
|
+
(d = o == null ? void 0 : o.dataTable) == null ? void 0 : d.columns
|
|
21
|
+
), D = (e == null ? void 0 : e.moveUp) ?? ((p = o == null ? void 0 : o.dataTable) == null ? void 0 : p.moveUp), b = (e == null ? void 0 : e.moveDown) ?? ((C = o == null ? void 0 : o.dataTable) == null ? void 0 : C.moveDown);
|
|
22
|
+
return /* @__PURE__ */ n(
|
|
23
|
+
z,
|
|
24
|
+
{
|
|
25
|
+
label: u,
|
|
26
|
+
align: "end",
|
|
27
|
+
trigger: /* @__PURE__ */ n(r, { icon: /* @__PURE__ */ n(g, { "aria-hidden": !0 }), label: u, size: "sm" }),
|
|
28
|
+
children: /* @__PURE__ */ n("ul", { className: i.columnMenu, children: s.map((t, a) => {
|
|
29
|
+
const m = j(t);
|
|
30
|
+
return /* @__PURE__ */ T("li", { className: i.columnMenu__item, children: [
|
|
31
|
+
/* @__PURE__ */ n(
|
|
32
|
+
N,
|
|
33
|
+
{
|
|
34
|
+
label: m,
|
|
35
|
+
checked: t.isAlwaysVisible || !h.has(t.key),
|
|
36
|
+
disabled: t.isAlwaysVisible,
|
|
37
|
+
onChange: () => v(t.key),
|
|
38
|
+
className: i.columnMenu__check
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ n(
|
|
42
|
+
r,
|
|
43
|
+
{
|
|
44
|
+
icon: /* @__PURE__ */ n(y, { "aria-hidden": !0 }),
|
|
45
|
+
label: f("DataTableColumnMenu.labels.moveUp", D, m),
|
|
46
|
+
size: "sm",
|
|
47
|
+
"aria-disabled": a === 0 || void 0,
|
|
48
|
+
onClick: () => c(a, -1)
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ n(
|
|
52
|
+
r,
|
|
53
|
+
{
|
|
54
|
+
icon: /* @__PURE__ */ n(M, { "aria-hidden": !0 }),
|
|
55
|
+
label: f("DataTableColumnMenu.labels.moveDown", b, m),
|
|
56
|
+
size: "sm",
|
|
57
|
+
"aria-disabled": a === s.length - 1 || void 0,
|
|
58
|
+
onClick: () => c(a, 1)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] }, t.key);
|
|
62
|
+
}) })
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}, Q = /* @__PURE__ */ k(/* @__PURE__ */ U(V, "DataTableColumnMenu"));
|
|
66
|
+
export {
|
|
67
|
+
Q as default
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/DataTableColumnMenu/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo, useContext } from 'react';\n\nimport { ArrowDown, ArrowUp, LayoutThreeColumns } from 'react-bootstrap-icons';\n\nimport { named } from '../../helpers/component.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport Checkbox from '../Checkbox';\nimport DataTableColumnMenuContext from '../DataTable/context';\nimport type { DataTableColumn } from '../DataTable';\nimport IconButton from '../IconButton';\nimport Popover from '../Popover';\n\nimport styles from './index.module.scss';\n\nexport type DataTableColumnMenuLabels = {\n /** Trigger and panel name (\"Sütunlar\"). */\n columns: string;\n moveUp: Formatter<[column: string]>;\n moveDown: Formatter<[column: string]>;\n};\n\ntype Props = {\n /** Each falls back to `UiLabels.dataTable` (`columns`, `moveUp`, `moveDown`). */\n labels?: Partial<DataTableColumnMenuLabels>;\n};\n\nconst columnName = (column: DataTableColumn<never>): string =>\n column.srLabel ?? (typeof column.label === 'string' ? column.label : column.key);\n\n/**\n * The column menu of a data-mode `DataTable` (3.1): visibility checkboxes and move up / down in a\n * `Popover`. Pass it as the table's `columnMenu`; it edits that table's `columnState`, controlled\n * or not. Outside a data-mode `DataTable` it draws nothing.\n */\nconst DataTableColumnMenu = ({ labels }: Props) => {\n const { labels: uiLabels } = useUi();\n const table = useContext(DataTableColumnMenuContext);\n if (!table) return null;\n\n const { columns, hidden, toggleColumn, moveColumn } = table;\n const title = resolveLabel(\n 'DataTableColumnMenu.labels.columns',\n labels?.columns,\n uiLabels?.dataTable?.columns,\n );\n const moveUp = labels?.moveUp ?? uiLabels?.dataTable?.moveUp;\n const moveDown = labels?.moveDown ?? uiLabels?.dataTable?.moveDown;\n\n return (\n <Popover\n label={title}\n align=\"end\"\n trigger={<IconButton icon={<LayoutThreeColumns aria-hidden />} label={title} size=\"sm\" />}\n >\n <ul className={styles.columnMenu}>\n {columns.map((column, index) => {\n const name = columnName(column);\n\n return (\n <li key={column.key} className={styles.columnMenu__item}>\n <Checkbox\n label={name}\n checked={column.isAlwaysVisible || !hidden.has(column.key)}\n disabled={column.isAlwaysVisible}\n onChange={() => toggleColumn(column.key)}\n className={styles.columnMenu__check}\n />\n {/* `aria-disabled`, not `disabled`: the focused button keeps the focus at the edge. */}\n <IconButton\n icon={<ArrowUp aria-hidden />}\n label={resolveFormatter('DataTableColumnMenu.labels.moveUp', moveUp, name)}\n size=\"sm\"\n aria-disabled={index === 0 || undefined}\n onClick={() => moveColumn(index, -1)}\n />\n <IconButton\n icon={<ArrowDown aria-hidden />}\n label={resolveFormatter('DataTableColumnMenu.labels.moveDown', moveDown, name)}\n size=\"sm\"\n aria-disabled={index === columns.length - 1 || undefined}\n onClick={() => moveColumn(index, 1)}\n />\n </li>\n );\n })}\n </ul>\n </Popover>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(DataTableColumnMenu, 'DataTableColumnMenu'));\n"],"names":["columnName","column","DataTableColumnMenu","labels","uiLabels","useUi","table","useContext","DataTableColumnMenuContext","columns","hidden","toggleColumn","moveColumn","title","resolveLabel","_a","moveUp","_b","moveDown","_c","jsx","Popover","IconButton","LayoutThreeColumns","styles","index","name","jsxs","Checkbox","ArrowUp","resolveFormatter","ArrowDown","memo","named"],"mappings":";;;;;;;;;;;;AA6BA,MAAMA,IAAa,CAACC,MAClBA,EAAO,YAAY,OAAOA,EAAO,SAAU,WAAWA,EAAO,QAAQA,EAAO,MAOxEC,IAAsB,CAAC,EAAE,QAAAC,QAAoB;;AACjD,QAAM,EAAE,QAAQC,EAAA,IAAaC,EAAA,GACvBC,IAAQC,EAAWC,CAA0B;AACnD,MAAI,CAACF,EAAO,QAAO;AAEnB,QAAM,EAAE,SAAAG,GAAS,QAAAC,GAAQ,cAAAC,GAAc,YAAAC,MAAeN,GAChDO,IAAQC;AAAA,IACZ;AAAA,IACAX,KAAA,gBAAAA,EAAQ;AAAA,KACRY,IAAAX,KAAA,gBAAAA,EAAU,cAAV,gBAAAW,EAAqB;AAAA,EAAA,GAEjBC,KAASb,KAAA,gBAAAA,EAAQ,aAAUc,IAAAb,KAAA,gBAAAA,EAAU,cAAV,gBAAAa,EAAqB,SAChDC,KAAWf,KAAA,gBAAAA,EAAQ,eAAYgB,IAAAf,KAAA,gBAAAA,EAAU,cAAV,gBAAAe,EAAqB;A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AAA;AAAA,QACpC,EAAA,GAtBOxB,EAAO,GAuBhB;AAAA,MAEJ,CAAC,EAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAGN,GAEAwB,IAA6B,gBAAAO,EAAmB,gBAAAC,EAAM/B,GAAqB,qBAAqB,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-columnMenu-MSpeh{display:flex;flex-direction:column;gap:var(--hd-space-1);margin:0;padding:0;list-style:none;min-width:220px}.ui-columnMenu__item-NPI--{display:flex;align-items:center;gap:var(--hd-space-1)}.ui-columnMenu__check-F-AK4{flex:1;min-width:0}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),a=require("react"),R=require("react-bootstrap-icons"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),a=require("react"),R=require("react-bootstrap-icons"),D=require("../../helpers/class-name.helper.cjs"),L=require("../../helpers/component.helper.cjs"),o=require("../../helpers/focus.helper.cjs"),M=require("../../helpers/label.helper.cjs"),E=require("../../hooks/useScrollLock.cjs"),S=require("../../hooks/useSheetViewport.cjs"),$=require("../../theme/context.cjs"),y=require("../IconButton/index.cjs"),r={default:{"drawer":"ui-drawer-fgfi1","drawer--sm":"ui-drawer--sm-ywgof","drawer--md":"ui-drawer--md-mN8Kg","drawer--lg":"ui-drawer--lg-5H-oE","drawer--end":"ui-drawer--end-q-sIP","drawer--start":"ui-drawer--start-xqVlX","drawer__header":"ui-drawer__header-BDcRe","drawer__title":"ui-drawer__title-9M0e8","drawer__close":"ui-drawer__close-Z30oW","drawer__toolbar":"ui-drawer__toolbar-vcsYi","drawer__body":"ui-drawer__body-x12SX","drawer__footer":"ui-drawer__footer-PajTg"}},I=({isOpen:s,onClose:c,title:p,closeLabel:x,children:q,side:v="end",size:g="md",footer:f,toolbar:_,initialFocus:h,className:j,testId:b})=>{const{labels:d}=$.useUi(),l=a.useRef(null),n=a.useRef(null),m=a.useRef(h);m.current=h;const w=a.useId();a.useEffect(()=>{const e=l.current;if(!e)return;if(!s){e.open&&e.close();return}const u=o.captureFocus();e.open||e.showModal(),o.focusDialogContent(e,m.current,`.${r.default.drawer__close}`);const{token:i,pop:N}=o.pushModal();return n.current=i,()=>{e.open&&e.close(),N(),n.current=null,u()}},[s]),E.default(s),S.default(s),a.useEffect(()=>{const e=l.current;if(!e)return;const u=i=>{i.preventDefault(),!(n.current&&!o.isTopModal(n.current))&&c()};return e.addEventListener("cancel",u),()=>e.removeEventListener("cancel",u)},[c]);const k=a.useCallback(e=>{e.target===l.current&&c()},[c]);return t.jsxs("dialog",{ref:l,className:D.cx(r.default.drawer,r.default[`drawer--${v}`],r.default[`drawer--${g}`],j),"aria-labelledby":w,"data-testid":b,onClick:k,children:[t.jsxs("header",{className:r.default.drawer__header,children:[t.jsx("h2",{id:w,className:r.default.drawer__title,children:p}),t.jsx(y.default,{icon:t.jsx(R.XLg,{"aria-hidden":!0}),label:M.resolveLabel("Drawer.closeLabel",x,d==null?void 0:d.close),variant:"ghost",size:"sm",className:r.default.drawer__close,onClick:c})]}),_&&t.jsx("div",{className:r.default.drawer__toolbar,children:_}),t.jsx("div",{className:r.default.drawer__body,children:q}),f&&t.jsx("div",{className:r.default.drawer__footer,children:f})]})},B=a.memo(L.named(I,"Drawer"));exports.default=B;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Drawer/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n memo,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n} from 'react';\n\nimport { XLg } from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport {\n captureFocus,\n focusDialogContent,\n type FocusTarget,\n isTopModal,\n pushModal,\n} from '../../helpers/focus.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport useScrollLock from '../../hooks/useScrollLock';\nimport useSheetViewport from '../../hooks/useSheetViewport';\nimport { useUi } from '../../theme/context';\nimport IconButton from '../IconButton';\n\nimport styles from './index.module.scss';\n\ntype Props = {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n /** Kapatma düğmesinin erişilebilir adı. */\n closeLabel?: string;\n children: ReactNode;\n /** Panelin hangi kenardan geldiği. */\n side?: 'start' | 'end';\n size?: 'sm' | 'md' | 'lg';\n /** Dipte duran eylem şeridi; gövde kaydırılırken yerinde kalır. */\n footer?: ReactNode;\n /** Başlığın altında duran, gövdeyle birlikte kaymayan şerit. */\n toolbar?: ReactNode;\n /**\n * Açılınca odaklanacak öğe (pencerenin içinde). Verilmezse `data-ui-autofocus` taşıyan öğe, o da\n * yoksa kapatma düğmesinden sonraki ilk odaklanabilir öğe. ⚠ İçerikteki React `autoFocus`u\n * `showModal()`dan ÖNCE koştuğu için etkisizdir; yerine bu prop.\n */\n initialFocus?: FocusTarget;\n className?: string;\n testId?: string;\n};\n\n/** Çekmece (drawer) — kenardan açılan kipsel panel. */\nconst Drawer = ({\n isOpen,\n onClose,\n title,\n closeLabel,\n children,\n side = 'end',\n size = 'md',\n footer,\n toolbar,\n initialFocus,\n className,\n testId,\n}: Props) => {\n const { labels } = useUi();\n const dialogRef = useRef<HTMLDialogElement>(null);\n /* Yigindaki yerimiz: */\n const tokenRef = useRef<symbol | null>(null);\n /* Acilis etkisi yalnizca `isOpen`a bagli; hedef her cizimde guncel okunur. */\n const initialFocusRef = useRef(initialFocus);\n initialFocusRef.current = initialFocus;\n const titleId = useId();\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n if (!isOpen) {\n if (dialog.open) dialog.close();\n return;\n }\n\n const restoreFocus = captureFocus();\n if (!dialog.open) dialog.showModal();\n\n focusDialogContent(dialog, initialFocusRef.current, `.${styles.drawer__close}`);\n\n const { token, pop } = pushModal();\n tokenRef.current = token;\n\n return () => {\n /*\n * Siralama ZORUNLU (`CommandPalette` gibi): kipsel pencere acikken disaridaki oge odak ALAMAZ.\n * Pencere once kapanir, sonra odak acan ogeye doner.\n */\n if (dialog.open) dialog.close();\n pop();\n tokenRef.current = null;\n restoreFocus();\n };\n }, [isOpen]);\n\n useScrollLock(isOpen);\n\n /*\n * ⚠ GÖRSEL GÖRÜNÜM ALANI TAKİBİ — `BottomSheet` ve `Modal` bunu zaten yapıyordu, `Drawer`\n * YAPMIYORDU.\n * ⚠ BAYRAK ZORUNLU — `BottomSheet`ten farkı burada. `Drawer` `<dialog>`ı KOŞULSUZ çiziyor\n * (yalnızca `showModal()`/`close()` `isOpen`e bağlı)…\n */\n useSheetViewport(isOpen);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n if (tokenRef.current && !isTopModal(tokenRef.current)) return;\n onClose();\n };\n\n dialog.addEventListener('cancel', handleCancel);\n return () => dialog.removeEventListener('cancel', handleCancel);\n }, [onClose]);\n\n const handleBackdropClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n // Hedef dialog'un KENDISI ise perdeye tiklanmistir; panel degil.\n if (event.target === dialogRef.current) onClose();\n },\n [onClose],\n );\n\n return (\n <dialog\n ref={dialogRef}\n className={cx(styles.drawer, styles[`drawer--${side}`], styles[`drawer--${size}`], className)}\n aria-labelledby={titleId}\n data-testid={testId}\n onClick={handleBackdropClick}\n >\n <header className={styles.drawer__header}>\n <h2 id={titleId} className={styles.drawer__title}>\n {title}\n </h2>\n\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('Drawer.closeLabel', closeLabel, labels?.close)}\n variant=\"ghost\"\n size=\"sm\"\n className={styles.drawer__close}\n onClick={onClose}\n />\n </header>\n\n {toolbar && <div className={styles.drawer__toolbar}>{toolbar}</div>}\n\n <div className={styles.drawer__body}>{children}</div>\n\n {footer && <div className={styles.drawer__footer}>{footer}</div>}\n </dialog>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Drawer, 'Drawer')) as typeof Drawer;\n"],"names":["Drawer","isOpen","onClose","title","closeLabel","children","side","size","footer","toolbar","initialFocus","className","testId","labels","useUi","dialogRef","useRef","tokenRef","initialFocusRef","titleId","useId","useEffect","dialog","restoreFocus","captureFocus","focusDialogContent","styles","token","pop","pushModal","useScrollLock","useSheetViewport","handleCancel","event","isTopModal","handleBackdropClick","useCallback","jsxs","cx","jsx","IconButton","XLg","resolveLabel","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Drawer/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n memo,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n} from 'react';\n\nimport { XLg } from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport {\n captureFocus,\n focusDialogContent,\n type FocusTarget,\n isTopModal,\n pushModal,\n} from '../../helpers/focus.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport useScrollLock from '../../hooks/useScrollLock';\nimport useSheetViewport from '../../hooks/useSheetViewport';\nimport { useUi } from '../../theme/context';\nimport IconButton from '../IconButton';\n\nimport styles from './index.module.scss';\n\ntype Props = {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n /** Kapatma düğmesinin erişilebilir adı. */\n closeLabel?: string;\n children: ReactNode;\n /** Panelin hangi kenardan geldiği. */\n side?: 'start' | 'end';\n size?: 'sm' | 'md' | 'lg';\n /** Dipte duran eylem şeridi; gövde kaydırılırken yerinde kalır. */\n footer?: ReactNode;\n /** Başlığın altında duran, gövdeyle birlikte kaymayan şerit. */\n toolbar?: ReactNode;\n /**\n * Açılınca odaklanacak öğe (pencerenin içinde). Verilmezse `data-ui-autofocus` taşıyan öğe, o da\n * yoksa kapatma düğmesinden sonraki ilk odaklanabilir öğe. ⚠ İçerikteki React `autoFocus`u\n * `showModal()`dan ÖNCE koştuğu için etkisizdir; yerine bu prop.\n */\n initialFocus?: FocusTarget;\n className?: string;\n testId?: string;\n};\n\n/** Çekmece (drawer) — kenardan açılan kipsel panel. */\nconst Drawer = ({\n isOpen,\n onClose,\n title,\n closeLabel,\n children,\n side = 'end',\n size = 'md',\n footer,\n toolbar,\n initialFocus,\n className,\n testId,\n}: Props) => {\n const { labels } = useUi();\n const dialogRef = useRef<HTMLDialogElement>(null);\n /* Yigindaki yerimiz: */\n const tokenRef = useRef<symbol | null>(null);\n /* Acilis etkisi yalnizca `isOpen`a bagli; hedef her cizimde guncel okunur. */\n const initialFocusRef = useRef(initialFocus);\n initialFocusRef.current = initialFocus;\n const titleId = useId();\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n if (!isOpen) {\n if (dialog.open) dialog.close();\n return;\n }\n\n const restoreFocus = captureFocus();\n if (!dialog.open) dialog.showModal();\n\n focusDialogContent(dialog, initialFocusRef.current, `.${styles.drawer__close}`);\n\n const { token, pop } = pushModal();\n tokenRef.current = token;\n\n return () => {\n /*\n * Siralama ZORUNLU (`CommandPalette` gibi): kipsel pencere acikken disaridaki oge odak ALAMAZ.\n * Pencere once kapanir, sonra odak acan ogeye doner.\n */\n if (dialog.open) dialog.close();\n pop();\n tokenRef.current = null;\n restoreFocus();\n };\n }, [isOpen]);\n\n useScrollLock(isOpen);\n\n /*\n * ⚠ GÖRSEL GÖRÜNÜM ALANI TAKİBİ — `BottomSheet` ve `Modal` bunu zaten yapıyordu, `Drawer`\n * YAPMIYORDU.\n * ⚠ BAYRAK ZORUNLU — `BottomSheet`ten farkı burada. `Drawer` `<dialog>`ı KOŞULSUZ çiziyor\n * (yalnızca `showModal()`/`close()` `isOpen`e bağlı)…\n */\n useSheetViewport(isOpen);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n if (tokenRef.current && !isTopModal(tokenRef.current)) return;\n onClose();\n };\n\n dialog.addEventListener('cancel', handleCancel);\n return () => dialog.removeEventListener('cancel', handleCancel);\n }, [onClose]);\n\n const handleBackdropClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n // Hedef dialog'un KENDISI ise perdeye tiklanmistir; panel degil.\n if (event.target === dialogRef.current) onClose();\n },\n [onClose],\n );\n\n return (\n <dialog\n ref={dialogRef}\n className={cx(styles.drawer, styles[`drawer--${side}`], styles[`drawer--${size}`], className)}\n aria-labelledby={titleId}\n data-testid={testId}\n onClick={handleBackdropClick}\n >\n <header className={styles.drawer__header}>\n <h2 id={titleId} className={styles.drawer__title}>\n {title}\n </h2>\n\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('Drawer.closeLabel', closeLabel, labels?.close)}\n variant=\"ghost\"\n size=\"sm\"\n className={styles.drawer__close}\n onClick={onClose}\n />\n </header>\n\n {toolbar && <div className={styles.drawer__toolbar}>{toolbar}</div>}\n\n <div className={styles.drawer__body}>{children}</div>\n\n {footer && <div className={styles.drawer__footer}>{footer}</div>}\n </dialog>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Drawer, 'Drawer')) as typeof Drawer;\n"],"names":["Drawer","isOpen","onClose","title","closeLabel","children","side","size","footer","toolbar","initialFocus","className","testId","labels","useUi","dialogRef","useRef","tokenRef","initialFocusRef","titleId","useId","useEffect","dialog","restoreFocus","captureFocus","focusDialogContent","styles","token","pop","pushModal","useScrollLock","useSheetViewport","handleCancel","event","isTopModal","handleBackdropClick","useCallback","jsxs","cx","jsx","IconButton","XLg","resolveLabel","memo","named"],"mappings":"qlBAuDMA,EAAS,CAAC,CACd,OAAAC,EACA,QAAAC,EACA,MAAAC,EACA,WAAAC,EACA,SAAAC,EACA,KAAAC,EAAO,MACP,KAAAC,EAAO,KACP,OAAAC,EACA,QAAAC,EACA,aAAAC,EACA,UA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EAGV,OACEmC,EAAAA,KAAC,SAAA,CACC,IAAKtB,EACL,UAAWuB,EAAAA,GAAGZ,EAAAA,QAAO,OAAQA,EAAAA,QAAO,WAAWpB,CAAI,EAAE,EAAGoB,EAAAA,QAAO,WAAWnB,CAAI,EAAE,EAAGI,CAAS,EAC5F,kBAAiBQ,EACjB,cAAaP,EACb,QAASuB,EAET,SAAA,CAAAE,EAAAA,KAAC,SAAA,CAAO,UAAWX,EAAAA,QAAO,eACxB,SAAA,CAAAa,MAAC,MAAG,GAAIpB,EAAS,UAAWO,EAAAA,QAAO,cAChC,SAAAvB,EACH,EAEAoC,EAAAA,IAACC,EAAAA,QAAA,CACC,KAAMD,EAAAA,IAACE,EAAAA,IAAA,CAAI,cAAW,EAAA,CAAC,EACvB,MAAOC,EAAAA,aAAa,oBAAqBtC,EAAYS,GAAA,YAAAA,EAAQ,KAAK,EAClE,QAAQ,QACR,KAAK,KACL,UAAWa,EAAAA,QAAO,cAClB,QAASxB,CAAA,CAAA,CACX,EACF,EAECO,GAAW8B,EAAAA,IAAC,MAAA,CAAI,UAAWb,EAAAA,QAAO,gBAAkB,SAAAjB,EAAQ,EAE7D8B,EAAAA,IAAC,MAAA,CAAI,UAAWb,EAAAA,QAAO,aAAe,SAAArB,EAAS,EAE9CG,GAAU+B,EAAAA,IAAC,MAAA,CAAI,UAAWb,EAAAA,QAAO,eAAiB,SAAAlB,CAAA,CAAO,CAAA,CAAA,CAAA,CAGhE,EAEAR,EAA6B2C,OAAmBC,EAAAA,MAAM5C,EAAQ,QAAQ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { memo as
|
|
4
|
-
import { XLg as
|
|
5
|
-
import { cx as
|
|
2
|
+
import { jsxs as h, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { memo as $, useRef as d, useId as y, useEffect as _, useCallback as E } from "react";
|
|
4
|
+
import { XLg as I } from "react-bootstrap-icons";
|
|
5
|
+
import { cx as M } from "../../helpers/class-name.helper.js";
|
|
6
6
|
import { named as j } from "../../helpers/component.helper.js";
|
|
7
7
|
import { focusDialogContent as B, pushModal as C, captureFocus as F, isTopModal as S } from "../../helpers/focus.helper.js";
|
|
8
8
|
import { resolveLabel as z } from "../../helpers/label.helper.js";
|
|
@@ -10,7 +10,7 @@ import T from "../../hooks/useScrollLock.js";
|
|
|
10
10
|
import U from "../../hooks/useSheetViewport.js";
|
|
11
11
|
import { useUi as V } from "../../theme/context.js";
|
|
12
12
|
import X from "../IconButton/index.js";
|
|
13
|
-
const
|
|
13
|
+
const e = {"drawer":"ui-drawer-fgfi1","drawer--sm":"ui-drawer--sm-ywgof","drawer--md":"ui-drawer--md-mN8Kg","drawer--lg":"ui-drawer--lg-5H-oE","drawer--end":"ui-drawer--end-q-sIP","drawer--start":"ui-drawer--start-xqVlX","drawer__header":"ui-drawer__header-BDcRe","drawer__title":"ui-drawer__title-9M0e8","drawer__close":"ui-drawer__close-Z30oW","drawer__toolbar":"ui-drawer__toolbar-vcsYi","drawer__body":"ui-drawer__body-x12SX","drawer__footer":"ui-drawer__footer-PajTg"};
|
|
14
14
|
const q = ({
|
|
15
15
|
isOpen: a,
|
|
16
16
|
onClose: o,
|
|
@@ -22,70 +22,70 @@ const q = ({
|
|
|
22
22
|
footer: m,
|
|
23
23
|
toolbar: u,
|
|
24
24
|
initialFocus: f,
|
|
25
|
-
className:
|
|
26
|
-
testId:
|
|
25
|
+
className: D,
|
|
26
|
+
testId: L
|
|
27
27
|
}) => {
|
|
28
28
|
const { labels: l } = V(), c = d(null), n = d(null), p = d(f);
|
|
29
29
|
p.current = f;
|
|
30
|
-
const
|
|
30
|
+
const w = y();
|
|
31
31
|
_(() => {
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
32
|
+
const r = c.current;
|
|
33
|
+
if (!r) return;
|
|
34
34
|
if (!a) {
|
|
35
|
-
|
|
35
|
+
r.open && r.close();
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
const s = F();
|
|
39
|
-
|
|
39
|
+
r.open || r.showModal(), B(r, p.current, `.${e.drawer__close}`);
|
|
40
40
|
const { token: i, pop: R } = C();
|
|
41
41
|
return n.current = i, () => {
|
|
42
|
-
|
|
42
|
+
r.open && r.close(), R(), n.current = null, s();
|
|
43
43
|
};
|
|
44
44
|
}, [a]), T(a), U(a), _(() => {
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
45
|
+
const r = c.current;
|
|
46
|
+
if (!r) return;
|
|
47
47
|
const s = (i) => {
|
|
48
48
|
i.preventDefault(), !(n.current && !S(n.current)) && o();
|
|
49
49
|
};
|
|
50
|
-
return
|
|
50
|
+
return r.addEventListener("cancel", s), () => r.removeEventListener("cancel", s);
|
|
51
51
|
}, [o]);
|
|
52
|
-
const
|
|
53
|
-
(
|
|
54
|
-
|
|
52
|
+
const x = E(
|
|
53
|
+
(r) => {
|
|
54
|
+
r.target === c.current && o();
|
|
55
55
|
},
|
|
56
56
|
[o]
|
|
57
57
|
);
|
|
58
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ h(
|
|
59
59
|
"dialog",
|
|
60
60
|
{
|
|
61
61
|
ref: c,
|
|
62
|
-
className:
|
|
63
|
-
"aria-labelledby":
|
|
64
|
-
"data-testid":
|
|
65
|
-
onClick:
|
|
62
|
+
className: M(e.drawer, e[`drawer--${N}`], e[`drawer--${b}`], D),
|
|
63
|
+
"aria-labelledby": w,
|
|
64
|
+
"data-testid": L,
|
|
65
|
+
onClick: x,
|
|
66
66
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
/* @__PURE__ */ t("h2", { id:
|
|
67
|
+
/* @__PURE__ */ h("header", { className: e.drawer__header, children: [
|
|
68
|
+
/* @__PURE__ */ t("h2", { id: w, className: e.drawer__title, children: v }),
|
|
69
69
|
/* @__PURE__ */ t(
|
|
70
70
|
X,
|
|
71
71
|
{
|
|
72
|
-
icon: /* @__PURE__ */ t(
|
|
72
|
+
icon: /* @__PURE__ */ t(I, { "aria-hidden": !0 }),
|
|
73
73
|
label: z("Drawer.closeLabel", g, l == null ? void 0 : l.close),
|
|
74
74
|
variant: "ghost",
|
|
75
75
|
size: "sm",
|
|
76
|
-
className:
|
|
76
|
+
className: e.drawer__close,
|
|
77
77
|
onClick: o
|
|
78
78
|
}
|
|
79
79
|
)
|
|
80
80
|
] }),
|
|
81
|
-
u && /* @__PURE__ */ t("div", { className:
|
|
82
|
-
/* @__PURE__ */ t("div", { className:
|
|
83
|
-
m && /* @__PURE__ */ t("div", { className:
|
|
81
|
+
u && /* @__PURE__ */ t("div", { className: e.drawer__toolbar, children: u }),
|
|
82
|
+
/* @__PURE__ */ t("div", { className: e.drawer__body, children: k }),
|
|
83
|
+
m && /* @__PURE__ */ t("div", { className: e.drawer__footer, children: m })
|
|
84
84
|
]
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
|
-
},
|
|
87
|
+
}, er = /* @__PURE__ */ $(/* @__PURE__ */ j(q, "Drawer"));
|
|
88
88
|
export {
|
|
89
|
-
|
|
89
|
+
er as default
|
|
90
90
|
};
|
|
91
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Drawer/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n memo,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n} from 'react';\n\nimport { XLg } from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport {\n captureFocus,\n focusDialogContent,\n type FocusTarget,\n isTopModal,\n pushModal,\n} from '../../helpers/focus.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport useScrollLock from '../../hooks/useScrollLock';\nimport useSheetViewport from '../../hooks/useSheetViewport';\nimport { useUi } from '../../theme/context';\nimport IconButton from '../IconButton';\n\nimport styles from './index.module.scss';\n\ntype Props = {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n /** Kapatma düğmesinin erişilebilir adı. */\n closeLabel?: string;\n children: ReactNode;\n /** Panelin hangi kenardan geldiği. */\n side?: 'start' | 'end';\n size?: 'sm' | 'md' | 'lg';\n /** Dipte duran eylem şeridi; gövde kaydırılırken yerinde kalır. */\n footer?: ReactNode;\n /** Başlığın altında duran, gövdeyle birlikte kaymayan şerit. */\n toolbar?: ReactNode;\n /**\n * Açılınca odaklanacak öğe (pencerenin içinde). Verilmezse `data-ui-autofocus` taşıyan öğe, o da\n * yoksa kapatma düğmesinden sonraki ilk odaklanabilir öğe. ⚠ İçerikteki React `autoFocus`u\n * `showModal()`dan ÖNCE koştuğu için etkisizdir; yerine bu prop.\n */\n initialFocus?: FocusTarget;\n className?: string;\n testId?: string;\n};\n\n/** Çekmece (drawer) — kenardan açılan kipsel panel. */\nconst Drawer = ({\n isOpen,\n onClose,\n title,\n closeLabel,\n children,\n side = 'end',\n size = 'md',\n footer,\n toolbar,\n initialFocus,\n className,\n testId,\n}: Props) => {\n const { labels } = useUi();\n const dialogRef = useRef<HTMLDialogElement>(null);\n /* Yigindaki yerimiz: */\n const tokenRef = useRef<symbol | null>(null);\n /* Acilis etkisi yalnizca `isOpen`a bagli; hedef her cizimde guncel okunur. */\n const initialFocusRef = useRef(initialFocus);\n initialFocusRef.current = initialFocus;\n const titleId = useId();\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n if (!isOpen) {\n if (dialog.open) dialog.close();\n return;\n }\n\n const restoreFocus = captureFocus();\n if (!dialog.open) dialog.showModal();\n\n focusDialogContent(dialog, initialFocusRef.current, `.${styles.drawer__close}`);\n\n const { token, pop } = pushModal();\n tokenRef.current = token;\n\n return () => {\n /*\n * Siralama ZORUNLU (`CommandPalette` gibi): kipsel pencere acikken disaridaki oge odak ALAMAZ.\n * Pencere once kapanir, sonra odak acan ogeye doner.\n */\n if (dialog.open) dialog.close();\n pop();\n tokenRef.current = null;\n restoreFocus();\n };\n }, [isOpen]);\n\n useScrollLock(isOpen);\n\n /*\n * ⚠ GÖRSEL GÖRÜNÜM ALANI TAKİBİ — `BottomSheet` ve `Modal` bunu zaten yapıyordu, `Drawer`\n * YAPMIYORDU.\n * ⚠ BAYRAK ZORUNLU — `BottomSheet`ten farkı burada. `Drawer` `<dialog>`ı KOŞULSUZ çiziyor\n * (yalnızca `showModal()`/`close()` `isOpen`e bağlı)…\n */\n useSheetViewport(isOpen);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n if (tokenRef.current && !isTopModal(tokenRef.current)) return;\n onClose();\n };\n\n dialog.addEventListener('cancel', handleCancel);\n return () => dialog.removeEventListener('cancel', handleCancel);\n }, [onClose]);\n\n const handleBackdropClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n // Hedef dialog'un KENDISI ise perdeye tiklanmistir; panel degil.\n if (event.target === dialogRef.current) onClose();\n },\n [onClose],\n );\n\n return (\n <dialog\n ref={dialogRef}\n className={cx(styles.drawer, styles[`drawer--${side}`], styles[`drawer--${size}`], className)}\n aria-labelledby={titleId}\n data-testid={testId}\n onClick={handleBackdropClick}\n >\n <header className={styles.drawer__header}>\n <h2 id={titleId} className={styles.drawer__title}>\n {title}\n </h2>\n\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('Drawer.closeLabel', closeLabel, labels?.close)}\n variant=\"ghost\"\n size=\"sm\"\n className={styles.drawer__close}\n onClick={onClose}\n />\n </header>\n\n {toolbar && <div className={styles.drawer__toolbar}>{toolbar}</div>}\n\n <div className={styles.drawer__body}>{children}</div>\n\n {footer && <div className={styles.drawer__footer}>{footer}</div>}\n </dialog>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Drawer, 'Drawer')) as typeof Drawer;\n"],"names":["Drawer","isOpen","onClose","title","closeLabel","children","side","size","footer","toolbar","initialFocus","className","testId","labels","useUi","dialogRef","useRef","tokenRef","initialFocusRef","titleId","useId","useEffect","dialog","restoreFocus","captureFocus","focusDialogContent","styles","token","pop","pushModal","useScrollLock","useSheetViewport","handleCancel","event","isTopModal","handleBackdropClick","useCallback","jsxs","cx","jsx","IconButton","XLg","resolveLabel","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Drawer/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n memo,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n} from 'react';\n\nimport { XLg } from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport {\n captureFocus,\n focusDialogContent,\n type FocusTarget,\n isTopModal,\n pushModal,\n} from '../../helpers/focus.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport useScrollLock from '../../hooks/useScrollLock';\nimport useSheetViewport from '../../hooks/useSheetViewport';\nimport { useUi } from '../../theme/context';\nimport IconButton from '../IconButton';\n\nimport styles from './index.module.scss';\n\ntype Props = {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n /** Kapatma düğmesinin erişilebilir adı. */\n closeLabel?: string;\n children: ReactNode;\n /** Panelin hangi kenardan geldiği. */\n side?: 'start' | 'end';\n size?: 'sm' | 'md' | 'lg';\n /** Dipte duran eylem şeridi; gövde kaydırılırken yerinde kalır. */\n footer?: ReactNode;\n /** Başlığın altında duran, gövdeyle birlikte kaymayan şerit. */\n toolbar?: ReactNode;\n /**\n * Açılınca odaklanacak öğe (pencerenin içinde). Verilmezse `data-ui-autofocus` taşıyan öğe, o da\n * yoksa kapatma düğmesinden sonraki ilk odaklanabilir öğe. ⚠ İçerikteki React `autoFocus`u\n * `showModal()`dan ÖNCE koştuğu için etkisizdir; yerine bu prop.\n */\n initialFocus?: FocusTarget;\n className?: string;\n testId?: string;\n};\n\n/** Çekmece (drawer) — kenardan açılan kipsel panel. */\nconst Drawer = ({\n isOpen,\n onClose,\n title,\n closeLabel,\n children,\n side = 'end',\n size = 'md',\n footer,\n toolbar,\n initialFocus,\n className,\n testId,\n}: Props) => {\n const { labels } = useUi();\n const dialogRef = useRef<HTMLDialogElement>(null);\n /* Yigindaki yerimiz: */\n const tokenRef = useRef<symbol | null>(null);\n /* Acilis etkisi yalnizca `isOpen`a bagli; hedef her cizimde guncel okunur. */\n const initialFocusRef = useRef(initialFocus);\n initialFocusRef.current = initialFocus;\n const titleId = useId();\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n if (!isOpen) {\n if (dialog.open) dialog.close();\n return;\n }\n\n const restoreFocus = captureFocus();\n if (!dialog.open) dialog.showModal();\n\n focusDialogContent(dialog, initialFocusRef.current, `.${styles.drawer__close}`);\n\n const { token, pop } = pushModal();\n tokenRef.current = token;\n\n return () => {\n /*\n * Siralama ZORUNLU (`CommandPalette` gibi): kipsel pencere acikken disaridaki oge odak ALAMAZ.\n * Pencere once kapanir, sonra odak acan ogeye doner.\n */\n if (dialog.open) dialog.close();\n pop();\n tokenRef.current = null;\n restoreFocus();\n };\n }, [isOpen]);\n\n useScrollLock(isOpen);\n\n /*\n * ⚠ GÖRSEL GÖRÜNÜM ALANI TAKİBİ — `BottomSheet` ve `Modal` bunu zaten yapıyordu, `Drawer`\n * YAPMIYORDU.\n * ⚠ BAYRAK ZORUNLU — `BottomSheet`ten farkı burada. `Drawer` `<dialog>`ı KOŞULSUZ çiziyor\n * (yalnızca `showModal()`/`close()` `isOpen`e bağlı)…\n */\n useSheetViewport(isOpen);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n if (tokenRef.current && !isTopModal(tokenRef.current)) return;\n onClose();\n };\n\n dialog.addEventListener('cancel', handleCancel);\n return () => dialog.removeEventListener('cancel', handleCancel);\n }, [onClose]);\n\n const handleBackdropClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n // Hedef dialog'un KENDISI ise perdeye tiklanmistir; panel degil.\n if (event.target === dialogRef.current) onClose();\n },\n [onClose],\n );\n\n return (\n <dialog\n ref={dialogRef}\n className={cx(styles.drawer, styles[`drawer--${side}`], styles[`drawer--${size}`], className)}\n aria-labelledby={titleId}\n data-testid={testId}\n onClick={handleBackdropClick}\n >\n <header className={styles.drawer__header}>\n <h2 id={titleId} className={styles.drawer__title}>\n {title}\n </h2>\n\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('Drawer.closeLabel', closeLabel, labels?.close)}\n variant=\"ghost\"\n size=\"sm\"\n className={styles.drawer__close}\n onClick={onClose}\n />\n </header>\n\n {toolbar && <div className={styles.drawer__toolbar}>{toolbar}</div>}\n\n <div className={styles.drawer__body}>{children}</div>\n\n {footer && <div className={styles.drawer__footer}>{footer}</div>}\n </dialog>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Drawer, 'Drawer')) as typeof Drawer;\n"],"names":["Drawer","isOpen","onClose","title","closeLabel","children","side","size","footer","toolbar","initialFocus","className","testId","labels","useUi","dialogRef","useRef","tokenRef","initialFocusRef","titleId","useId","useEffect","dialog","restoreFocus","captureFocus","focusDialogContent","styles","token","pop","pushModal","useScrollLock","useSheetViewport","handleCancel","event","isTopModal","handleBackdropClick","useCallback","jsxs","cx","jsx","IconButton","XLg","resolveLabel","Drawer$1","memo","named"],"mappings":";;;;;;;;;;;;;AAuDA,MAAMA,IAAS,CAAC;AAAA,EACd,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC;AACF,MAAa;AACX,QAAM,EAAE,QAAAC,EAAA,IAAWC,EAAA,GACbC,IAAYC,EAA0B,IAAI,GAE1CC,IAAWD,EAAsB,IAAI,GAErCE,IAAkBF,EAAON,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AAGoB,EAAO,WAAWnB,CAAI,EAAE,GAAGI,CAAS;AAAA,MAC5F,mBAAiBQ;AAAA,MACjB,eAAaP;AAAA,MACb,SAASuB;AAAA,MAET,UAAA;AAAA,QAAA,gBAAAE,EAAC,UAAA,EAAO,WAAWX,EAAO,gBACxB,UAAA;AAAA,UAAA,gBAAAa,EAAC,QAAG,IAAIpB,GAAS,WAAWO,EAAO,eAChC,UAAAvB,GACH;AAAA,UAEA,gBAAAoC;AAAA,YAACC;AAAA,YAAA;AAAA,cACC,MAAM,gBAAAD,EAACE,GAAA,EAAI,eAAW,GAAA,CAAC;AAAA,cACvB,OAAOC,EAAa,qBAAqBtC,GAAYS,KAAA,gBAAAA,EAAQ,KAAK;AAAA,cAClE,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,WAAWa,EAAO;AAAA,cAClB,SAASxB;AAAA,YAAA;AAAA,UAAA;AAAA,QACX,GACF;AAAA,QAECO,KAAW,gBAAA8B,EAAC,OAAA,EAAI,WAAWb,EAAO,iBAAkB,UAAAjB,GAAQ;AAAA,QAE7D,gBAAA8B,EAAC,OAAA,EAAI,WAAWb,EAAO,cAAe,UAAArB,GAAS;AAAA,QAE9CG,KAAU,gBAAA+B,EAAC,OAAA,EAAI,WAAWb,EAAO,gBAAiB,UAAAlB,EAAA,CAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhE,GAEAmC,KAA6B,gBAAAC,EAAmB,gBAAAC,EAAM7C,GAAQ,QAAQ,CAAC;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),u=require("react"),v=require("react-bootstrap-icons"),N=require("../../helpers/class-name.helper.cjs"),ne=require("../../helpers/component.helper.cjs"),F=require("../../helpers/focus.helper.cjs"),y=require("../../helpers/label.helper.cjs"),re=require("../../hooks/useScrollLock.cjs"),se=require("../../theme/context.cjs"),S=require("../IconButton/index.cjs"),r={default:{"gallery":"ui-gallery-kHzW5","srOnly":"ui-srOnly-yZqYR","stage":"ui-stage-rg2mL","stage__open":"ui-stage__open-O-WpB","stage__hint":"ui-stage__hint-yvk-Q","image":"ui-image-eMyVt","stage--zoom":"ui-stage--zoom-gCoIw","arrow":"ui-arrow-HMm6V","arrow--previous":"ui-arrow--previous-iynhU","arrow--next":"ui-arrow--next-xShor","arrowIcon":"ui-arrowIcon--GW5Q","thumbs":"ui-thumbs-fquXS","thumb":"ui-thumb-Upsix","thumb__image":"ui-thumb__image-9VWiM","viewer":"ui-viewer-mAIN4","viewer__bar":"ui-viewer__bar-8DJT1","viewer__count":"ui-viewer__count--vw9Q","viewer__stage":"ui-viewer__stage-YmCnh","viewer__stage--zoomed":"ui-viewer__stage--zoomed-ktQdi","viewer__image":"ui-viewer__image-hHATa"}},le=40,ce=({src:d,alt:w,className:x,width:l,height:h,variant:f})=>t.jsx("img",{src:d,alt:w,className:x,width:l,height:h,loading:f==="thumbnail"?"lazy":void 0,decoding:"async",draggable:!1}),A=(d,w,x)=>{const l=d.getBoundingClientRect(),h=l.width>0?(w-l.left)/l.width*100:50,f=l.height>0?(x-l.top)/l.height*100:50;d.style.setProperty("--ui-gallery-zoom-x",`${h}%`),d.style.setProperty("--ui-gallery-zoom-y",`${f}%`)},ie=({images:d,label:w,renderImage:x=ce,index:l,onIndexChange:h,hasZoom:f=!0,labels:a,className:W,testId:J})=>{var K,U,Z,B,V,H;const{labels:n}=se.useUi(),[Q,p]=u.useState(0),[b,I]=u.useState(!1),[g,M]=u.useState(!1),O=u.useRef(null),T=u.useRef(null),G=u.useRef(null),k=u.useRef(!1),c=d.length,o=Math.max(0,Math.min(l??Q,c-1)),z={thumbnails:y.resolveLabel("Gallery.labels.thumbnails",a==null?void 0:a.thumbnails,(K=n==null?void 0:n.gallery)==null?void 0:K.thumbnails),previous:y.resolveLabel("Gallery.labels.previous",a==null?void 0:a.previous,(U=n==null?void 0:n.gallery)==null?void 0:U.previous),next:y.resolveLabel("Gallery.labels.next",a==null?void 0:a.next,(Z=n==null?void 0:n.gallery)==null?void 0:Z.next),fullscreen:y.resolveLabel("Gallery.labels.fullscreen",a==null?void 0:a.fullscreen,(B=n==null?void 0:n.gallery)==null?void 0:B.fullscreen)},j=u.useCallback(e=>{const s=(e+c)%c;l===void 0&&p(s),M(!1),h==null||h(s)},[l,h,c]),C=u.useCallback(()=>{I(!1),M(!1)},[]);if(u.useEffect(()=>{const e=O.current;if(!b||!e)return;const s=F.captureFocus();e.open||e.showModal();const{token:i,pop:m}=F.pushModal(),_=q=>{q.preventDefault(),F.isTopModal(i)&&C()};return e.addEventListener("cancel",_),()=>{e.removeEventListener("cancel",_),e.open&&e.close(),m(),s()}},[b,C]),re.default(b),c===0)return null;const L=d[o],R=c>1,D=(e,s=!1)=>{var _,q;const i={ArrowRight:o+1,ArrowLeft:o-1,Home:0,End:c-1};if(!R||!(e.key in i))return;e.preventDefault();const m=(i[e.key]+c)%c;j(m),s&&((q=(_=T.current)==null?void 0:_.querySelectorAll("button")[m])==null||q.focus())},E=e=>{k.current=!1,G.current=g?null:{x:e.clientX,y:e.clientY}},X=e=>{const s=G.current;if(G.current=null,!s||!R)return;const i=e.clientX-s.x,m=e.clientY-s.y;Math.abs(i)<le||Math.abs(i)<Math.abs(m)||(k.current=!0,j(o+(i<0?1:-1)))},P=e=>{f&&e.pointerType==="mouse"&&A(e.currentTarget,e.clientX,e.clientY)},ee=()=>{k.current||I(!0)},te=e=>{!f||k.current||(A(e.currentTarget,e.clientX,e.clientY),M(s=>!s))},ae=e=>{g&&A(e.currentTarget,e.clientX,e.clientY)},Y=(e,s)=>({src:L.src,alt:L.alt,className:s,variant:e,index:o,width:L.width,height:L.height}),$=R&&t.jsxs(t.Fragment,{children:[t.jsx(S.default,{icon:t.jsx(v.ChevronLeft,{"aria-hidden":!0,className:r.default.arrowIcon}),label:z.previous,variant:"secondary",size:"sm",className:N.cx(r.default.arrow,r.default["arrow--previous"]),onClick:()=>j(o-1)}),t.jsx(S.default,{icon:t.jsx(v.ChevronRight,{"aria-hidden":!0,className:r.default.arrowIcon}),label:z.next,variant:"secondary",size:"sm",className:N.cx(r.default.arrow,r.default["arrow--next"]),onClick:()=>j(o+1)})]});return t.jsxs("section",{className:N.cx(r.default.gallery,W),"aria-label":w,"data-testid":J,children:[t.jsxs("div",{className:N.cx(r.default.stage,f&&r.default["stage--zoom"]),onPointerMove:P,onPointerDown:E,onPointerUp:X,onKeyDown:e=>D(e),children:[t.jsxs("button",{type:"button",className:r.default.stage__open,onClick:ee,children:[x(Y("main",r.default.image)),t.jsx("span",{className:r.default.srOnly,children:z.fullscreen}),t.jsx(v.ArrowsFullscreen,{"aria-hidden":!0,className:r.default.stage__hint})]}),$]}),R&&t.jsx("ul",{ref:T,className:r.default.thumbs,"aria-label":z.thumbnails,children:d.map((e,s)=>{var i;return t.jsx("li",{children:t.jsx("button",{type:"button",className:r.default.thumb,"aria-current":s===o||void 0,"aria-label":y.resolveFormatter("Gallery.labels.thumbnail",(a==null?void 0:a.thumbnail)??((i=n==null?void 0:n.gallery)==null?void 0:i.thumbnail),s+1,c),tabIndex:s===o?0:-1,onClick:()=>j(s),onKeyDown:m=>D(m,!0),children:x({src:e.thumbnailSrc??e.src,alt:"",className:r.default.thumb__image,variant:"thumbnail",index:s,width:e.width,height:e.height})})},`${e.src}-${s}`)})}),t.jsx("dialog",{ref:O,className:r.default.viewer,"aria-label":w,onKeyDown:e=>D(e),children:b&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:r.default.viewer__bar,children:[t.jsxs("span",{className:r.default.viewer__count,"aria-live":"polite",children:[o+1," / ",c]}),f&&t.jsx(S.default,{icon:g?t.jsx(v.ZoomOut,{"aria-hidden":!0}):t.jsx(v.ZoomIn,{"aria-hidden":!0}),label:g?y.resolveLabel("Gallery.labels.zoomOut",a==null?void 0:a.zoomOut,(V=n==null?void 0:n.gallery)==null?void 0:V.zoomOut):y.resolveLabel("Gallery.labels.zoomIn",a==null?void 0:a.zoomIn,(H=n==null?void 0:n.gallery)==null?void 0:H.zoomIn),variant:"secondary",onClick:()=>M(e=>!e)}),t.jsx(S.default,{icon:t.jsx(v.XLg,{"aria-hidden":!0}),label:y.resolveLabel("Gallery.labels.close",a==null?void 0:a.close,n==null?void 0:n.close),variant:"secondary",onClick:C})]}),t.jsx("div",{className:N.cx(r.default.viewer__stage,g&&r.default["viewer__stage--zoomed"]),onClick:te,onPointerDown:E,onPointerUp:X,onPointerMove:ae,children:x(Y("fullscreen",r.default.viewer__image))}),$]})})]})},ue=u.memo(ne.named(ie,"Gallery"));exports.default=ue;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Gallery/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type KeyboardEvent,\n memo,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n ArrowsFullscreen,\n ChevronLeft,\n ChevronRight,\n XLg,\n ZoomIn,\n ZoomOut,\n} from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { captureFocus, isTopModal, pushModal } from '../../helpers/focus.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport useScrollLock from '../../hooks/useScrollLock';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport IconButton from '../IconButton';\n\nimport styles from './index.module.scss';\n\nexport type GalleryImage = {\n src: string;\n /** What the image shows (\"Fren balatası, ön yüz\"). */\n alt: string;\n /** A smaller file for the thumbnail; `src` when omitted. */\n thumbnailSrc?: string;\n width?: number;\n height?: number;\n};\n\n/** Where an image is drawn: the adapter picks sizes and priority from it. */\nexport type GalleryImageVariant = 'main' | 'thumbnail' | 'fullscreen';\n\n/** What `renderImage` receives. `className` MUST reach the element: zoom is drawn through it. */\nexport type GalleryRenderImageProps = {\n src: string;\n alt: string;\n className: string;\n variant: GalleryImageVariant;\n /** The image's position in `images`. */\n index: number;\n width?: number;\n height?: number;\n};\n\nexport type GalleryLabels = {\n thumbnails: string;\n thumbnail: Formatter<[index: number, total: number]>;\n previous: string;\n next: string;\n fullscreen: string;\n zoomIn: string;\n zoomOut: string;\n close: string;\n};\n\ntype Props = {\n images: GalleryImage[];\n /** The gallery's accessible name (\"Ürün görselleri\"); also the full-screen view's name. */\n label: string;\n /**\n * Draws one image — the platform's own component (`next/image`, a cached Electron loader). A\n * plain `<img>` when omitted.\n */\n renderImage?: (props: GalleryRenderImageProps) => ReactNode;\n /** Controlled index of the shown image; uncontrolled when omitted. */\n index?: number;\n onIndexChange?: (index: number) => void;\n /** Magnifies the main image under a mouse pointer and lets the full-screen view zoom (default). */\n hasZoom?: boolean;\n labels?: Partial<GalleryLabels>;\n className?: string;\n testId?: string;\n};\n\n/* A horizontal drag this long (px) is a swipe, not a tap. */\nconst SWIPE_DISTANCE = 40;\n\nconst defaultRenderImage = ({\n src,\n alt,\n className,\n width,\n height,\n variant,\n}: GalleryRenderImageProps) => (\n <img\n src={src}\n alt={alt}\n className={className}\n width={width}\n height={height}\n loading={variant === 'thumbnail' ? 'lazy' : undefined}\n decoding=\"async\"\n draggable={false}\n />\n);\n\n/** Writes the zoom origin as custom properties: no re-render on every pointer move. */\nconst setZoomOrigin = (element: HTMLElement, clientX: number, clientY: number) => {\n const rect = element.getBoundingClientRect();\n const x = rect.width > 0 ? ((clientX - rect.left) / rect.width) * 100 : 50;\n const y = rect.height > 0 ? ((clientY - rect.top) / rect.height) * 100 : 50;\n element.style.setProperty('--ui-gallery-zoom-x', `${x}%`);\n element.style.setProperty('--ui-gallery-zoom-y', `${y}%`);\n};\n\n/** Product gallery: main image, thumbnails, hover zoom and a full-screen view (3.1). */\nconst Gallery = ({\n images,\n label,\n renderImage = defaultRenderImage,\n index: controlledIndex,\n onIndexChange,\n hasZoom = true,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const [innerIndex, setInnerIndex] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isZoomed, setIsZoomed] = useState(false);\n const dialogRef = useRef<HTMLDialogElement>(null);\n const thumbsRef = useRef<HTMLUListElement>(null);\n const swipeRef = useRef<{ x: number; y: number } | null>(null);\n /* A swipe ends with a click on the same element: that click must not open the viewer. */\n const didSwipeRef = useRef(false);\n\n const total = images.length;\n const current = Math.max(0, Math.min(controlledIndex ?? innerIndex, total - 1));\n\n const text = {\n thumbnails: resolveLabel(\n 'Gallery.labels.thumbnails',\n labelProps?.thumbnails,\n config?.gallery?.thumbnails,\n ),\n previous: resolveLabel(\n 'Gallery.labels.previous',\n labelProps?.previous,\n config?.gallery?.previous,\n ),\n next: resolveLabel('Gallery.labels.next', labelProps?.next, config?.gallery?.next),\n fullscreen: resolveLabel(\n 'Gallery.labels.fullscreen',\n labelProps?.fullscreen,\n config?.gallery?.fullscreen,\n ),\n };\n\n const select = useCallback(\n (next: number) => {\n const wrapped = (next + total) % total;\n if (controlledIndex === undefined) setInnerIndex(wrapped);\n setIsZoomed(false);\n onIndexChange?.(wrapped);\n },\n [controlledIndex, onIndexChange, total],\n );\n\n const close = useCallback(() => {\n setIsFullscreen(false);\n setIsZoomed(false);\n }, []);\n\n /* The viewer is a modal `<dialog>`, opened and closed like `Modal`. */\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!isFullscreen || !dialog) return;\n\n const restoreFocus = captureFocus();\n if (!dialog.open) dialog.showModal();\n const { token, pop } = pushModal();\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n if (isTopModal(token)) close();\n };\n dialog.addEventListener('cancel', handleCancel);\n\n return () => {\n dialog.removeEventListener('cancel', handleCancel);\n if (dialog.open) dialog.close();\n pop();\n restoreFocus();\n };\n }, [isFullscreen, close]);\n\n useScrollLock(isFullscreen);\n\n if (total === 0) return null;\n\n const image = images[current];\n const hasMany = total > 1;\n\n const handleArrowKeys = (event: KeyboardEvent<HTMLElement>, moveFocus = false) => {\n const target: Record<string, number> = {\n ArrowRight: current + 1,\n ArrowLeft: current - 1,\n Home: 0,\n End: total - 1,\n };\n if (!hasMany || !(event.key in target)) return;\n\n event.preventDefault();\n const next = (target[event.key] + total) % total;\n select(next);\n if (moveFocus) thumbsRef.current?.querySelectorAll('button')[next]?.focus();\n };\n\n const handlePointerDown = (event: PointerEvent<HTMLElement>) => {\n didSwipeRef.current = false;\n swipeRef.current = isZoomed ? null : { x: event.clientX, y: event.clientY };\n };\n\n const handlePointerUp = (event: PointerEvent<HTMLElement>) => {\n const start = swipeRef.current;\n swipeRef.current = null;\n if (!start || !hasMany) return;\n\n const dx = event.clientX - start.x;\n const dy = event.clientY - start.y;\n if (Math.abs(dx) < SWIPE_DISTANCE || Math.abs(dx) < Math.abs(dy)) return;\n\n didSwipeRef.current = true;\n select(current + (dx < 0 ? 1 : -1));\n };\n\n const handleStageMove = (event: PointerEvent<HTMLElement>) => {\n if (hasZoom && event.pointerType === 'mouse')\n setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n };\n\n const openViewer = () => {\n if (didSwipeRef.current) return;\n setIsFullscreen(true);\n };\n\n const toggleZoomAt = (event: MouseEvent<HTMLElement>) => {\n if (!hasZoom || didSwipeRef.current) return;\n setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n setIsZoomed(zoomed => !zoomed);\n };\n\n const handleViewerMove = (event: PointerEvent<HTMLElement>) => {\n if (isZoomed) setZoomOrigin(event.currentTarget, event.clientX, event.clientY);\n };\n\n const imageProps = (variant: GalleryImageVariant, className: string) => ({\n src: image.src,\n alt: image.alt,\n className,\n variant,\n index: current,\n width: image.width,\n height: image.height,\n });\n\n const arrows = hasMany && (\n <>\n <IconButton\n icon={<ChevronLeft aria-hidden className={styles.arrowIcon} />}\n label={text.previous}\n variant=\"secondary\"\n size=\"sm\"\n className={cx(styles.arrow, styles['arrow--previous'])}\n onClick={() => select(current - 1)}\n />\n <IconButton\n icon={<ChevronRight aria-hidden className={styles.arrowIcon} />}\n label={text.next}\n variant=\"secondary\"\n size=\"sm\"\n className={cx(styles.arrow, styles['arrow--next'])}\n onClick={() => select(current + 1)}\n />\n </>\n );\n\n return (\n <section className={cx(styles.gallery, className)} aria-label={label} data-testid={testId}>\n <div\n className={cx(styles.stage, hasZoom && styles['stage--zoom'])}\n onPointerMove={handleStageMove}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onKeyDown={event => handleArrowKeys(event)}\n >\n <button type=\"button\" className={styles.stage__open} onClick={openViewer}>\n {renderImage(imageProps('main', styles.image))}\n <span className={styles.srOnly}>{text.fullscreen}</span>\n <ArrowsFullscreen aria-hidden className={styles.stage__hint} />\n </button>\n {arrows}\n </div>\n\n {hasMany && (\n <ul ref={thumbsRef} className={styles.thumbs} aria-label={text.thumbnails}>\n {images.map((item, position) => (\n <li key={`${item.src}-${position}`}>\n <button\n type=\"button\"\n className={styles.thumb}\n aria-current={position === current || undefined}\n aria-label={resolveFormatter(\n 'Gallery.labels.thumbnail',\n labelProps?.thumbnail ?? config?.gallery?.thumbnail,\n position + 1,\n total,\n )}\n tabIndex={position === current ? 0 : -1}\n onClick={() => select(position)}\n onKeyDown={event => handleArrowKeys(event, true)}\n >\n {renderImage({\n src: item.thumbnailSrc ?? item.src,\n alt: '',\n className: styles.thumb__image,\n variant: 'thumbnail',\n index: position,\n width: item.width,\n height: item.height,\n })}\n </button>\n </li>\n ))}\n </ul>\n )}\n\n <dialog\n ref={dialogRef}\n className={styles.viewer}\n aria-label={label}\n onKeyDown={event => handleArrowKeys(event)}\n >\n {isFullscreen && (\n <>\n <div className={styles.viewer__bar}>\n <span className={styles.viewer__count} aria-live=\"polite\">\n {current + 1} / {total}\n </span>\n {hasZoom && (\n <IconButton\n icon={isZoomed ? <ZoomOut aria-hidden /> : <ZoomIn aria-hidden />}\n label={\n isZoomed\n ? resolveLabel(\n 'Gallery.labels.zoomOut',\n labelProps?.zoomOut,\n config?.gallery?.zoomOut,\n )\n : resolveLabel(\n 'Gallery.labels.zoomIn',\n labelProps?.zoomIn,\n config?.gallery?.zoomIn,\n )\n }\n variant=\"secondary\"\n onClick={() => setIsZoomed(zoomed => !zoomed)}\n />\n )}\n <IconButton\n icon={<XLg aria-hidden />}\n label={resolveLabel('Gallery.labels.close', labelProps?.close, config?.close)}\n variant=\"secondary\"\n onClick={close}\n />\n </div>\n <div\n className={cx(styles.viewer__stage, isZoomed && styles['viewer__stage--zoomed'])}\n onClick={toggleZoomAt}\n onPointerDown={handlePointerDown}\n onPointerUp={handlePointerUp}\n onPointerMove={handleViewerMove}\n >\n {renderImage(imageProps('fullscreen', styles.viewer__image))}\n </div>\n {arrows}\n </>\n )}\n </dialog>\n </section>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Gallery, 'Gallery')) as typeof Gallery;\n"],"names":["SWIPE_DISTANCE","defaultRenderImage","src","alt","className","width","height","variant","jsx","setZoomOrigin","element","clientX","clientY","rect","x","y","Gallery","images","label","renderImage","controlledIndex","onIndexChange","hasZoom","labelProps","testId","config","useUi","innerIndex","setInnerIndex","useState","isFullscreen","setIsFullscreen","isZoomed","setIsZoomed","dialogRef","useRef","thumbsRef","swipeRef","didSwipeRef","total","current","text","resolveLabel","_a","_b","_c","_d","select","useCallback","next","wrapped","close","useEffect","dialog","restoreFocus","captureFocus","token","pop","pushModal","handleCancel","event","isTopModal","useScrollLock","image","hasMany","handleArrowKeys","moveFocus","target","handlePointerDown","handlePointerUp","start","dx","dy","handleStageMove","openViewer","toggleZoomAt","zoomed","handleViewerMove","imageProps","arrows","jsxs","Fragment","IconButton","ChevronLeft","styles","cx","ChevronRight","ArrowsFullscreen","item","position","resolveFormatter","ZoomOut","ZoomIn","_e","_f","XLg","index","memo","named"],"mappings":"0iBAyFMA,GAAiB,GAEjBC,GAAqB,CAAC,CAC1B,IAAAC,EACA,IAAAC,EACA,UAAAC,EACA,MAAAC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
import { ReactNode } from 'react';
|
|
2
|
+
import { Formatter } from '../../types/theme.type.cjs';
|
|
3
|
+
export type GalleryImage = {
|
|
4
|
+
src: string;
|
|
5
|
+
/** What the image shows ("Fren balatası, ön yüz"). */
|
|
6
|
+
alt: string;
|
|
7
|
+
/** A smaller file for the thumbnail; `src` when omitted. */
|
|
8
|
+
thumbnailSrc?: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
};
|
|
12
|
+
/** Where an image is drawn: the adapter picks sizes and priority from it. */
|
|
13
|
+
export type GalleryImageVariant = 'main' | 'thumbnail' | 'fullscreen';
|
|
14
|
+
/** What `renderImage` receives. `className` MUST reach the element: zoom is drawn through it. */
|
|
15
|
+
export type GalleryRenderImageProps = {
|
|
16
|
+
src: string;
|
|
17
|
+
alt: string;
|
|
18
|
+
className: string;
|
|
19
|
+
variant: GalleryImageVariant;
|
|
20
|
+
/** The image's position in `images`. */
|
|
21
|
+
index: number;
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
};
|
|
25
|
+
export type GalleryLabels = {
|
|
26
|
+
thumbnails: string;
|
|
27
|
+
thumbnail: Formatter<[index: number, total: number]>;
|
|
28
|
+
previous: string;
|
|
29
|
+
next: string;
|
|
30
|
+
fullscreen: string;
|
|
31
|
+
zoomIn: string;
|
|
32
|
+
zoomOut: string;
|
|
33
|
+
close: string;
|
|
34
|
+
};
|
|
35
|
+
type Props = {
|
|
36
|
+
images: GalleryImage[];
|
|
37
|
+
/** The gallery's accessible name ("Ürün görselleri"); also the full-screen view's name. */
|
|
38
|
+
label: string;
|
|
39
|
+
/**
|
|
40
|
+
* Draws one image — the platform's own component (`next/image`, a cached Electron loader). A
|
|
41
|
+
* plain `<img>` when omitted.
|
|
42
|
+
*/
|
|
43
|
+
renderImage?: (props: GalleryRenderImageProps) => ReactNode;
|
|
44
|
+
/** Controlled index of the shown image; uncontrolled when omitted. */
|
|
45
|
+
index?: number;
|
|
46
|
+
onIndexChange?: (index: number) => void;
|
|
47
|
+
/** Magnifies the main image under a mouse pointer and lets the full-screen view zoom (default). */
|
|
48
|
+
hasZoom?: boolean;
|
|
49
|
+
labels?: Partial<GalleryLabels>;
|
|
50
|
+
className?: string;
|
|
51
|
+
testId?: string;
|
|
52
|
+
};
|
|
53
|
+
/** Product gallery: main image, thumbnails, hover zoom and a full-screen view (3.1). */
|
|
54
|
+
declare const Gallery: ({ images, label, renderImage, index: controlledIndex, onIndexChange, hasZoom, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element | null;
|
|
55
|
+
declare const _default: typeof Gallery;
|
|
56
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Formatter } from '../../types/theme.type.js';
|
|
3
|
+
export type GalleryImage = {
|
|
4
|
+
src: string;
|
|
5
|
+
/** What the image shows ("Fren balatası, ön yüz"). */
|
|
6
|
+
alt: string;
|
|
7
|
+
/** A smaller file for the thumbnail; `src` when omitted. */
|
|
8
|
+
thumbnailSrc?: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
};
|
|
12
|
+
/** Where an image is drawn: the adapter picks sizes and priority from it. */
|
|
13
|
+
export type GalleryImageVariant = 'main' | 'thumbnail' | 'fullscreen';
|
|
14
|
+
/** What `renderImage` receives. `className` MUST reach the element: zoom is drawn through it. */
|
|
15
|
+
export type GalleryRenderImageProps = {
|
|
16
|
+
src: string;
|
|
17
|
+
alt: string;
|
|
18
|
+
className: string;
|
|
19
|
+
variant: GalleryImageVariant;
|
|
20
|
+
/** The image's position in `images`. */
|
|
21
|
+
index: number;
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
};
|
|
25
|
+
export type GalleryLabels = {
|
|
26
|
+
thumbnails: string;
|
|
27
|
+
thumbnail: Formatter<[index: number, total: number]>;
|
|
28
|
+
previous: string;
|
|
29
|
+
next: string;
|
|
30
|
+
fullscreen: string;
|
|
31
|
+
zoomIn: string;
|
|
32
|
+
zoomOut: string;
|
|
33
|
+
close: string;
|
|
34
|
+
};
|
|
35
|
+
type Props = {
|
|
36
|
+
images: GalleryImage[];
|
|
37
|
+
/** The gallery's accessible name ("Ürün görselleri"); also the full-screen view's name. */
|
|
38
|
+
label: string;
|
|
39
|
+
/**
|
|
40
|
+
* Draws one image — the platform's own component (`next/image`, a cached Electron loader). A
|
|
41
|
+
* plain `<img>` when omitted.
|
|
42
|
+
*/
|
|
43
|
+
renderImage?: (props: GalleryRenderImageProps) => ReactNode;
|
|
44
|
+
/** Controlled index of the shown image; uncontrolled when omitted. */
|
|
45
|
+
index?: number;
|
|
46
|
+
onIndexChange?: (index: number) => void;
|
|
47
|
+
/** Magnifies the main image under a mouse pointer and lets the full-screen view zoom (default). */
|
|
48
|
+
hasZoom?: boolean;
|
|
49
|
+
labels?: Partial<GalleryLabels>;
|
|
50
|
+
className?: string;
|
|
51
|
+
testId?: string;
|
|
52
|
+
};
|
|
53
|
+
/** Product gallery: main image, thumbnails, hover zoom and a full-screen view (3.1). */
|
|
54
|
+
declare const Gallery: ({ images, label, renderImage, index: controlledIndex, onIndexChange, hasZoom, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element | null;
|
|
55
|
+
declare const _default: typeof Gallery;
|
|
56
|
+
export default _default;
|