@handijitcom/ui 3.3.1 → 3.4.1
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 +247 -0
- package/build/chat.css +1 -1
- package/build/components/AppShell/Nav.cjs +1 -1
- package/build/components/AppShell/Nav.cjs.map +1 -1
- package/build/components/AppShell/Nav.d.cts +8 -1
- package/build/components/AppShell/Nav.d.ts +8 -1
- package/build/components/AppShell/Nav.js +127 -112
- package/build/components/AppShell/Nav.js.map +1 -1
- package/build/components/AppShell/style.css +1 -1
- package/build/components/AppliedFilters/index.cjs +2 -0
- package/build/components/AppliedFilters/index.cjs.map +1 -0
- package/build/components/AppliedFilters/index.d.cts +33 -0
- package/build/components/AppliedFilters/index.d.ts +33 -0
- package/build/components/AppliedFilters/index.js +85 -0
- package/build/components/AppliedFilters/index.js.map +1 -0
- package/build/components/AppliedFilters/style.css +1 -0
- package/build/components/BrandLockup/index.cjs +2 -0
- package/build/components/BrandLockup/index.cjs.map +1 -0
- package/build/components/BrandLockup/index.d.cts +29 -0
- package/build/components/BrandLockup/index.d.ts +29 -0
- package/build/components/BrandLockup/index.js +41 -0
- package/build/components/BrandLockup/index.js.map +1 -0
- package/build/components/BrandLockup/style.css +1 -0
- package/build/components/Carousel/index.cjs +1 -1
- package/build/components/Carousel/index.cjs.map +1 -1
- package/build/components/Carousel/index.d.cts +9 -0
- package/build/components/Carousel/index.d.ts +9 -0
- package/build/components/Carousel/index.js +65 -60
- package/build/components/Carousel/index.js.map +1 -1
- package/build/components/Carousel/style.css +1 -1
- package/build/components/CodeText/CodeTextCopy.cjs +2 -0
- package/build/components/CodeText/CodeTextCopy.cjs.map +1 -0
- package/build/components/CodeText/CodeTextCopy.d.cts +11 -0
- package/build/components/CodeText/CodeTextCopy.d.ts +11 -0
- package/build/components/CodeText/CodeTextCopy.js +41 -0
- package/build/components/CodeText/CodeTextCopy.js.map +1 -0
- package/build/components/CodeText/index.cjs +2 -0
- package/build/components/CodeText/index.cjs.map +1 -0
- package/build/components/CodeText/index.d.cts +26 -0
- package/build/components/CodeText/index.d.ts +26 -0
- package/build/components/CodeText/index.js +39 -0
- package/build/components/CodeText/index.js.map +1 -0
- package/build/components/CodeText/style.css +1 -0
- package/build/components/Combobox/index.cjs +1 -1
- package/build/components/Combobox/index.cjs.map +1 -1
- package/build/components/Combobox/index.js +147 -146
- package/build/components/Combobox/index.js.map +1 -1
- package/build/components/Combobox/style.css +1 -1
- package/build/components/CompareTray/index.cjs +2 -0
- package/build/components/CompareTray/index.cjs.map +1 -0
- package/build/components/CompareTray/index.d.cts +44 -0
- package/build/components/CompareTray/index.d.ts +44 -0
- package/build/components/CompareTray/index.js +94 -0
- package/build/components/CompareTray/index.js.map +1 -0
- package/build/components/CompareTray/style.css +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 +12 -0
- package/build/components/DataTable/index.d.ts +12 -0
- package/build/components/DataTable/index.js +120 -122
- package/build/components/DataTable/index.js.map +1 -1
- package/build/components/DataTable/style.css +1 -1
- package/build/components/Eyebrow/style.css +1 -1
- package/build/components/FacetSection/index.cjs +2 -0
- package/build/components/FacetSection/index.cjs.map +1 -0
- package/build/components/FacetSection/index.d.cts +75 -0
- package/build/components/FacetSection/index.d.ts +75 -0
- package/build/components/FacetSection/index.js +199 -0
- package/build/components/FacetSection/index.js.map +1 -0
- package/build/components/FacetSection/style.css +1 -0
- package/build/components/FacetSidebar/index.cjs +2 -0
- package/build/components/FacetSidebar/index.cjs.map +1 -0
- package/build/components/FacetSidebar/index.d.cts +35 -0
- package/build/components/FacetSidebar/index.d.ts +35 -0
- package/build/components/FacetSidebar/index.js +110 -0
- package/build/components/FacetSidebar/index.js.map +1 -0
- package/build/components/FacetSidebar/style.css +1 -0
- package/build/components/FilterToolbar/index.cjs +2 -0
- package/build/components/FilterToolbar/index.cjs.map +1 -0
- package/build/components/FilterToolbar/index.d.cts +55 -0
- package/build/components/FilterToolbar/index.d.ts +55 -0
- package/build/components/FilterToolbar/index.js +149 -0
- package/build/components/FilterToolbar/index.js.map +1 -0
- package/build/components/FilterToolbar/style.css +1 -0
- package/build/components/Gallery/index.cjs +1 -1
- package/build/components/Gallery/index.cjs.map +1 -1
- package/build/components/Gallery/index.d.cts +8 -1
- package/build/components/Gallery/index.d.ts +8 -1
- package/build/components/Gallery/index.js +146 -138
- package/build/components/Gallery/index.js.map +1 -1
- package/build/components/Gallery/style.css +1 -1
- package/build/components/MegaMenu/index.cjs +2 -0
- package/build/components/MegaMenu/index.cjs.map +1 -0
- package/build/components/MegaMenu/index.d.cts +67 -0
- package/build/components/MegaMenu/index.d.ts +67 -0
- package/build/components/MegaMenu/index.js +220 -0
- package/build/components/MegaMenu/index.js.map +1 -0
- package/build/components/MegaMenu/style.css +1 -0
- package/build/components/MoneyInput/index.cjs +1 -1
- package/build/components/MoneyInput/index.cjs.map +1 -1
- package/build/components/MoneyInput/index.js +10 -10
- package/build/components/MoneyInput/index.js.map +1 -1
- package/build/components/NotificationCenter/style.css +1 -1
- package/build/components/PageHeader/style.css +1 -1
- package/build/components/Popover/style.css +1 -1
- package/build/components/ProductCarousel/index.cjs +2 -0
- package/build/components/ProductCarousel/index.cjs.map +1 -0
- package/build/components/ProductCarousel/index.d.cts +35 -0
- package/build/components/ProductCarousel/index.d.ts +35 -0
- package/build/components/ProductCarousel/index.js +86 -0
- package/build/components/ProductCarousel/index.js.map +1 -0
- package/build/components/ProductCarousel/style.css +1 -0
- package/build/components/Radio/index.cjs +1 -1
- package/build/components/Radio/index.cjs.map +1 -1
- package/build/components/Radio/index.js +10 -10
- package/build/components/Radio/index.js.map +1 -1
- package/build/components/SectionHeader/index.cjs +1 -1
- package/build/components/SectionHeader/index.cjs.map +1 -1
- package/build/components/SectionHeader/index.js +4 -4
- package/build/components/SectionHeader/index.js.map +1 -1
- package/build/components/SectionHeader/style.css +1 -1
- package/build/components/SegmentedControl/index.cjs +1 -1
- package/build/components/SegmentedControl/index.cjs.map +1 -1
- package/build/components/SegmentedControl/index.js +23 -23
- package/build/components/SegmentedControl/index.js.map +1 -1
- package/build/components/Select/index.cjs +1 -1
- package/build/components/Select/index.cjs.map +1 -1
- package/build/components/Select/index.js +37 -37
- package/build/components/Select/index.js.map +1 -1
- package/build/components/Select/style.css +1 -1
- package/build/components/Skeleton/index.cjs +1 -1
- package/build/components/Skeleton/index.cjs.map +1 -1
- package/build/components/Skeleton/index.js +16 -16
- package/build/components/Skeleton/index.js.map +1 -1
- package/build/components/SortableList/index.cjs +2 -0
- package/build/components/SortableList/index.cjs.map +1 -0
- package/build/components/SortableList/index.d.cts +37 -0
- package/build/components/SortableList/index.d.ts +37 -0
- package/build/components/SortableList/index.js +159 -0
- package/build/components/SortableList/index.js.map +1 -0
- package/build/components/SortableList/style.css +1 -0
- package/build/components/Steps/index.cjs +1 -1
- package/build/components/Steps/index.cjs.map +1 -1
- package/build/components/Steps/index.d.cts +6 -0
- package/build/components/Steps/index.d.ts +6 -0
- package/build/components/Steps/index.js +37 -35
- package/build/components/Steps/index.js.map +1 -1
- package/build/components/Steps/style.css +1 -1
- package/build/components/StickyActionBar/index.cjs +2 -0
- package/build/components/StickyActionBar/index.cjs.map +1 -0
- package/build/components/StickyActionBar/index.d.cts +29 -0
- package/build/components/StickyActionBar/index.d.ts +29 -0
- package/build/components/StickyActionBar/index.js +57 -0
- package/build/components/StickyActionBar/index.js.map +1 -0
- package/build/components/StickyActionBar/style.css +1 -0
- package/build/components/Table/index.cjs +1 -1
- package/build/components/Table/index.cjs.map +1 -1
- package/build/components/Table/index.d.cts +6 -0
- package/build/components/Table/index.d.ts +6 -0
- package/build/components/Table/index.js +34 -32
- package/build/components/Table/index.js.map +1 -1
- package/build/components/Table/style.css +1 -1
- package/build/helpers/carousel.helper.cjs +2 -0
- package/build/helpers/carousel.helper.cjs.map +1 -0
- package/build/helpers/carousel.helper.d.cts +11 -0
- package/build/helpers/carousel.helper.d.ts +11 -0
- package/build/helpers/carousel.helper.js +10 -0
- package/build/helpers/carousel.helper.js.map +1 -0
- package/build/helpers/facet.helper.cjs +2 -0
- package/build/helpers/facet.helper.cjs.map +1 -0
- package/build/helpers/facet.helper.d.cts +6 -0
- package/build/helpers/facet.helper.d.ts +6 -0
- package/build/helpers/facet.helper.js +5 -0
- package/build/helpers/facet.helper.js.map +1 -0
- package/build/helpers/focus.helper.cjs +1 -1
- package/build/helpers/focus.helper.cjs.map +1 -1
- package/build/helpers/focus.helper.d.cts +2 -0
- package/build/helpers/focus.helper.d.ts +2 -0
- package/build/helpers/focus.helper.js +1 -0
- package/build/helpers/focus.helper.js.map +1 -1
- package/build/helpers/sortable.helper.cjs +2 -0
- package/build/helpers/sortable.helper.cjs.map +1 -0
- package/build/helpers/sortable.helper.d.cts +19 -0
- package/build/helpers/sortable.helper.d.ts +19 -0
- package/build/helpers/sortable.helper.js +20 -0
- package/build/helpers/sortable.helper.js.map +1 -0
- package/build/helpers/sticky-bar.helper.cjs +2 -0
- package/build/helpers/sticky-bar.helper.cjs.map +1 -0
- package/build/helpers/sticky-bar.helper.d.cts +6 -0
- package/build/helpers/sticky-bar.helper.d.ts +6 -0
- package/build/helpers/sticky-bar.helper.js +8 -0
- package/build/helpers/sticky-bar.helper.js.map +1 -0
- package/build/hooks/useRemovalFocus.cjs +2 -0
- package/build/hooks/useRemovalFocus.cjs.map +1 -0
- package/build/hooks/useRemovalFocus.d.cts +13 -0
- package/build/hooks/useRemovalFocus.d.ts +13 -0
- package/build/hooks/useRemovalFocus.js +21 -0
- package/build/hooks/useRemovalFocus.js.map +1 -0
- package/build/index.cjs +1 -1
- package/build/index.d.cts +13 -2
- package/build/index.d.ts +13 -2
- package/build/index.js +115 -93
- package/build/index.js.map +1 -1
- package/build/scss/_mixins.scss +3 -1
- package/build/styles.css +38 -14
- package/build/types/sortable.type.d.cts +12 -0
- package/build/types/sortable.type.d.ts +12 -0
- package/build/types/theme.type.d.cts +95 -0
- package/build/types/theme.type.d.ts +95 -0
- package/build/types/types/theme.type.d.cts +95 -0
- package/build/types/types/theme.type.d.ts +95 -0
- package/package.json +111 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/SegmentedControl/index.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, memo, type ReactNode, useRef } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\n\nimport styles from './index.module.scss';\n\nexport type SegmentOption<T extends string = string> = {\n value: T;\n label: string;\n /** Yalnızca ikon gösterilecekse `label` erişilebilir ad olarak kalır. */\n icon?: ReactNode;\n isDisabled?: boolean;\n};\n\ntype Props<T extends string> = {\n options: SegmentOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Grubun erişilebilir adı (\"Görünüm\"). */\n label: string;\n /** Etiketler gizlenir, yalnızca ikon çizilir. `label` yine okunur. */\n isIconOnly?: boolean;\n size?: 'sm' | 'md';\n /** Every segment disabled at once (2.2); `SegmentOption.isDisabled` still disables one. */\n isDisabled?: boolean;\n /**\n * Read-only (2.2): the choice stays focusable and announced (`aria-readonly` on the group), but\n * neither a press nor the arrow keys change it.\n */\n isReadOnly?: boolean;\n /** The id of the `radiogroup` (2.2) — the `id` of `Field`'s `FieldChildProps`. */\n id?: string;\n /** Zorunluluk — `Field`in `FieldChildProps` sözleşmesi (2.2); `aria-required` on the group. */\n required?: boolean;\n /** On the `radiogroup` (2.2), with the error and hint ids of `Field`. */\n 'aria-describedby'?: string;\n /** On the `radiogroup` (2.2), which takes `aria-invalid`; the frame turns danger. */\n 'aria-invalid'?: boolean;\n className?: string;\n testId?: string;\n};\n\n/** Bölmeli denetim — görünüm değiştirme. */\nconst SegmentedControl = <T extends string>({\n options,\n value,\n onChange,\n label,\n isIconOnly,\n size = 'md',\n isDisabled,\n isReadOnly,\n id,\n required,\n 'aria-describedby': describedBy,\n 'aria-invalid': isInvalid,\n className,\n testId,\n}: Props<T>) => {\n const listRef = useRef<HTMLDivElement>(null);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const offset =\n event.key === 'ArrowRight' || event.key === 'ArrowDown'\n ? 1\n : event.key === 'ArrowLeft' || event.key === 'ArrowUp'\n ? -1\n : 0;\n\n if (offset === 0) return;\n event.preventDefault();\n if (isReadOnly || isDisabled) return;\n\n const enabled = options.filter(option => !option.isDisabled);\n if (enabled.length === 0) return;\n\n const current = enabled.findIndex(option => option.value === value);\n const next = enabled[(current + offset + enabled.length) % enabled.length];\n\n onChange(next.value);\n listRef.current\n ?.querySelector<HTMLButtonElement>(`[data-value=\"${next.value}\"]`)\n ?.focus({ preventScroll: true });\n };\n\n return (\n <div\n ref={listRef}\n id={id}\n role=\"radiogroup\"\n aria-label={label}\n aria-describedby={describedBy}\n aria-invalid={isInvalid || undefined}\n aria-required={required || undefined}\n aria-readonly={isReadOnly || undefined}\n className={cx(\n styles.segmented,\n styles[`segmented--${size}`],\n isReadOnly && styles['segmented--readOnly'],\n className,\n )}\n data-testid={testId}\n onKeyDown={handleKeyDown}\n >\n {options.map(option => {\n const isSelected = option.value === value;\n\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={isSelected}\n aria-label={isIconOnly ? option.label : undefined}\n data-value={option.value}\n disabled={isDisabled || option.isDisabled}\n /* Donen `tabindex`: grup Tab sirasinda TEK durak. */\n tabIndex={isSelected ? 0 : -1}\n className={cx(\n styles.segmented__item,\n isSelected && styles['segmented__item--selected'],\n )}\n /*\n * Secili ogeye ikinci kez basmak HICBIR SEY yapmaz: gorunum anahtarinda \"hicbiri\" diye\n * bir hal yok. `ChipGroup`ta ayni hareket secimi kaldiriyor ve iki…\n */\n onClick={() => !isSelected && !isReadOnly && onChange(option.value)}\n >\n {option.icon && (\n <span className={styles.segmented__icon} aria-hidden>\n {option.icon}\n </span>\n )}\n {!isIconOnly && <span className={styles.segmented__label}>{option.label}</span>}\n </button>\n );\n })}\n </div>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(SegmentedControl, 'SegmentedControl'),\n) as typeof SegmentedControl;\n"],"names":["SegmentedControl","options","value","onChange","label","isIconOnly","size","isDisabled","isReadOnly","id","required","describedBy","isInvalid","className","testId","listRef","useRef","handleKeyDown","event","offset","enabled","option","current","next","_b","_a","jsx","cx","styles","isSelected","jsxs","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/SegmentedControl/index.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, memo, type ReactNode, useRef } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\n\nimport styles from './index.module.scss';\n\nexport type SegmentOption<T extends string = string> = {\n value: T;\n label: string;\n /** Yalnızca ikon gösterilecekse `label` erişilebilir ad olarak kalır. */\n icon?: ReactNode;\n isDisabled?: boolean;\n};\n\ntype Props<T extends string> = {\n options: SegmentOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Grubun erişilebilir adı (\"Görünüm\"). */\n label: string;\n /** Etiketler gizlenir, yalnızca ikon çizilir. `label` yine okunur. */\n isIconOnly?: boolean;\n size?: 'sm' | 'md';\n /** Every segment disabled at once (2.2); `SegmentOption.isDisabled` still disables one. */\n isDisabled?: boolean;\n /**\n * Read-only (2.2): the choice stays focusable and announced (`aria-readonly` on the group), but\n * neither a press nor the arrow keys change it.\n */\n isReadOnly?: boolean;\n /** The id of the `radiogroup` (2.2) — the `id` of `Field`'s `FieldChildProps`. */\n id?: string;\n /** Zorunluluk — `Field`in `FieldChildProps` sözleşmesi (2.2); `aria-required` on the group. */\n required?: boolean;\n /** On the `radiogroup` (2.2), with the error and hint ids of `Field`. */\n 'aria-describedby'?: string;\n /** On the `radiogroup` (2.2), which takes `aria-invalid`; the frame turns danger. */\n 'aria-invalid'?: boolean;\n className?: string;\n testId?: string;\n};\n\n/** Bölmeli denetim — görünüm değiştirme. */\nconst SegmentedControl = <T extends string>({\n options,\n value,\n onChange,\n label,\n isIconOnly,\n size = 'md',\n isDisabled,\n isReadOnly,\n id,\n required,\n 'aria-describedby': describedBy,\n 'aria-invalid': isInvalid,\n className,\n testId,\n}: Props<T>) => {\n const listRef = useRef<HTMLDivElement>(null);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const offset =\n event.key === 'ArrowRight' || event.key === 'ArrowDown'\n ? 1\n : event.key === 'ArrowLeft' || event.key === 'ArrowUp'\n ? -1\n : 0;\n\n if (offset === 0) return;\n event.preventDefault();\n if (isReadOnly || isDisabled) return;\n\n const enabled = options.filter(option => !option.isDisabled);\n if (enabled.length === 0) return;\n\n const current = enabled.findIndex(option => option.value === value);\n const next = enabled[(current + offset + enabled.length) % enabled.length];\n\n onChange(next.value);\n listRef.current\n ?.querySelector<HTMLButtonElement>(`[data-value=\"${next.value}\"]`)\n ?.focus({ preventScroll: true });\n };\n\n return (\n <div\n ref={listRef}\n id={id}\n role=\"radiogroup\"\n aria-label={label}\n aria-describedby={describedBy}\n aria-invalid={isInvalid || undefined}\n aria-required={required || undefined}\n aria-readonly={isReadOnly || undefined}\n className={cx(\n styles.segmented,\n styles[`segmented--${size}`],\n isReadOnly && styles['segmented--readOnly'],\n className,\n )}\n data-testid={testId}\n onKeyDown={handleKeyDown}\n >\n {options.map(option => {\n const isSelected = option.value === value;\n\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={isSelected}\n aria-label={isIconOnly ? option.label : undefined}\n data-value={option.value}\n disabled={isDisabled || option.isDisabled}\n /* Donen `tabindex`: grup Tab sirasinda TEK durak. */\n tabIndex={isSelected ? 0 : -1}\n className={cx(\n styles.segmented__item,\n isSelected && styles['segmented__item--selected'],\n )}\n /*\n * Secili ogeye ikinci kez basmak HICBIR SEY yapmaz: gorunum anahtarinda \"hicbiri\" diye\n * bir hal yok. `ChipGroup`ta ayni hareket secimi kaldiriyor ve iki…\n */\n onClick={() => !isSelected && !isReadOnly && onChange(option.value)}\n >\n {option.icon && (\n <span className={styles.segmented__icon} aria-hidden>\n {option.icon}\n </span>\n )}\n {!isIconOnly && <span className={styles.segmented__label}>{option.label}</span>}\n </button>\n );\n })}\n </div>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(SegmentedControl, 'SegmentedControl'),\n) as typeof SegmentedControl;\n"],"names":["SegmentedControl","options","value","onChange","label","isIconOnly","size","isDisabled","isReadOnly","id","required","describedBy","isInvalid","className","testId","listRef","useRef","handleKeyDown","event","offset","enabled","option","current","next","_b","_a","jsx","cx","styles","isSelected","jsxs","memo","named"],"mappings":"uTA6CMA,EAAmB,CAAmB,CAC1C,QAAAC,EACA,MAAAC,EACA,SAAAC,EACA,MAAAC,EACA,WAAAC,EACA,KAAAC,EAAO,KACP,WAAAC,EACA,WAAAC,EACA,GAAAC,EACA,SAAAC,EACA,mBAAoBC,EACpB,eAAgBC,EAChB,UAAAC,EACA,OAAAC,CACF,IAAgB,CACd,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EAErCC,EAAiBC,GAAyC,SAC9D,MAAMC,EACJD,EAAM,MAAQ,cAAgBA,EAAM,MAAQ,YACxC,EACAA,EAAM,MAAQ,aAAeA,EAAM,MAAQ,UACzC,GACA,EAIR,GAFIC,IAAW,IACfD,EAAM,eAAA,EACFV,GAAcD,GAAY,OAE9B,MAAMa,EAAUnB,EAAQ,OAAOoB,GAAU,CAACA,EAAO,UAAU,EAC3D,GAAID,EAAQ,SAAW,EAAG,OAE1B,MAAME,EAAUF,EAAQ,UAAUC,GAAUA,EAAO,QAAUnB,CAAK,EAC5DqB,EAAOH,GAASE,EAAUH,EAASC,EAAQ,QAAUA,EAAQ,MAAM,EAEzEjB,EAASoB,EAAK,KAAK,GACnBC,GAAAC,EAAAV,EAAQ,UAAR,YAAAU,EACI,cAAiC,gBAAgBF,EAAK,KAAK,QAD/D,MAAAC,EAEI,MAAM,CAAE,cAAe,EAAA,EAC7B,EAEA,OACEE,EAAAA,IAAC,MAAA,CACC,IAAKX,EACL,GAAAN,EACA,KAAK,aACL,aAAYL,EACZ,mBAAkBO,EAClB,eAAcC,GAAa,OAC3B,gBAAeF,GAAY,OAC3B,gBAAeF,GAAc,OAC7B,UAAWmB,EAAAA,GACTC,EAAAA,QAAO,UACPA,EAAAA,QAAO,cAActB,CAAI,EAAE,EAC3BE,GAAcoB,EAAAA,QAAO,qBAAqB,EAC1Cf,CAAA,EAEF,cAAaC,EACb,UAAWG,EAEV,SAAAhB,EAAQ,IAAIoB,GAAU,CACrB,MAAMQ,EAAaR,EAAO,QAAUnB,EAEpC,OACE4B,EAAAA,KAAC,SAAA,CAEC,KAAK,SACL,KAAK,QACL,eAAcD,EACd,aAAYxB,EAAagB,EAAO,MAAQ,OACxC,aAAYA,EAAO,MACnB,SAAUd,GAAcc,EAAO,WAE/B,SAAUQ,EAAa,EAAI,GAC3B,UAAWF,EAAAA,GACTC,EAAAA,QAAO,gBACPC,GAAcD,EAAAA,QAAO,2BAA2B,CAAA,EAMlD,QAAS,IAAM,CAACC,GAAc,CAACrB,GAAcL,EAASkB,EAAO,KAAK,EAEjE,SAAA,CAAAA,EAAO,YACL,OAAA,CAAK,UAAWO,EAAAA,QAAO,gBAAiB,cAAW,GACjD,SAAAP,EAAO,IAAA,CACV,EAED,CAAChB,GAAcqB,MAAC,OAAA,CAAK,UAAWE,EAAAA,QAAO,iBAAmB,WAAO,KAAA,CAAM,CAAA,CAAA,EAxBnEP,EAAO,KAAA,CA2BlB,CAAC,CAAA,CAAA,CAGP,EAEArB,EAA6B+B,EAAAA,KACbC,EAAAA,MAAMhC,EAAkB,kBAAkB,CAC1D"}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as n, jsxs as N } from "react/jsx-runtime";
|
|
3
|
-
import { memo as
|
|
3
|
+
import { memo as C, useRef as $ } from "react";
|
|
4
4
|
import { cx as v } from "../../helpers/class-name.helper.js";
|
|
5
|
-
import { named as
|
|
5
|
+
import { named as j } from "../../helpers/component.helper.js";
|
|
6
6
|
const a = {"segmented":"ui-segmented-qo2Bw","segmented--sm":"ui-segmented--sm-7tUry","segmented--md":"ui-segmented--md-PiSqt","segmented__item":"ui-segmented__item-mqRNZ","segmented__item--selected":"ui-segmented__item--selected-r7CLj","segmented--readOnly":"ui-segmented--readOnly-V0PUH","segmented__icon":"ui-segmented__icon-C9CT-","segmented__label":"ui-segmented__label-NVXBv"};
|
|
7
|
-
const
|
|
7
|
+
const q = ({
|
|
8
8
|
options: i,
|
|
9
9
|
value: s,
|
|
10
|
-
onChange:
|
|
10
|
+
onChange: o,
|
|
11
11
|
label: h,
|
|
12
|
-
isIconOnly:
|
|
12
|
+
isIconOnly: c,
|
|
13
13
|
size: y = "md",
|
|
14
14
|
isDisabled: m,
|
|
15
15
|
isReadOnly: l,
|
|
16
|
-
id:
|
|
17
|
-
required:
|
|
18
|
-
"aria-describedby":
|
|
16
|
+
id: _,
|
|
17
|
+
required: w,
|
|
18
|
+
"aria-describedby": x,
|
|
19
19
|
"aria-invalid": k,
|
|
20
|
-
className:
|
|
21
|
-
testId:
|
|
20
|
+
className: S,
|
|
21
|
+
testId: p
|
|
22
22
|
}) => {
|
|
23
|
-
const u =
|
|
23
|
+
const u = $(null), D = (e) => {
|
|
24
24
|
var b, g;
|
|
25
25
|
const r = e.key === "ArrowRight" || e.key === "ArrowDown" ? 1 : e.key === "ArrowLeft" || e.key === "ArrowUp" ? -1 : 0;
|
|
26
26
|
if (r === 0 || (e.preventDefault(), l || m)) return;
|
|
27
27
|
const t = i.filter((d) => !d.isDisabled);
|
|
28
28
|
if (t.length === 0) return;
|
|
29
29
|
const A = t.findIndex((d) => d.value === s), f = t[(A + r + t.length) % t.length];
|
|
30
|
-
|
|
30
|
+
o(f.value), (g = (b = u.current) == null ? void 0 : b.querySelector(`[data-value="${f.value}"]`)) == null || g.focus({ preventScroll: !0 });
|
|
31
31
|
};
|
|
32
32
|
return /* @__PURE__ */ n(
|
|
33
33
|
"div",
|
|
34
34
|
{
|
|
35
35
|
ref: u,
|
|
36
|
-
id:
|
|
36
|
+
id: _,
|
|
37
37
|
role: "radiogroup",
|
|
38
38
|
"aria-label": h,
|
|
39
|
-
"aria-describedby":
|
|
39
|
+
"aria-describedby": x,
|
|
40
40
|
"aria-invalid": k || void 0,
|
|
41
|
-
"aria-required":
|
|
41
|
+
"aria-required": w || void 0,
|
|
42
42
|
"aria-readonly": l || void 0,
|
|
43
43
|
className: v(
|
|
44
44
|
a.segmented,
|
|
45
45
|
a[`segmented--${y}`],
|
|
46
46
|
l && a["segmented--readOnly"],
|
|
47
|
-
|
|
47
|
+
S
|
|
48
48
|
),
|
|
49
|
-
"data-testid":
|
|
50
|
-
onKeyDown:
|
|
49
|
+
"data-testid": p,
|
|
50
|
+
onKeyDown: D,
|
|
51
51
|
children: i.map((e) => {
|
|
52
52
|
const r = e.value === s;
|
|
53
53
|
return /* @__PURE__ */ N(
|
|
@@ -56,7 +56,7 @@ const K = ({
|
|
|
56
56
|
type: "button",
|
|
57
57
|
role: "radio",
|
|
58
58
|
"aria-checked": r,
|
|
59
|
-
"aria-label":
|
|
59
|
+
"aria-label": c ? e.label : void 0,
|
|
60
60
|
"data-value": e.value,
|
|
61
61
|
disabled: m || e.isDisabled,
|
|
62
62
|
tabIndex: r ? 0 : -1,
|
|
@@ -64,10 +64,10 @@ const K = ({
|
|
|
64
64
|
a.segmented__item,
|
|
65
65
|
r && a["segmented__item--selected"]
|
|
66
66
|
),
|
|
67
|
-
onClick: () => !r && !l &&
|
|
67
|
+
onClick: () => !r && !l && o(e.value),
|
|
68
68
|
children: [
|
|
69
69
|
e.icon && /* @__PURE__ */ n("span", { className: a.segmented__icon, "aria-hidden": !0, children: e.icon }),
|
|
70
|
-
!
|
|
70
|
+
!c && /* @__PURE__ */ n("span", { className: a.segmented__label, children: e.label })
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
e.value
|
|
@@ -75,8 +75,8 @@ const K = ({
|
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
);
|
|
78
|
-
}, B = /* @__PURE__ */
|
|
79
|
-
/* @__PURE__ */
|
|
78
|
+
}, B = /* @__PURE__ */ C(
|
|
79
|
+
/* @__PURE__ */ j(q, "SegmentedControl")
|
|
80
80
|
);
|
|
81
81
|
export {
|
|
82
82
|
B as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/SegmentedControl/index.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, memo, type ReactNode, useRef } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\n\nimport styles from './index.module.scss';\n\nexport type SegmentOption<T extends string = string> = {\n value: T;\n label: string;\n /** Yalnızca ikon gösterilecekse `label` erişilebilir ad olarak kalır. */\n icon?: ReactNode;\n isDisabled?: boolean;\n};\n\ntype Props<T extends string> = {\n options: SegmentOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Grubun erişilebilir adı (\"Görünüm\"). */\n label: string;\n /** Etiketler gizlenir, yalnızca ikon çizilir. `label` yine okunur. */\n isIconOnly?: boolean;\n size?: 'sm' | 'md';\n /** Every segment disabled at once (2.2); `SegmentOption.isDisabled` still disables one. */\n isDisabled?: boolean;\n /**\n * Read-only (2.2): the choice stays focusable and announced (`aria-readonly` on the group), but\n * neither a press nor the arrow keys change it.\n */\n isReadOnly?: boolean;\n /** The id of the `radiogroup` (2.2) — the `id` of `Field`'s `FieldChildProps`. */\n id?: string;\n /** Zorunluluk — `Field`in `FieldChildProps` sözleşmesi (2.2); `aria-required` on the group. */\n required?: boolean;\n /** On the `radiogroup` (2.2), with the error and hint ids of `Field`. */\n 'aria-describedby'?: string;\n /** On the `radiogroup` (2.2), which takes `aria-invalid`; the frame turns danger. */\n 'aria-invalid'?: boolean;\n className?: string;\n testId?: string;\n};\n\n/** Bölmeli denetim — görünüm değiştirme. */\nconst SegmentedControl = <T extends string>({\n options,\n value,\n onChange,\n label,\n isIconOnly,\n size = 'md',\n isDisabled,\n isReadOnly,\n id,\n required,\n 'aria-describedby': describedBy,\n 'aria-invalid': isInvalid,\n className,\n testId,\n}: Props<T>) => {\n const listRef = useRef<HTMLDivElement>(null);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const offset =\n event.key === 'ArrowRight' || event.key === 'ArrowDown'\n ? 1\n : event.key === 'ArrowLeft' || event.key === 'ArrowUp'\n ? -1\n : 0;\n\n if (offset === 0) return;\n event.preventDefault();\n if (isReadOnly || isDisabled) return;\n\n const enabled = options.filter(option => !option.isDisabled);\n if (enabled.length === 0) return;\n\n const current = enabled.findIndex(option => option.value === value);\n const next = enabled[(current + offset + enabled.length) % enabled.length];\n\n onChange(next.value);\n listRef.current\n ?.querySelector<HTMLButtonElement>(`[data-value=\"${next.value}\"]`)\n ?.focus({ preventScroll: true });\n };\n\n return (\n <div\n ref={listRef}\n id={id}\n role=\"radiogroup\"\n aria-label={label}\n aria-describedby={describedBy}\n aria-invalid={isInvalid || undefined}\n aria-required={required || undefined}\n aria-readonly={isReadOnly || undefined}\n className={cx(\n styles.segmented,\n styles[`segmented--${size}`],\n isReadOnly && styles['segmented--readOnly'],\n className,\n )}\n data-testid={testId}\n onKeyDown={handleKeyDown}\n >\n {options.map(option => {\n const isSelected = option.value === value;\n\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={isSelected}\n aria-label={isIconOnly ? option.label : undefined}\n data-value={option.value}\n disabled={isDisabled || option.isDisabled}\n /* Donen `tabindex`: grup Tab sirasinda TEK durak. */\n tabIndex={isSelected ? 0 : -1}\n className={cx(\n styles.segmented__item,\n isSelected && styles['segmented__item--selected'],\n )}\n /*\n * Secili ogeye ikinci kez basmak HICBIR SEY yapmaz: gorunum anahtarinda \"hicbiri\" diye\n * bir hal yok. `ChipGroup`ta ayni hareket secimi kaldiriyor ve iki…\n */\n onClick={() => !isSelected && !isReadOnly && onChange(option.value)}\n >\n {option.icon && (\n <span className={styles.segmented__icon} aria-hidden>\n {option.icon}\n </span>\n )}\n {!isIconOnly && <span className={styles.segmented__label}>{option.label}</span>}\n </button>\n );\n })}\n </div>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(SegmentedControl, 'SegmentedControl'),\n) as typeof SegmentedControl;\n"],"names":["SegmentedControl","options","value","onChange","label","isIconOnly","size","isDisabled","isReadOnly","id","required","describedBy","isInvalid","className","testId","listRef","useRef","handleKeyDown","event","offset","enabled","option","current","next","_b","_a","jsx","cx","styles","isSelected","jsxs","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/SegmentedControl/index.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, memo, type ReactNode, useRef } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\n\nimport styles from './index.module.scss';\n\nexport type SegmentOption<T extends string = string> = {\n value: T;\n label: string;\n /** Yalnızca ikon gösterilecekse `label` erişilebilir ad olarak kalır. */\n icon?: ReactNode;\n isDisabled?: boolean;\n};\n\ntype Props<T extends string> = {\n options: SegmentOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Grubun erişilebilir adı (\"Görünüm\"). */\n label: string;\n /** Etiketler gizlenir, yalnızca ikon çizilir. `label` yine okunur. */\n isIconOnly?: boolean;\n size?: 'sm' | 'md';\n /** Every segment disabled at once (2.2); `SegmentOption.isDisabled` still disables one. */\n isDisabled?: boolean;\n /**\n * Read-only (2.2): the choice stays focusable and announced (`aria-readonly` on the group), but\n * neither a press nor the arrow keys change it.\n */\n isReadOnly?: boolean;\n /** The id of the `radiogroup` (2.2) — the `id` of `Field`'s `FieldChildProps`. */\n id?: string;\n /** Zorunluluk — `Field`in `FieldChildProps` sözleşmesi (2.2); `aria-required` on the group. */\n required?: boolean;\n /** On the `radiogroup` (2.2), with the error and hint ids of `Field`. */\n 'aria-describedby'?: string;\n /** On the `radiogroup` (2.2), which takes `aria-invalid`; the frame turns danger. */\n 'aria-invalid'?: boolean;\n className?: string;\n testId?: string;\n};\n\n/** Bölmeli denetim — görünüm değiştirme. */\nconst SegmentedControl = <T extends string>({\n options,\n value,\n onChange,\n label,\n isIconOnly,\n size = 'md',\n isDisabled,\n isReadOnly,\n id,\n required,\n 'aria-describedby': describedBy,\n 'aria-invalid': isInvalid,\n className,\n testId,\n}: Props<T>) => {\n const listRef = useRef<HTMLDivElement>(null);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const offset =\n event.key === 'ArrowRight' || event.key === 'ArrowDown'\n ? 1\n : event.key === 'ArrowLeft' || event.key === 'ArrowUp'\n ? -1\n : 0;\n\n if (offset === 0) return;\n event.preventDefault();\n if (isReadOnly || isDisabled) return;\n\n const enabled = options.filter(option => !option.isDisabled);\n if (enabled.length === 0) return;\n\n const current = enabled.findIndex(option => option.value === value);\n const next = enabled[(current + offset + enabled.length) % enabled.length];\n\n onChange(next.value);\n listRef.current\n ?.querySelector<HTMLButtonElement>(`[data-value=\"${next.value}\"]`)\n ?.focus({ preventScroll: true });\n };\n\n return (\n <div\n ref={listRef}\n id={id}\n role=\"radiogroup\"\n aria-label={label}\n aria-describedby={describedBy}\n aria-invalid={isInvalid || undefined}\n aria-required={required || undefined}\n aria-readonly={isReadOnly || undefined}\n className={cx(\n styles.segmented,\n styles[`segmented--${size}`],\n isReadOnly && styles['segmented--readOnly'],\n className,\n )}\n data-testid={testId}\n onKeyDown={handleKeyDown}\n >\n {options.map(option => {\n const isSelected = option.value === value;\n\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={isSelected}\n aria-label={isIconOnly ? option.label : undefined}\n data-value={option.value}\n disabled={isDisabled || option.isDisabled}\n /* Donen `tabindex`: grup Tab sirasinda TEK durak. */\n tabIndex={isSelected ? 0 : -1}\n className={cx(\n styles.segmented__item,\n isSelected && styles['segmented__item--selected'],\n )}\n /*\n * Secili ogeye ikinci kez basmak HICBIR SEY yapmaz: gorunum anahtarinda \"hicbiri\" diye\n * bir hal yok. `ChipGroup`ta ayni hareket secimi kaldiriyor ve iki…\n */\n onClick={() => !isSelected && !isReadOnly && onChange(option.value)}\n >\n {option.icon && (\n <span className={styles.segmented__icon} aria-hidden>\n {option.icon}\n </span>\n )}\n {!isIconOnly && <span className={styles.segmented__label}>{option.label}</span>}\n </button>\n );\n })}\n </div>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(SegmentedControl, 'SegmentedControl'),\n) as typeof SegmentedControl;\n"],"names":["SegmentedControl","options","value","onChange","label","isIconOnly","size","isDisabled","isReadOnly","id","required","describedBy","isInvalid","className","testId","listRef","useRef","handleKeyDown","event","offset","enabled","option","current","next","_b","_a","jsx","cx","styles","isSelected","jsxs","SegmentedControl$1","memo","named"],"mappings":";;;;;;AA6CA,MAAMA,IAAmB,CAAmB;AAAA,EAC1C,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,IAAAC;AAAA,EACA,UAAAC;AAAA,EACA,oBAAoBC;AAAA,EACpB,gBAAgBC;AAAA,EAChB,WAAAC;AAAA,EACA,QAAAC;AACF,MAAgB;AACd,QAAMC,IAAUC,EAAuB,IAAI,GAErCC,IAAgB,CAACC,MAAyC;;AAC9D,UAAMC,IACJD,EAAM,QAAQ,gBAAgBA,EAAM,QAAQ,cACxC,IACAA,EAAM,QAAQ,eAAeA,EAAM,QAAQ,YACzC,KACA;AAIR,QAFIC,MAAW,MACfD,EAAM,eAAA,GACFV,KAAcD,GAAY;AAE9B,UAAMa,IAAUnB,EAAQ,OAAO,CAAAoB,MAAU,CAACA,EAAO,UAAU;AAC3D,QAAID,EAAQ,WAAW,EAAG;AAE1B,UAAME,IAAUF,EAAQ,UAAU,CAAAC,MAAUA,EAAO,UAAUnB,CAAK,GAC5DqB,IA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qB,EAAC,QAAA,EAAK,WAAWE,EAAO,kBAAmB,YAAO,MAAA,CAAM;AAAA,YAAA;AAAA,UAAA;AAAA,UAxBnEP,EAAO;AAAA,QAAA;AAAA,MA2BlB,CAAC;AAAA,IAAA;AAAA,EAAA;AAGP,GAEAU,IAA6B,gBAAAC;AAAA,EACb,gBAAAC,EAAMjC,GAAkB,kBAAkB;AAC1D;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),n=require("react"),ae=require("react-dom"),U=require("react-bootstrap-icons"),se=require("../../hooks/useListboxNavigation.cjs"),oe=require("../../hooks/usePortalSurface.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),n=require("react"),ae=require("react-dom"),U=require("react-bootstrap-icons"),se=require("../../hooks/useListboxNavigation.cjs"),oe=require("../../hooks/usePortalSurface.cjs"),le=require("../../hooks/usePositioning.cjs"),ce=require("../../constants/breakpoint.constants.cjs"),v=require("../../helpers/class-name.helper.cjs"),ie=require("../../helpers/component.helper.cjs"),de=require("../../helpers/ref.helper.cjs"),ue=require("../../helpers/label.helper.cjs"),fe=require("../../theme/context.cjs"),pe=require("../BottomSheet/index.cjs"),t={default:{"select":"ui-select-tiiPL","trigger":"ui-trigger-rHQJz","trigger--empty":"ui-trigger--empty-cuinb","trigger--open":"ui-trigger--open-1nsvu","trigger--invalid":"ui-trigger--invalid-NtP0W","trigger--readOnly":"ui-trigger--readOnly-E6YX-","trigger--sm":"ui-trigger--sm-Xnu1C","trigger__icon":"ui-trigger__icon-apCcx","trigger__srName":"ui-trigger__srName-XLCxt","trigger__value":"ui-trigger__value-ioH7K","trigger__chevron":"ui-trigger__chevron-FtsIZ","trigger__chevron--open":"ui-trigger__chevron--open-1P2P-","panel":"ui-panel-rGOOd","list":"ui-list-SOKf8","list--sheet":"ui-list--sheet-BIjCb","option":"ui-option-ZDPef","option--active":"ui-option--active-R4lLF","option--selected":"ui-option--selected-glQMj","option--disabled":"ui-option--disabled-h4rdd","option__label":"ui-option__label-SsoYB","option__check":"ui-option__check-8CPSG"}},ge=({options:c,value:E,onChange:O,onBlur:R,label:q,placeholder:W,closeLabel:F,icon:C,size:H="md",align:Q="start",isDisabled:N,isReadOnly:p,id:Y,className:z,testId:G,required:J,"aria-describedby":V,"aria-invalid":D},S)=>{const{labels:u}=fe.useUi(),X=ue.resolveLabel("Select.placeholder",W,u==null?void 0:u.selectPlaceholder),Z=n.useId(),d=Y??Z,$=`${d}-listbox`,j=e=>`${d}-option-${e}`,w=n.useRef(null),x=n.useRef(null),g=n.useRef(null),ee=n.useCallback(e=>{x.current=e,de.assignRef(S,e)},[S]),[a,k]=n.useState(null),y=le.default(x,g,{side:"bottom",align:Q,isOpen:a==="popover"}),b=oe.default(a==="popover",x,g),o=a!==null,_=c.findIndex(e=>e.value===E),h=_>=0?c[_]:null,f=n.useCallback(()=>k(null),[]),M=n.useCallback(()=>{N||p||c.length===0||k(window.matchMedia(ce.SHEET_MEDIA_QUERY).matches?"sheet":"popover")},[N,p,c.length]),L=e=>{e.isDisabled||(O(e.value),f())},P=n.useRef(!1);n.useEffect(()=>{var e;P.current&&!o&&((e=x.current)==null||e.focus()),P.current=o},[o]),n.useEffect(()=>{if(a!=="popover")return;const e=r=>{var i,K;const l=r.target;(i=w.current)!=null&&i.contains(l)||(K=g.current)!=null&&K.contains(l)||f()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a,f]);const{activeIndex:m,setActiveIndex:te,listRef:I,handleKeyDown:re}=se.default({count:c.length,isOpen:o,initialIndex:_>=0?_:0,onSelect:e=>{const r=c[e];r&&L(r)},onClose:f});n.useEffect(()=>{var e;a==="sheet"&&((e=I.current)==null||e.focus({preventScroll:!0}))},[a,I]);const T=n.useRef(a);T.current=a;const ne=e=>{var l,i;if(!R||T.current==="sheet")return;const r=e.relatedTarget;r instanceof Node&&((l=w.current)!=null&&l.contains(r)||(i=g.current)!=null&&i.contains(r))||R(e)},A=e=>{if(!o){["ArrowDown","ArrowUp","Enter"," "].includes(e.key)&&(e.preventDefault(),M());return}re(e)},B=e=>s.jsx("ul",{ref:I,id:$,role:"listbox","aria-label":q,"aria-activedescendant":e&&c[m]?j(m):void 0,tabIndex:e?0:-1,className:v.cx(t.default.list,e&&t.default["list--sheet"]),onKeyDown:e?A:void 0,children:c.map((r,l)=>{const i=r.value===E;return s.jsxs("li",{id:j(l),role:"option","data-index":l,"aria-selected":i,"aria-disabled":r.isDisabled,className:v.cx(t.default.option,l===m&&t.default["option--active"],i&&t.default["option--selected"],r.isDisabled&&t.default["option--disabled"]),onMouseEnter:()=>te(l),onClick:()=>L(r),children:[s.jsx("span",{className:t.default.option__label,children:r.label}),i&&s.jsx(U.CheckLg,{"aria-hidden":!0,className:t.default.option__check})]},r.value)})});return s.jsxs("span",{ref:w,className:v.cx(t.default.select,z),"data-testid":G,onBlur:ne,children:[s.jsxs("button",{ref:ee,id:d,type:"button",role:"combobox",className:v.cx(t.default.trigger,t.default[`trigger--${H}`],!h&&t.default["trigger--empty"],o&&t.default["trigger--open"],D&&t.default["trigger--invalid"],p&&t.default["trigger--readOnly"]),disabled:N,"aria-haspopup":"listbox","aria-expanded":o,"aria-controls":o?$:void 0,"aria-activedescendant":a==="popover"&&c[m]?j(m):void 0,"aria-labelledby":h?`${d}-name ${d}-value`:`${d}-name`,"aria-describedby":V,"aria-invalid":D,"aria-required":J||void 0,"aria-readonly":p||void 0,onClick:()=>o?f():M(),onKeyDown:A,children:[C&&s.jsx("span",{className:t.default.trigger__icon,"aria-hidden":!0,children:C}),s.jsx("span",{id:`${d}-name`,className:t.default.trigger__srName,children:q}),s.jsx("span",{id:`${d}-value`,className:t.default.trigger__value,children:(h==null?void 0:h.label)??X}),!p&&s.jsx(U.CaretDownFill,{"aria-hidden":!0,className:v.cx(t.default.trigger__chevron,o&&t.default["trigger__chevron--open"])})]}),a==="popover"&&b.container&&ae.createPortal(s.jsx("div",{ref:g,className:t.default.panel,...b.attributes,style:{...y.style,...b.style,minWidth:y.anchorWidth||void 0,visibility:y.isPositioned?void 0:"hidden"},children:B(!1)}),b.container),a==="sheet"&&s.jsx(pe.default,{title:q,closeLabel:F??(u==null?void 0:u.close),onClose:f,children:B(!0)})]})},he=n.forwardRef(ge),me=n.memo(ie.named(he,"Select"));exports.default=me;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Select/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FocusEvent,\n type ForwardedRef,\n forwardRef,\n type KeyboardEvent,\n memo,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\nimport { CaretDownFill, CheckLg } from 'react-bootstrap-icons';\n\nimport useListboxNavigation from '../../hooks/useListboxNavigation';\nimport usePortalSurface from '../../hooks/usePortalSurface';\nimport usePositioning from '../../hooks/usePositioning';\n\nimport { SHEET_MEDIA_QUERY } from '../../constants/breakpoint.constants';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { assignRef } from '../../helpers/ref.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport BottomSheet from '../BottomSheet';\n\nimport styles from './index.module.scss';\n\nexport type SelectOption<T extends string = string> = {\n value: T;\n label: string;\n isDisabled?: boolean;\n};\n\n/** Seçenek listesinin nerede açıldığı. */\ntype OpenMode = 'popover' | 'sheet';\n\ntype Props<T extends string> = {\n options: SelectOption<T>[];\n /** The chosen value. `null` (2.2), or a value no option has, shows the placeholder. */\n value: T | null;\n onChange: (value: T) => void;\n /**\n * Focus left the select (2.2): the trigger and its open list count as one control, so moving\n * between them is not a blur. While the bottom sheet is open the select is still being used;\n * the trigger takes the focus back when the sheet closes.\n */\n onBlur?: (event: FocusEvent<HTMLElement>) => void;\n /** Alanın adı. */\n label: string;\n /** Seçim yokken tetikleyicide görünen metin. */\n placeholder?: string;\n /** Alt sayfanın kapatma düğmesinin erişilebilir adı. */\n closeLabel?: string;\n /** Tetikleyicinin solundaki ikon. */\n icon?: ReactNode;\n /** `sm` yoğun şeritler içindir (araç çubuğu); varsayılan form ölçüsü `md`. */\n size?: 'sm' | 'md';\n /** Panelin hangi kenardan hizalanacağı. */\n align?: 'start' | 'end';\n isDisabled?: boolean;\n /**\n * Read-only (2.2): the value is shown, focusable and announced (`aria-readonly`), but the list\n * does not open. A disabled select drops out of the tab order; a read-only one does not.\n */\n isReadOnly?: boolean;\n id?: string;\n /**\n * Zorunluluk — `Field`in `FieldChildProps` sözleşmesinden gelir.\n * ⚠ Bileşen `...rest` YAYMIYOR, yani `Props`ta bildirilmeyen her alan sessizce buharlaşır.\n * `required` bir dönem tam olarak öyleydi: `<Field…\n */\n required?: boolean;\n 'aria-describedby'?: string;\n 'aria-invalid'?: boolean;\n className?: string;\n testId?: string;\n};\n\n/** Seçim kutusu. `ref` reaches the trigger (2.2): the element to focus for an error. */\nconst SelectBase = <T extends string>(\n {\n options,\n value,\n onChange,\n onBlur,\n label,\n placeholder,\n closeLabel,\n icon,\n size = 'md',\n align = 'start',\n isDisabled,\n isReadOnly,\n id,\n className,\n testId,\n required,\n 'aria-describedby': describedBy,\n 'aria-invalid': isInvalid,\n }: Props<T>,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n const { labels } = useUi();\n const emptyText = resolveLabel('Select.placeholder', placeholder, labels?.selectPlaceholder);\n const generatedId = useId();\n const baseId = id ?? generatedId;\n const listboxId = `${baseId}-listbox`;\n const optionId = (index: number) => `${baseId}-option-${index}`;\n\n const rootRef = useRef<HTMLSpanElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n /* The caller's `ref` and the inner one hold the same trigger. */\n const setTrigger = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n const [openMode, setOpenMode] = useState<OpenMode | null>(null);\n\n /* PANEL SABIT KONUMLU, MUTLAK DEGIL — gerekce SCSS'te (`.panel`). */\n const positioning = usePositioning(triggerRef, panelRef, {\n side: 'bottom',\n align,\n isOpen: openMode === 'popover',\n });\n\n /*\n * Panel BODY'e (ya da icinde bulundugu acik `<dialog>`a) portallanir; gerekce\n * `hooks/usePortalSurface.ts`.\n */\n const portal = usePortalSurface(openMode === 'popover', triggerRef, panelRef);\n\n const isOpen = openMode !== null;\n const selectedIndex = options.findIndex(option => option.value === value);\n const selectedOption = selectedIndex >= 0 ? options[selectedIndex] : null;\n\n const close = useCallback(() => setOpenMode(null), []);\n\n const open = useCallback(() => {\n if (isDisabled || isReadOnly || options.length === 0) return;\n\n /*\n * Etkin secenek SECILI olandan baslar (kancanin `initialIndex`i); kullanici listeyi bastan\n * taramaz.\n */\n /* A sheet only on a narrow TOUCH screen; a desktop window gets the dropdown at any width. */\n setOpenMode(window.matchMedia(SHEET_MEDIA_QUERY).matches ? 'sheet' : 'popover');\n }, [isDisabled, isReadOnly, options.length]);\n\n const selectOption = (option: SelectOption<T>) => {\n if (option.isDisabled) return;\n onChange(option.value);\n close();\n };\n\n /* Kapaninca odak TETIKLEYICIYE doner. */\n const wasOpenRef = useRef(false);\n useEffect(() => {\n if (wasOpenRef.current && !isOpen) triggerRef.current?.focus();\n wasOpenRef.current = isOpen;\n }, [isOpen]);\n\n /*\n * Disari tiklamada panel kapanir.\n * ⚠ PANEL ARTIK KOKUN ICINDE DEGIL — portallandi. `rootRef` tek basina bakilsaydi panelin ICINE\n * yapilan `mousedown` \"disari\" sayilir ve panel…\n */\n useEffect(() => {\n if (openMode !== 'popover') return;\n\n const handlePointerDown = (event: globalThis.MouseEvent) => {\n const target = event.target as Node;\n if (rootRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n close();\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n return () => document.removeEventListener('mousedown', handlePointerDown);\n }, [openMode, close]);\n\n /* KLAVYE MODELI `useListboxNavigation`da — `Combobox`la AYNI kanca. */\n const { activeIndex, setActiveIndex, listRef, handleKeyDown } =\n useListboxNavigation<HTMLUListElement>({\n count: options.length,\n isOpen,\n initialIndex: selectedIndex >= 0 ? selectedIndex : 0,\n onSelect: index => {\n const option = options[index];\n if (option) selectOption(option);\n },\n onClose: close,\n });\n\n /* Alt sayfada odak listenin kendisine gecer: ok tuslari orada isler. */\n useEffect(() => {\n if (openMode === 'sheet') listRef.current?.focus({ preventScroll: true });\n /* `listRef` kancadan geliyor ve `useRef` kimligi SABIT; bagimlilikta\n olmasi etkiyi yeniden calistirmaz, denetci ise kancadan gelen bir\n degerin referans oldugunu kanitlayamiyor. */\n }, [openMode, listRef]);\n\n /*\n * 2.2 `onBlur`: React's focus events bubble through the portal, so the root hears the trigger\n * AND the list. Focus moving to the other part, or into the open sheet, is not a blur.\n */\n const openModeRef = useRef(openMode);\n openModeRef.current = openMode;\n const handleBlur = (event: FocusEvent<HTMLElement>) => {\n if (!onBlur || openModeRef.current === 'sheet') return;\n const next = event.relatedTarget;\n if (\n next instanceof Node &&\n (rootRef.current?.contains(next) || panelRef.current?.contains(next))\n )\n return;\n onBlur(event);\n };\n\n /* KAPALIYKEN ok/Enter/Space paneli ACAR. */\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if (!isOpen) {\n if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(event.key)) {\n event.preventDefault();\n open();\n }\n return;\n }\n\n handleKeyDown(event);\n };\n\n const renderList = (isSheet: boolean) => (\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n /*\n * Alt sayfada baslik `BottomSheet`in icinde ve kimligi bize kapali; listenin adi dogrudan\n * yazilir.\n */\n aria-label={label}\n /*\n * Odak alt sayfada listede, panelde tetikleyicide: etkin seçeneği bildiren öznitelik odağın\n * olduğu öğede durmak zorunda.\n */\n aria-activedescendant={isSheet && options[activeIndex] ? optionId(activeIndex) : undefined}\n tabIndex={isSheet ? 0 : -1}\n className={cx(styles.list, isSheet && styles['list--sheet'])}\n onKeyDown={isSheet ? onKeyDown : undefined}\n >\n {options.map((option, index) => {\n const isChosen = option.value === value;\n\n return (\n <li\n key={option.value}\n id={optionId(index)}\n role=\"option\"\n data-index={index}\n aria-selected={isChosen}\n aria-disabled={option.isDisabled}\n className={cx(\n styles.option,\n index === activeIndex && styles['option--active'],\n isChosen && styles['option--selected'],\n option.isDisabled && styles['option--disabled'],\n )}\n // Fare imleci seçeneğin üstündeyken etkin seçenek de oraya taşınır; iki ayrı vurgu\n // kullanıcıyı şaşırtıyordu.\n onMouseEnter={() => setActiveIndex(index)}\n onClick={() => selectOption(option)}\n >\n <span className={styles.option__label}>{option.label}</span>\n {isChosen && <CheckLg aria-hidden className={styles.option__check} />}\n </li>\n );\n })}\n </ul>\n );\n\n return (\n <span\n ref={rootRef}\n className={cx(styles.select, className)}\n data-testid={testId}\n onBlur={handleBlur}\n >\n <button\n ref={setTrigger}\n id={baseId}\n type=\"button\"\n role=\"combobox\"\n className={cx(\n styles.trigger,\n styles[`trigger--${size}`],\n !selectedOption && styles['trigger--empty'],\n isOpen && styles['trigger--open'],\n isInvalid && styles['trigger--invalid'],\n isReadOnly && styles['trigger--readOnly'],\n )}\n disabled={isDisabled}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listboxId : undefined}\n aria-activedescendant={\n openMode === 'popover' && options[activeIndex] ? optionId(activeIndex) : undefined\n }\n /* ⚠ `aria-label` KULLANILMAZ — SECILI DEGERI MASKELIYORDU. */\n aria-labelledby={selectedOption ? `${baseId}-name ${baseId}-value` : `${baseId}-name`}\n aria-describedby={describedBy}\n aria-invalid={isInvalid}\n /* Tetikleyici bir `<button>`; yerel `required` yok, karsiligi bu. */\n aria-required={required || undefined}\n aria-readonly={isReadOnly || undefined}\n onClick={() => (isOpen ? close() : open())}\n onKeyDown={onKeyDown}\n >\n {icon && (\n <span className={styles.trigger__icon} aria-hidden>\n {icon}\n </span>\n )}\n\n {/* Kontrolün adı — yalnızca erişilebilirlik ağacında. */}\n <span id={`${baseId}-name`} className={styles.trigger__srName}>\n {label}\n </span>\n\n <span id={`${baseId}-value`} className={styles.trigger__value}>\n {selectedOption?.label ?? emptyText}\n </span>\n\n {/*\n * Ok DOLU CARET: ince chevron, kutunun sag ucunda `$text-2` tonunda\n * iki hairline cizgiye iniyor ve kutunun acilir oldugu uzaktan\n * okunmuyordu. Acikken 180° donuyor — yon hâlâ durumu bildiriyor.\n */}\n {/* A read-only select does not open: no caret promising a list. */}\n {!isReadOnly && (\n <CaretDownFill\n aria-hidden\n className={cx(styles.trigger__chevron, isOpen && styles['trigger__chevron--open'])}\n />\n )}\n </button>\n\n {openMode === 'popover' &&\n portal.container &&\n createPortal(\n <div\n ref={panelRef}\n className={styles.panel}\n {...portal.attributes}\n style={{\n ...positioning.style,\n ...portal.style,\n /* Panel tetikleyiciyle EN AZ ayni genislikte. */\n minWidth: positioning.anchorWidth || undefined,\n /* Ilk karede olcu yok; yanlis yerde bir kare parlamasin. */\n visibility: positioning.isPositioned ? undefined : 'hidden',\n }}\n >\n {renderList(false)}\n </div>,\n portal.container,\n )}\n\n {/* Dar ekranda liste alt sayfada acilir; panel klavye acilinca sikisiyor\n ve alt ucu ekranin disinda kaliyordu (bkz. `BottomSheet`). */}\n {openMode === 'sheet' && (\n <BottomSheet title={label} closeLabel={closeLabel ?? labels?.close} onClose={close}>\n {renderList(true)}\n </BottomSheet>\n )}\n </span>\n );\n};\n\n/* A generic component keeps its type parameter through `forwardRef` only with this cast. */\nconst Select = /*#__PURE__*/ forwardRef(SelectBase) as <T extends string>(\n props: Props<T> & { ref?: Ref<HTMLButtonElement> },\n) => ReactElement;\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Select, 'Select')) as typeof Select;\n"],"names":["SelectBase","options","value","onChange","onBlur","label","placeholder","closeLabel","icon","size","align","isDisabled","isReadOnly","id","className","testId","required","describedBy","isInvalid","ref","labels","useUi","emptyText","resolveLabel","generatedId","useId","baseId","listboxId","optionId","index","rootRef","useRef","triggerRef","panelRef","setTrigger","useCallback","node","assignRef","openMode","setOpenMode","useState","positioning","usePositioning","portal","usePortalSurface","isOpen","selectedIndex","option","selectedOption","close","open","SHEET_MEDIA_QUERY","selectOption","wasOpenRef","useEffect","_a","handlePointerDown","event","target","_b","activeIndex","setActiveIndex","listRef","handleKeyDown","useListboxNavigation","openModeRef","handleBlur","next","onKeyDown","renderList","isSheet","jsx","cx","styles","isChosen","jsxs","CheckLg","CaretDownFill","createPortal","BottomSheet","Select","memo","named"],"mappings":"8tBAsFMA,GAAa,CACjB,CACE,QAAAC,EACA,MAAAC,EACA,SAAAC,EACA,OAAAC,EACA,MAAAC,EACA,YAAAC,EACA,WAAAC,EACA,KAAAC,EACA,KAAAC,EAAO,KACP,MAAAC,EAAQ,QACR,WAAAC,EACA,WAAAC,EACA,GAAAC,EACA,UAAAC,EACA,OAAAC,EACA,SAAAC,EACA,mBAAoBC,EACpB,eAAgBC,CAClB,EACAC,IACG,CACH,KAAM,CAAE,OAAAC,CAAA,EAAWC,SAAA,EACbC,EAAYC,GAAAA,aAAa,qBAAsBjB,EAAac,GAAA,YAAAA,EAAQ,iBAAiB,EACrFI,EAAcC,EAAAA,MAAA,EACdC,EAASb,GAAMW,EACfG,EAAY,GAAGD,CAAM,WACrBE,EAAYC,GAAkB,GAAGH,CAAM,WAAWG,CAAK,GAEvDC,EAAUC,EAAAA,OAAwB,IAAI,EACtCC,EAAaD,EAAAA,OAA0B,IAAI,EAC3CE,EAAWF,EAAAA,OAAuB,IAAI,EAEtCG,GAAaC,EAAAA,YAChBC,GAAmC,CAClCJ,EAAW,QAAUI,EACrBC,GAAAA,UAAUlB,EAAKiB,CAAI,CACrB,EACA,CAACj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,MAAMF,GAAQ,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Select/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FocusEvent,\n type ForwardedRef,\n forwardRef,\n type KeyboardEvent,\n memo,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\nimport { CaretDownFill, CheckLg } from 'react-bootstrap-icons';\n\nimport useListboxNavigation from '../../hooks/useListboxNavigation';\nimport usePortalSurface from '../../hooks/usePortalSurface';\nimport usePositioning from '../../hooks/usePositioning';\n\nimport { SHEET_MEDIA_QUERY } from '../../constants/breakpoint.constants';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { assignRef } from '../../helpers/ref.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport BottomSheet from '../BottomSheet';\n\nimport styles from './index.module.scss';\n\nexport type SelectOption<T extends string = string> = {\n value: T;\n label: string;\n isDisabled?: boolean;\n};\n\n/** Seçenek listesinin nerede açıldığı. */\ntype OpenMode = 'popover' | 'sheet';\n\ntype Props<T extends string> = {\n options: SelectOption<T>[];\n /** The chosen value. `null` (2.2), or a value no option has, shows the placeholder. */\n value: T | null;\n onChange: (value: T) => void;\n /**\n * Focus left the select (2.2): the trigger and its open list count as one control, so moving\n * between them is not a blur. While the bottom sheet is open the select is still being used;\n * the trigger takes the focus back when the sheet closes.\n */\n onBlur?: (event: FocusEvent<HTMLElement>) => void;\n /** Alanın adı. */\n label: string;\n /** Seçim yokken tetikleyicide görünen metin. */\n placeholder?: string;\n /** Alt sayfanın kapatma düğmesinin erişilebilir adı. */\n closeLabel?: string;\n /** Tetikleyicinin solundaki ikon. */\n icon?: ReactNode;\n /** `sm` yoğun şeritler içindir (araç çubuğu); varsayılan form ölçüsü `md`. */\n size?: 'sm' | 'md';\n /** Panelin hangi kenardan hizalanacağı. */\n align?: 'start' | 'end';\n isDisabled?: boolean;\n /**\n * Read-only (2.2): the value is shown, focusable and announced (`aria-readonly`), but the list\n * does not open. A disabled select drops out of the tab order; a read-only one does not.\n */\n isReadOnly?: boolean;\n id?: string;\n /**\n * Zorunluluk — `Field`in `FieldChildProps` sözleşmesinden gelir.\n * ⚠ Bileşen `...rest` YAYMIYOR, yani `Props`ta bildirilmeyen her alan sessizce buharlaşır.\n * `required` bir dönem tam olarak öyleydi: `<Field…\n */\n required?: boolean;\n 'aria-describedby'?: string;\n 'aria-invalid'?: boolean;\n className?: string;\n testId?: string;\n};\n\n/** Seçim kutusu. `ref` reaches the trigger (2.2): the element to focus for an error. */\nconst SelectBase = <T extends string>(\n {\n options,\n value,\n onChange,\n onBlur,\n label,\n placeholder,\n closeLabel,\n icon,\n size = 'md',\n align = 'start',\n isDisabled,\n isReadOnly,\n id,\n className,\n testId,\n required,\n 'aria-describedby': describedBy,\n 'aria-invalid': isInvalid,\n }: Props<T>,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n const { labels } = useUi();\n const emptyText = resolveLabel('Select.placeholder', placeholder, labels?.selectPlaceholder);\n const generatedId = useId();\n const baseId = id ?? generatedId;\n const listboxId = `${baseId}-listbox`;\n const optionId = (index: number) => `${baseId}-option-${index}`;\n\n const rootRef = useRef<HTMLSpanElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n /* The caller's `ref` and the inner one hold the same trigger. */\n const setTrigger = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n const [openMode, setOpenMode] = useState<OpenMode | null>(null);\n\n /* PANEL SABIT KONUMLU, MUTLAK DEGIL — gerekce SCSS'te (`.panel`). */\n const positioning = usePositioning(triggerRef, panelRef, {\n side: 'bottom',\n align,\n isOpen: openMode === 'popover',\n });\n\n /*\n * Panel BODY'e (ya da icinde bulundugu acik `<dialog>`a) portallanir; gerekce\n * `hooks/usePortalSurface.ts`.\n */\n const portal = usePortalSurface(openMode === 'popover', triggerRef, panelRef);\n\n const isOpen = openMode !== null;\n const selectedIndex = options.findIndex(option => option.value === value);\n const selectedOption = selectedIndex >= 0 ? options[selectedIndex] : null;\n\n const close = useCallback(() => setOpenMode(null), []);\n\n const open = useCallback(() => {\n if (isDisabled || isReadOnly || options.length === 0) return;\n\n /*\n * Etkin secenek SECILI olandan baslar (kancanin `initialIndex`i); kullanici listeyi bastan\n * taramaz.\n */\n /* A sheet only on a narrow TOUCH screen; a desktop window gets the dropdown at any width. */\n setOpenMode(window.matchMedia(SHEET_MEDIA_QUERY).matches ? 'sheet' : 'popover');\n }, [isDisabled, isReadOnly, options.length]);\n\n const selectOption = (option: SelectOption<T>) => {\n if (option.isDisabled) return;\n onChange(option.value);\n close();\n };\n\n /* Kapaninca odak TETIKLEYICIYE doner. */\n const wasOpenRef = useRef(false);\n useEffect(() => {\n if (wasOpenRef.current && !isOpen) triggerRef.current?.focus();\n wasOpenRef.current = isOpen;\n }, [isOpen]);\n\n /*\n * Disari tiklamada panel kapanir.\n * ⚠ PANEL ARTIK KOKUN ICINDE DEGIL — portallandi. `rootRef` tek basina bakilsaydi panelin ICINE\n * yapilan `mousedown` \"disari\" sayilir ve panel…\n */\n useEffect(() => {\n if (openMode !== 'popover') return;\n\n const handlePointerDown = (event: globalThis.MouseEvent) => {\n const target = event.target as Node;\n if (rootRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n close();\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n return () => document.removeEventListener('mousedown', handlePointerDown);\n }, [openMode, close]);\n\n /* KLAVYE MODELI `useListboxNavigation`da — `Combobox`la AYNI kanca. */\n const { activeIndex, setActiveIndex, listRef, handleKeyDown } =\n useListboxNavigation<HTMLUListElement>({\n count: options.length,\n isOpen,\n initialIndex: selectedIndex >= 0 ? selectedIndex : 0,\n onSelect: index => {\n const option = options[index];\n if (option) selectOption(option);\n },\n onClose: close,\n });\n\n /* Alt sayfada odak listenin kendisine gecer: ok tuslari orada isler. */\n useEffect(() => {\n if (openMode === 'sheet') listRef.current?.focus({ preventScroll: true });\n /* `listRef` kancadan geliyor ve `useRef` kimligi SABIT; bagimlilikta\n olmasi etkiyi yeniden calistirmaz, denetci ise kancadan gelen bir\n degerin referans oldugunu kanitlayamiyor. */\n }, [openMode, listRef]);\n\n /*\n * 2.2 `onBlur`: React's focus events bubble through the portal, so the root hears the trigger\n * AND the list. Focus moving to the other part, or into the open sheet, is not a blur.\n */\n const openModeRef = useRef(openMode);\n openModeRef.current = openMode;\n const handleBlur = (event: FocusEvent<HTMLElement>) => {\n if (!onBlur || openModeRef.current === 'sheet') return;\n const next = event.relatedTarget;\n if (\n next instanceof Node &&\n (rootRef.current?.contains(next) || panelRef.current?.contains(next))\n )\n return;\n onBlur(event);\n };\n\n /* KAPALIYKEN ok/Enter/Space paneli ACAR. */\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if (!isOpen) {\n if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(event.key)) {\n event.preventDefault();\n open();\n }\n return;\n }\n\n handleKeyDown(event);\n };\n\n const renderList = (isSheet: boolean) => (\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n /*\n * Alt sayfada baslik `BottomSheet`in icinde ve kimligi bize kapali; listenin adi dogrudan\n * yazilir.\n */\n aria-label={label}\n /*\n * Odak alt sayfada listede, panelde tetikleyicide: etkin seçeneği bildiren öznitelik odağın\n * olduğu öğede durmak zorunda.\n */\n aria-activedescendant={isSheet && options[activeIndex] ? optionId(activeIndex) : undefined}\n tabIndex={isSheet ? 0 : -1}\n className={cx(styles.list, isSheet && styles['list--sheet'])}\n onKeyDown={isSheet ? onKeyDown : undefined}\n >\n {options.map((option, index) => {\n const isChosen = option.value === value;\n\n return (\n <li\n key={option.value}\n id={optionId(index)}\n role=\"option\"\n data-index={index}\n aria-selected={isChosen}\n aria-disabled={option.isDisabled}\n className={cx(\n styles.option,\n index === activeIndex && styles['option--active'],\n isChosen && styles['option--selected'],\n option.isDisabled && styles['option--disabled'],\n )}\n // Fare imleci seçeneğin üstündeyken etkin seçenek de oraya taşınır; iki ayrı vurgu\n // kullanıcıyı şaşırtıyordu.\n onMouseEnter={() => setActiveIndex(index)}\n onClick={() => selectOption(option)}\n >\n <span className={styles.option__label}>{option.label}</span>\n {isChosen && <CheckLg aria-hidden className={styles.option__check} />}\n </li>\n );\n })}\n </ul>\n );\n\n return (\n <span\n ref={rootRef}\n className={cx(styles.select, className)}\n data-testid={testId}\n onBlur={handleBlur}\n >\n <button\n ref={setTrigger}\n id={baseId}\n type=\"button\"\n role=\"combobox\"\n className={cx(\n styles.trigger,\n styles[`trigger--${size}`],\n !selectedOption && styles['trigger--empty'],\n isOpen && styles['trigger--open'],\n isInvalid && styles['trigger--invalid'],\n isReadOnly && styles['trigger--readOnly'],\n )}\n disabled={isDisabled}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listboxId : undefined}\n aria-activedescendant={\n openMode === 'popover' && options[activeIndex] ? optionId(activeIndex) : undefined\n }\n /* ⚠ `aria-label` KULLANILMAZ — SECILI DEGERI MASKELIYORDU. */\n aria-labelledby={selectedOption ? `${baseId}-name ${baseId}-value` : `${baseId}-name`}\n aria-describedby={describedBy}\n aria-invalid={isInvalid}\n /* Tetikleyici bir `<button>`; yerel `required` yok, karsiligi bu. */\n aria-required={required || undefined}\n aria-readonly={isReadOnly || undefined}\n onClick={() => (isOpen ? close() : open())}\n onKeyDown={onKeyDown}\n >\n {icon && (\n <span className={styles.trigger__icon} aria-hidden>\n {icon}\n </span>\n )}\n\n {/* Kontrolün adı — yalnızca erişilebilirlik ağacında. */}\n <span id={`${baseId}-name`} className={styles.trigger__srName}>\n {label}\n </span>\n\n <span id={`${baseId}-value`} className={styles.trigger__value}>\n {selectedOption?.label ?? emptyText}\n </span>\n\n {/*\n * Ok DOLU CARET: ince chevron, kutunun sag ucunda `$text-2` tonunda\n * iki hairline cizgiye iniyor ve kutunun acilir oldugu uzaktan\n * okunmuyordu. Acikken 180° donuyor — yon hâlâ durumu bildiriyor.\n */}\n {/* A read-only select does not open: no caret promising a list. */}\n {!isReadOnly && (\n <CaretDownFill\n aria-hidden\n className={cx(styles.trigger__chevron, isOpen && styles['trigger__chevron--open'])}\n />\n )}\n </button>\n\n {openMode === 'popover' &&\n portal.container &&\n createPortal(\n <div\n ref={panelRef}\n className={styles.panel}\n {...portal.attributes}\n style={{\n ...positioning.style,\n ...portal.style,\n /* Panel tetikleyiciyle EN AZ ayni genislikte. */\n minWidth: positioning.anchorWidth || undefined,\n /* Ilk karede olcu yok; yanlis yerde bir kare parlamasin. */\n visibility: positioning.isPositioned ? undefined : 'hidden',\n }}\n >\n {renderList(false)}\n </div>,\n portal.container,\n )}\n\n {/* Dar ekranda liste alt sayfada acilir; panel klavye acilinca sikisiyor\n ve alt ucu ekranin disinda kaliyordu (bkz. `BottomSheet`). */}\n {openMode === 'sheet' && (\n <BottomSheet title={label} closeLabel={closeLabel ?? labels?.close} onClose={close}>\n {renderList(true)}\n </BottomSheet>\n )}\n </span>\n );\n};\n\n/* A generic component keeps its type parameter through `forwardRef` only with this cast. */\nconst Select = /*#__PURE__*/ forwardRef(SelectBase) as <T extends string>(\n props: Props<T> & { ref?: Ref<HTMLButtonElement> },\n) => ReactElement;\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Select, 'Select')) as typeof Select;\n"],"names":["SelectBase","options","value","onChange","onBlur","label","placeholder","closeLabel","icon","size","align","isDisabled","isReadOnly","id","className","testId","required","describedBy","isInvalid","ref","labels","useUi","emptyText","resolveLabel","generatedId","useId","baseId","listboxId","optionId","index","rootRef","useRef","triggerRef","panelRef","setTrigger","useCallback","node","assignRef","openMode","setOpenMode","useState","positioning","usePositioning","portal","usePortalSurface","isOpen","selectedIndex","option","selectedOption","close","open","SHEET_MEDIA_QUERY","selectOption","wasOpenRef","useEffect","_a","handlePointerDown","event","target","_b","activeIndex","setActiveIndex","listRef","handleKeyDown","useListboxNavigation","openModeRef","handleBlur","next","onKeyDown","renderList","isSheet","jsx","cx","styles","isChosen","jsxs","CheckLg","CaretDownFill","createPortal","BottomSheet","Select","memo","named"],"mappings":"8tBAsFMA,GAAa,CACjB,CACE,QAAAC,EACA,MAAAC,EACA,SAAAC,EACA,OAAAC,EACA,MAAAC,EACA,YAAAC,EACA,WAAAC,EACA,KAAAC,EACA,KAAAC,EAAO,KACP,MAAAC,EAAQ,QACR,WAAAC,EACA,WAAAC,EACA,GAAAC,EACA,UAAAC,EACA,OAAAC,EACA,SAAAC,EACA,mBAAoBC,EACpB,eAAgBC,CAClB,EACAC,IACG,CACH,KAAM,CAAE,OAAAC,CAAA,EAAWC,SAAA,EACbC,EAAYC,GAAAA,aAAa,qBAAsBjB,EAAac,GAAA,YAAAA,EAAQ,iBAAiB,EACrFI,EAAcC,EAAAA,MAAA,EACdC,EAASb,GAAMW,EACfG,EAAY,GAAGD,CAAM,WACrBE,EAAYC,GAAkB,GAAGH,CAAM,WAAWG,CAAK,GAEvDC,EAAUC,EAAAA,OAAwB,IAAI,EACtCC,EAAaD,EAAAA,OAA0B,IAAI,EAC3CE,EAAWF,EAAAA,OAAuB,IAAI,EAEtCG,GAAaC,EAAAA,YAChBC,GAAmC,CAClCJ,EAAW,QAAUI,EACrBC,GAAAA,UAAUlB,EAAKiB,CAAI,CACrB,EACA,CAACjB,CAAG,CAAA,EAEA,CAACmB,EAAUC,CAAW,EAAIC,EAAAA,SAA0B,IAAI,EAGxDC,EAAcC,GAAAA,QAAeV,EAAYC,EAAU,CACvD,KAAM,SACN,MAAAvB,EACA,OAAQ4B,IAAa,SAAA,CACtB,EAMKK,EAASC,GAAAA,QAAiBN,IAAa,UAAWN,EAAYC,CAAQ,EAEtEY,EAASP,IAAa,KACtBQ,EAAgB7C,EAAQ,UAAU8C,GAAUA,EAAO,QAAU7C,CAAK,EAClE8C,EAAiBF,GAAiB,EAAI7C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,QAAS,UAAW+C,EAAAA,QAAO,gBAC3C,SAAApE,CAAA,CACH,EAEAkE,EAAAA,IAAC,OAAA,CAAK,GAAI,GAAG7C,CAAM,SAAU,UAAW+C,EAAAA,QAAO,eAC5C,UAAAzB,GAAA,YAAAA,EAAgB,QAAS1B,CAAA,CAC5B,EAQC,CAACV,GACA2D,EAAAA,IAACM,EAAAA,cAAA,CACC,cAAW,GACX,UAAWL,EAAAA,GAAGC,EAAAA,QAAO,iBAAkB5B,GAAU4B,EAAAA,QAAO,wBAAwB,CAAC,CAAA,CAAA,CACnF,CAAA,CAAA,EAIHnC,IAAa,WACZK,EAAO,WACPmC,GAAAA,aACEP,EAAAA,IAAC,MAAA,CACC,IAAKtC,EACL,UAAWwC,EAAAA,QAAO,MACjB,GAAG9B,EAAO,WACX,MAAO,CACL,GAAGF,EAAY,MACf,GAAGE,EAAO,MAEV,SAAUF,EAAY,aAAe,OAErC,WAAYA,EAAY,aAAe,OAAY,QAAA,EAGpD,WAAW,EAAK,CAAA,CAAA,EAEnBE,EAAO,SAAA,EAKVL,IAAa,SACZiC,EAAAA,IAACQ,GAAAA,QAAA,CAAY,MAAO1E,EAAO,WAAYE,IAAca,GAAA,YAAAA,EAAQ,OAAO,QAAS6B,EAC1E,SAAAoB,EAAW,EAAI,CAAA,CAClB,CAAA,CAAA,CAAA,CAIR,EAGMW,gBAAkChF,EAAU,EAIlDgF,GAA6BC,OAAmBC,GAAAA,MAAMF,GAAQ,QAAQ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { memo as ae, forwardRef as se, useId as ce, useRef as h, useCallback as C, useState as le, useEffect as
|
|
2
|
+
import { jsxs as E, jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { memo as ae, forwardRef as se, useId as ce, useRef as h, useCallback as C, useState as le, useEffect as S } from "react";
|
|
4
4
|
import { createPortal as de } from "react-dom";
|
|
5
5
|
import { CaretDownFill as ue, CheckLg as me } from "react-bootstrap-icons";
|
|
6
6
|
import pe from "../../hooks/useListboxNavigation.js";
|
|
@@ -16,7 +16,7 @@ import we from "../BottomSheet/index.js";
|
|
|
16
16
|
const t = {"select":"ui-select-tiiPL","trigger":"ui-trigger-rHQJz","trigger--empty":"ui-trigger--empty-cuinb","trigger--open":"ui-trigger--open-1nsvu","trigger--invalid":"ui-trigger--invalid-NtP0W","trigger--readOnly":"ui-trigger--readOnly-E6YX-","trigger--sm":"ui-trigger--sm-Xnu1C","trigger__icon":"ui-trigger__icon-apCcx","trigger__srName":"ui-trigger__srName-XLCxt","trigger__value":"ui-trigger__value-ioH7K","trigger__chevron":"ui-trigger__chevron-FtsIZ","trigger__chevron--open":"ui-trigger__chevron--open-1P2P-","panel":"ui-panel-rGOOd","list":"ui-list-SOKf8","list--sheet":"ui-list--sheet-BIjCb","option":"ui-option-ZDPef","option--active":"ui-option--active-R4lLF","option--selected":"ui-option--selected-glQMj","option--disabled":"ui-option--disabled-h4rdd","option__label":"ui-option__label-SsoYB","option__check":"ui-option__check-8CPSG"};
|
|
17
17
|
const Ne = ({
|
|
18
18
|
options: a,
|
|
19
|
-
value:
|
|
19
|
+
value: L,
|
|
20
20
|
onChange: H,
|
|
21
21
|
onBlur: k,
|
|
22
22
|
label: w,
|
|
@@ -39,30 +39,30 @@ const Ne = ({
|
|
|
39
39
|
b.current = e, be(R, e);
|
|
40
40
|
},
|
|
41
41
|
[R]
|
|
42
|
-
), [
|
|
42
|
+
), [o, T] = le(null), $ = ge(b, p, {
|
|
43
43
|
side: "bottom",
|
|
44
44
|
align: z,
|
|
45
|
-
isOpen:
|
|
46
|
-
}), x = fe(
|
|
45
|
+
isOpen: o === "popover"
|
|
46
|
+
}), x = fe(o === "popover", b, p), n = o !== null, _ = a.findIndex((e) => e.value === L), f = _ >= 0 ? a[_] : null, u = C(() => T(null), []), B = C(() => {
|
|
47
47
|
N || m || a.length === 0 || T(window.matchMedia(he).matches ? "sheet" : "popover");
|
|
48
48
|
}, [N, m, a.length]), K = (e) => {
|
|
49
49
|
e.isDisabled || (H(e.value), u());
|
|
50
50
|
}, U = h(!1);
|
|
51
|
-
|
|
51
|
+
S(() => {
|
|
52
52
|
var e;
|
|
53
|
-
U.current && !
|
|
54
|
-
}, [
|
|
55
|
-
if (
|
|
53
|
+
U.current && !n && ((e = b.current) == null || e.focus()), U.current = n;
|
|
54
|
+
}, [n]), S(() => {
|
|
55
|
+
if (o !== "popover") return;
|
|
56
56
|
const e = (r) => {
|
|
57
57
|
var s, F;
|
|
58
58
|
const i = r.target;
|
|
59
59
|
(s = I.current) != null && s.contains(i) || (F = p.current) != null && F.contains(i) || u();
|
|
60
60
|
};
|
|
61
61
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
62
|
-
}, [
|
|
63
|
-
const { activeIndex: g, setActiveIndex:
|
|
62
|
+
}, [o, u]);
|
|
63
|
+
const { activeIndex: g, setActiveIndex: oe, listRef: D, handleKeyDown: ne } = pe({
|
|
64
64
|
count: a.length,
|
|
65
|
-
isOpen:
|
|
65
|
+
isOpen: n,
|
|
66
66
|
initialIndex: _ >= 0 ? _ : 0,
|
|
67
67
|
onSelect: (e) => {
|
|
68
68
|
const r = a[e];
|
|
@@ -70,27 +70,27 @@ const Ne = ({
|
|
|
70
70
|
},
|
|
71
71
|
onClose: u
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
S(() => {
|
|
74
74
|
var e;
|
|
75
|
-
|
|
76
|
-
}, [
|
|
77
|
-
const j = h(
|
|
78
|
-
j.current =
|
|
75
|
+
o === "sheet" && ((e = D.current) == null || e.focus({ preventScroll: !0 }));
|
|
76
|
+
}, [o, D]);
|
|
77
|
+
const j = h(o);
|
|
78
|
+
j.current = o;
|
|
79
79
|
const ie = (e) => {
|
|
80
80
|
var i, s;
|
|
81
81
|
if (!k || j.current === "sheet") return;
|
|
82
82
|
const r = e.relatedTarget;
|
|
83
83
|
r instanceof Node && ((i = I.current) != null && i.contains(r) || (s = p.current) != null && s.contains(r)) || k(e);
|
|
84
84
|
}, W = (e) => {
|
|
85
|
-
if (!
|
|
85
|
+
if (!n) {
|
|
86
86
|
["ArrowDown", "ArrowUp", "Enter", " "].includes(e.key) && (e.preventDefault(), B());
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
ne(e);
|
|
90
90
|
}, q = (e) => /* @__PURE__ */ c(
|
|
91
91
|
"ul",
|
|
92
92
|
{
|
|
93
|
-
ref:
|
|
93
|
+
ref: D,
|
|
94
94
|
id: A,
|
|
95
95
|
role: "listbox",
|
|
96
96
|
"aria-label": w,
|
|
@@ -99,8 +99,8 @@ const Ne = ({
|
|
|
99
99
|
className: v(t.list, e && t["list--sheet"]),
|
|
100
100
|
onKeyDown: e ? W : void 0,
|
|
101
101
|
children: a.map((r, i) => {
|
|
102
|
-
const s = r.value ===
|
|
103
|
-
return /* @__PURE__ */
|
|
102
|
+
const s = r.value === L;
|
|
103
|
+
return /* @__PURE__ */ E(
|
|
104
104
|
"li",
|
|
105
105
|
{
|
|
106
106
|
id: y(i),
|
|
@@ -114,7 +114,7 @@ const Ne = ({
|
|
|
114
114
|
s && t["option--selected"],
|
|
115
115
|
r.isDisabled && t["option--disabled"]
|
|
116
116
|
),
|
|
117
|
-
onMouseEnter: () =>
|
|
117
|
+
onMouseEnter: () => oe(i),
|
|
118
118
|
onClick: () => K(r),
|
|
119
119
|
children: [
|
|
120
120
|
/* @__PURE__ */ c("span", { className: t.option__label, children: r.label }),
|
|
@@ -126,7 +126,7 @@ const Ne = ({
|
|
|
126
126
|
})
|
|
127
127
|
}
|
|
128
128
|
);
|
|
129
|
-
return /* @__PURE__ */
|
|
129
|
+
return /* @__PURE__ */ E(
|
|
130
130
|
"span",
|
|
131
131
|
{
|
|
132
132
|
ref: I,
|
|
@@ -134,7 +134,7 @@ const Ne = ({
|
|
|
134
134
|
"data-testid": V,
|
|
135
135
|
onBlur: ie,
|
|
136
136
|
children: [
|
|
137
|
-
/* @__PURE__ */
|
|
137
|
+
/* @__PURE__ */ E(
|
|
138
138
|
"button",
|
|
139
139
|
{
|
|
140
140
|
ref: re,
|
|
@@ -145,21 +145,21 @@ const Ne = ({
|
|
|
145
145
|
t.trigger,
|
|
146
146
|
t[`trigger--${Y}`],
|
|
147
147
|
!f && t["trigger--empty"],
|
|
148
|
-
|
|
148
|
+
n && t["trigger--open"],
|
|
149
149
|
P && t["trigger--invalid"],
|
|
150
150
|
m && t["trigger--readOnly"]
|
|
151
151
|
),
|
|
152
152
|
disabled: N,
|
|
153
153
|
"aria-haspopup": "listbox",
|
|
154
|
-
"aria-expanded":
|
|
155
|
-
"aria-controls":
|
|
156
|
-
"aria-activedescendant":
|
|
154
|
+
"aria-expanded": n,
|
|
155
|
+
"aria-controls": n ? A : void 0,
|
|
156
|
+
"aria-activedescendant": o === "popover" && a[g] ? y(g) : void 0,
|
|
157
157
|
"aria-labelledby": f ? `${l}-name ${l}-value` : `${l}-name`,
|
|
158
158
|
"aria-describedby": Z,
|
|
159
159
|
"aria-invalid": P,
|
|
160
160
|
"aria-required": X || void 0,
|
|
161
161
|
"aria-readonly": m || void 0,
|
|
162
|
-
onClick: () =>
|
|
162
|
+
onClick: () => n ? u() : B(),
|
|
163
163
|
onKeyDown: W,
|
|
164
164
|
children: [
|
|
165
165
|
M && /* @__PURE__ */ c("span", { className: t.trigger__icon, "aria-hidden": !0, children: M }),
|
|
@@ -169,13 +169,13 @@ const Ne = ({
|
|
|
169
169
|
ue,
|
|
170
170
|
{
|
|
171
171
|
"aria-hidden": !0,
|
|
172
|
-
className: v(t.trigger__chevron,
|
|
172
|
+
className: v(t.trigger__chevron, n && t["trigger__chevron--open"])
|
|
173
173
|
}
|
|
174
174
|
)
|
|
175
175
|
]
|
|
176
176
|
}
|
|
177
177
|
),
|
|
178
|
-
|
|
178
|
+
o === "popover" && x.container && de(
|
|
179
179
|
/* @__PURE__ */ c(
|
|
180
180
|
"div",
|
|
181
181
|
{
|
|
@@ -183,19 +183,19 @@ const Ne = ({
|
|
|
183
183
|
className: t.panel,
|
|
184
184
|
...x.attributes,
|
|
185
185
|
style: {
|
|
186
|
-
|
|
186
|
+
...$.style,
|
|
187
187
|
...x.style,
|
|
188
188
|
/* Panel tetikleyiciyle EN AZ ayni genislikte. */
|
|
189
|
-
minWidth:
|
|
189
|
+
minWidth: $.anchorWidth || void 0,
|
|
190
190
|
/* Ilk karede olcu yok; yanlis yerde bir kare parlamasin. */
|
|
191
|
-
visibility:
|
|
191
|
+
visibility: $.isPositioned ? void 0 : "hidden"
|
|
192
192
|
},
|
|
193
193
|
children: q(!1)
|
|
194
194
|
}
|
|
195
195
|
),
|
|
196
196
|
x.container
|
|
197
197
|
),
|
|
198
|
-
|
|
198
|
+
o === "sheet" && /* @__PURE__ */ c(we, { title: w, closeLabel: Q ?? (d == null ? void 0 : d.close), onClose: u, children: q(!0) })
|
|
199
199
|
]
|
|
200
200
|
}
|
|
201
201
|
);
|