@lablup/ui-common 0.1.0-alpha.2 → 0.1.0-alpha.21
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 +1 -1
- package/dist/assets/components/BaseCard/BaseCard.css +1 -1
- package/dist/assets/components/Button/Button.css +1 -1
- package/dist/assets/components/DataTable/DataTable.css +1 -1
- package/dist/assets/components/Drawer/Drawer.css +1 -1
- package/dist/assets/components/EmptyState/EmptyState.css +1 -1
- package/dist/assets/components/ErrorState/ErrorState.css +1 -1
- package/dist/assets/components/PageHeader/PageHeader.css +1 -1
- package/dist/assets/components/Select/Select.css +1 -0
- package/dist/assets/components/StatCard/StatCard.css +1 -1
- package/dist/assets/components/Tabs/Tabs.css +1 -1
- package/dist/assets/components/Tooltip/Tooltip.css +1 -1
- package/dist/components/DataTable/DataTable.d.ts +50 -6
- package/dist/components/DataTable/DataTable2.js +205 -133
- package/dist/components/DataTable/DataTable2.js.map +1 -1
- package/dist/components/Drawer/Drawer.d.ts +12 -1
- package/dist/components/Drawer/Drawer2.js +69 -51
- package/dist/components/Drawer/Drawer2.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +10 -3
- package/dist/components/EmptyState/EmptyState2.js +31 -48
- package/dist/components/EmptyState/EmptyState2.js.map +1 -1
- package/dist/components/EmptyState/index.d.ts +6 -1
- package/dist/components/ErrorState/ErrorState.d.ts +17 -4
- package/dist/components/ErrorState/ErrorState2.js +20 -23
- package/dist/components/ErrorState/ErrorState2.js.map +1 -1
- package/dist/components/ErrorState/index.d.ts +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +14 -1
- package/dist/components/PageHeader/PageHeader2.js +40 -24
- package/dist/components/PageHeader/PageHeader2.js.map +1 -1
- package/dist/components/Select/Select.d.ts +38 -0
- package/dist/components/Select/Select2.js +313 -0
- package/dist/components/Select/Select2.js.map +1 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/Skeleton/Skeleton.d.ts +11 -1
- package/dist/components/Skeleton/Skeleton2.js +8 -6
- package/dist/components/Skeleton/Skeleton2.js.map +1 -1
- package/dist/components/Skeleton/SkeletonCard.d.ts +3 -1
- package/dist/components/Skeleton/SkeletonCard2.js +13 -3
- package/dist/components/Skeleton/SkeletonCard2.js.map +1 -1
- package/dist/components/Skeleton/SkeletonChart2.js +5 -0
- package/dist/components/Skeleton/SkeletonChart2.js.map +1 -1
- package/dist/components/Skeleton/SkeletonRow.d.ts +3 -1
- package/dist/components/Skeleton/SkeletonRow2.js +9 -3
- package/dist/components/Skeleton/SkeletonRow2.js.map +1 -1
- package/dist/components/Skeleton/SkeletonText.d.ts +3 -1
- package/dist/components/Skeleton/SkeletonText2.js +7 -5
- package/dist/components/Skeleton/SkeletonText2.js.map +1 -1
- package/dist/components/StatCard/StatCard.d.ts +10 -1
- package/dist/components/StatCard/StatCard2.js +30 -30
- package/dist/components/StatCard/StatCard2.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +10 -23
- package/dist/components/Tabs/Tabs2.js +127 -146
- package/dist/components/Tabs/Tabs2.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/Tabs/index.js +2 -3
- package/dist/components/Tooltip/Tooltip.d.ts +15 -1
- package/dist/components/Tooltip/Tooltip2.js +77 -47
- package/dist/components/Tooltip/Tooltip2.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -6
- package/dist/styles/base.css +101 -10
- package/dist/styles/themes/orange-dark.css +3 -0
- package/dist/styles/themes/orange-light.css +6 -1
- package/package.json +1 -1
- package/dist/components/EmptyState/illustrations.d.ts +0 -51
- package/dist/components/EmptyState/illustrations.js +0 -571
- package/dist/components/EmptyState/illustrations.js.map +0 -1
- package/dist/components/Tabs/tabTags.d.ts +0 -9
- package/dist/components/Tabs/tabTags.js +0 -11
- package/dist/components/Tabs/tabTags.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatCard2.js","names":[],"sources":["../../../src/components/StatCard/StatCard.tsx"],"sourcesContent":["/**\n * StatCard Component\n *\n * Compact metric card for dashboards. Renders a label, a large numeric\n * value (with optional unit/suffix), and optional icon, hint, trend, or\n * accent tone. Wraps `BaseCard` so it inherits hover/focus/click affordances\n * and design tokens consistently with the rest of the common library.\n *\n * Designed for cross-page reuse: Squad dashboard, Statistics page, Cowork\n * dashboard, etc.\n */\n\nimport { memo, useEffect, useRef, useState, type ReactNode, type JSX } from \"react\";\nimport { usePrefersReducedMotion } from \"../../hooks/usePrefersReducedMotion\";\nimport { BaseCard } from \"../BaseCard\";\nimport { Skeleton } from \"../Skeleton\";\nimport \"./StatCard.css\";\n\nexport type StatCardEmphasis = \"compact\" | \"default\" | \"prominent\";\n\nexport type StatCardTone = \"default\" | \"success\" | \"warning\" | \"danger\" | \"info\";\n\nexport type StatCardTrendDirection = \"up\" | \"down\" | \"flat\";\n\nexport interface StatCardTrend {\n /** Direction indicator (up / down / flat) */\n direction: StatCardTrendDirection;\n /** Human-readable delta label (e.g. \"+12%\", \"-3\", \"0\") */\n label: string;\n /** Optional ARIA description for screen readers */\n ariaLabel?: string;\n}\n\nexport interface StatCardProps {\n /** Short label rendered above the value (UPPERCASE styled) */\n label: string;\n /** Primary metric value (number is coerced to localised string) */\n value: string | number;\n /** Optional suffix appended to the value (e.g. \"/ 4\", \"GB\") */\n valueSuffix?: string;\n /** Optional helper line under the value (e.g. context, secondary metric) */\n hint?: ReactNode;\n /** Optional leading icon node, rendered inside an accent badge */\n icon?: ReactNode;\n /** Visual tone, mirrors Badge variants. Default: \"default\" */\n tone?: StatCardTone;\n /** Optional trend indicator under the value */\n trend?: StatCardTrend;\n /** Click handler. Renders the card as keyboard-accessible button. */\n onClick?: () => void;\n /** Render skeletons instead of value/label content while loading */\n loading?: boolean;\n /** Optional aria label override (defaults to label + value) */\n ariaLabel?: string;\n /** Extra class name applied to the root */\n className?: string;\n /** Test id for unit tests */\n testId?: string;\n /**\n * Formatter for numeric values (e.g. abbreviate to \"1.2K\", append \"%\").\n * Defaults to `toLocaleString`. Ignored when `value` is a string.\n */\n format?: (value: number) => string;\n /**\n * Count up to a numeric value on mount and on change. Off by default so\n * existing consumers render the final value immediately; opt in for\n * dashboard hero metrics. Suppressed under `prefers-reduced-motion`.\n */\n animate?: boolean;\n /**\n * Optional trailing visual on the value line (e.g. a sparkline). Kept as a\n * slot so the card does not depend on any particular chart component.\n */\n sparkline?: ReactNode;\n /** Visual weight. Default: \"default\" */\n emphasis?: StatCardEmphasis;\n}\n\nconst ANIMATION_DURATION_MS = 800;\n\n/**\n * Counts from the previous value to `target` with an ease-out-cubic curve.\n * When `enabled` is false the target is returned directly and no animation\n * frame is ever scheduled.\n */\nfunction useAnimatedValue(target: number, enabled: boolean): number {\n const [displayValue, setDisplayValue] = useState(enabled ? 0 : target);\n const previousValue = useRef(enabled ? 0 : target);\n const frameRef = useRef<number | null>(null);\n\n useEffect(() => {\n if (!enabled) {\n previousValue.current = target;\n setDisplayValue(target);\n return;\n }\n\n const startValue = previousValue.current;\n const startTime = performance.now();\n\n const step = (now: number): void => {\n const progress = Math.min((now - startTime) / ANIMATION_DURATION_MS, 1);\n const eased = 1 - Math.pow(1 - progress, 3);\n setDisplayValue(Math.round(startValue + (target - startValue) * eased));\n\n if (progress < 1) {\n frameRef.current = requestAnimationFrame(step);\n } else {\n previousValue.current = target;\n }\n };\n\n frameRef.current = requestAnimationFrame(step);\n\n return () => {\n if (frameRef.current !== null) {\n cancelAnimationFrame(frameRef.current);\n }\n };\n }, [target, enabled]);\n\n return enabled ? displayValue : target;\n}\n\nconst TREND_GLYPH: Record<StatCardTrendDirection, string> = {\n up: \"▲\",\n down: \"▼\",\n flat: \"•\",\n};\n\nfunction formatValue(\n value: string | number,\n format?: (value: number) => string,\n): string {\n if (typeof value === \"number\") {\n return format ? format(value) : value.toLocaleString();\n }\n return value;\n}\n\nfunction StatCardComponent({\n label,\n value,\n valueSuffix,\n hint,\n icon,\n tone = \"default\",\n trend,\n onClick,\n loading = false,\n ariaLabel,\n className = \"\",\n testId,\n format,\n animate = false,\n sparkline,\n emphasis = \"default\",\n}: StatCardProps): JSX.Element {\n const prefersReducedMotion = usePrefersReducedMotion();\n const isNumeric = typeof value === \"number\";\n const shouldAnimate = animate && isNumeric && !loading && !prefersReducedMotion;\n const animatedValue = useAnimatedValue(isNumeric ? value : 0, shouldAnimate);\n\n const displayValue = formatValue(\n isNumeric && shouldAnimate ? animatedValue : value,\n format,\n );\n\n // The aria-label always describes the settled value, never an in-flight\n // animation frame, so assistive tech is not read a counting-up number.\n const composedAriaLabel =\n ariaLabel ??\n (loading ? label : `${label}: ${formatValue(value, format)}${valueSuffix ?? \"\"}`);\n\n const rootClass = [\n \"stat-card\",\n \"corner-accent\",\n `stat-card--tone-${tone}`,\n emphasis !== \"default\" ? `stat-card--${emphasis}` : \"\",\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <BaseCard\n className={rootClass}\n onClick={onClick}\n role={onClick ? undefined : \"group\"}\n ariaLabel={composedAriaLabel}\n testId={testId}\n >\n <div className=\"stat-card__header\">\n <span className=\"stat-card__label\">{label}</span>\n {icon && (\n <span className=\"stat-card__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n </div>\n\n <div className=\"stat-card__body\">\n {loading ? (\n <Skeleton width=\"60%\" height=\"2rem\" />\n ) : sparkline ? (\n // Only wrap when a sparkline is present, so cards without one keep\n // the exact DOM they had before the slot existed.\n <span className=\"stat-card__value-line\">\n <span className=\"stat-card__value-row\">\n <span className=\"stat-card__value\">{displayValue}</span>\n {valueSuffix && (\n <span className=\"stat-card__value-suffix\">{valueSuffix}</span>\n )}\n </span>\n <span className=\"stat-card__sparkline\">{sparkline}</span>\n </span>\n ) : (\n <span className=\"stat-card__value-row\">\n <span className=\"stat-card__value\">{displayValue}</span>\n {valueSuffix && (\n <span className=\"stat-card__value-suffix\">{valueSuffix}</span>\n )}\n </span>\n )}\n\n {trend && !loading && (\n <span\n className={`stat-card__trend stat-card__trend--${trend.direction}`}\n aria-label={trend.ariaLabel ?? trend.label}\n >\n <span aria-hidden=\"true\">{TREND_GLYPH[trend.direction]}</span>\n <span>{trend.label}</span>\n </span>\n )}\n </div>\n\n {hint !== undefined && hint !== null && (\n <div className=\"stat-card__hint\">\n {loading ? <Skeleton width=\"80%\" height=\"0.85rem\" /> : hint}\n </div>\n )}\n </BaseCard>\n );\n}\n\nexport const StatCard = memo(StatCardComponent);\n"],"mappings":";;;;;;;AA8EA,IAAM,IAAwB;AAO9B,SAAS,EAAiB,GAAgB,GAA0B;CAClE,IAAM,CAAC,GAAc,KAAmB,EAAS,IAAU,IAAI,CAAM,GAC/D,IAAgB,EAAO,IAAU,IAAI,CAAM,GAC3C,IAAW,EAAsB,IAAI;CAiC3C,OA/BA,QAAgB;EACd,IAAI,CAAC,GAAS;GAEZ,AADA,EAAc,UAAU,GACxB,EAAgB,CAAM;GACtB;EACF;EAEA,IAAM,IAAa,EAAc,SAC3B,IAAY,YAAY,IAAI,GAE5B,KAAQ,MAAsB;GAClC,IAAM,IAAW,KAAK,KAAK,IAAM,KAAa,GAAuB,CAAC,GAChE,IAAQ,KAAa,IAAI,MAAU;GAGzC,AAFA,EAAgB,KAAK,MAAM,KAAc,IAAS,KAAc,CAAK,CAAC,GAElE,IAAW,IACb,EAAS,UAAU,sBAAsB,CAAI,IAE7C,EAAc,UAAU;EAE5B;EAIA,OAFA,EAAS,UAAU,sBAAsB,CAAI,SAEhC;GACX,AAAI,EAAS,YAAY,QACvB,qBAAqB,EAAS,OAAO;EAEzC;CACF,GAAG,CAAC,GAAQ,CAAO,CAAC,GAEb,IAAU,IAAe;AAClC;AAEA,IAAM,IAAsD;CAC1D,IAAI;CACJ,MAAM;CACN,MAAM;AACR;AAEA,SAAS,EACP,GACA,GACQ;CAIR,OAHI,OAAO,KAAU,WACZ,IAAS,EAAO,CAAK,IAAI,EAAM,eAAe,IAEhD;AACT;AAEA,SA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KAAM,WAAU;KAAhB,UAAA,CACE,kBAAC,QAAD;MAAM,WAAU;MAAoB,UAAA;KAAmB,CAAA,GACtD,KACC,kBAAC,QAAD;MAAM,WAAU;MAA2B,UAAA;KAAkB,CAAA,CAE3D;IAGP,CAAA,GAAA,KAAS,CAAC,KACT,kBAAC,QAAD;KACE,WAAW,sCAAsC,EAAM;KACvD,cAAY,EAAM,aAAa,EAAM;KAFvC,UAAA,CAIE,kBAAC,QAAD;MAAM,eAAY;MAAQ,UAAA,EAAY,EAAM;KAAiB,CAAA,GAC7D,kBAAC,QAAD,EAAA,UAAO,EAAM,MAAY,CAAA,CACrB;IAEL,CAAA,CAAA;;GAEJ,KAA+B,QAC9B,kBAAC,OAAD;IAAK,WAAU;IACZ,UAAA,IAAU,kBAAC,GAAD;KAAU,OAAM;KAAM,QAAO;IAAW,CAAA,IAAI;GACpD,CAAA;EAEC;;AAEd;AAEA,IAAa,IAAW,EAAK,CAAiB"}
|
|
1
|
+
{"version":3,"file":"StatCard2.js","names":[],"sources":["../../../src/components/StatCard/StatCard.tsx"],"sourcesContent":["/**\n * StatCard Component\n *\n * Compact metric card for dashboards. Renders a label, a large numeric\n * value (with optional unit/suffix), and optional icon, hint, trend, or\n * accent tone. The label can be a node (`labelNode`) while the accessible name\n * stays the plain `label` string. Wraps `BaseCard` so it inherits hover/focus/click affordances\n * and design tokens consistently with the rest of the common library.\n *\n * Designed for cross-page reuse: Squad dashboard, Statistics page, Cowork\n * dashboard, etc.\n */\n\nimport { memo, useEffect, useRef, useState, type ReactNode, type JSX } from \"react\";\nimport { usePrefersReducedMotion } from \"../../hooks/usePrefersReducedMotion\";\nimport { BaseCard } from \"../BaseCard\";\nimport { Skeleton } from \"../Skeleton\";\nimport \"./StatCard.css\";\n\nexport type StatCardEmphasis = \"compact\" | \"default\" | \"prominent\";\n\nexport type StatCardTone = \"default\" | \"success\" | \"warning\" | \"danger\" | \"info\";\n\nexport type StatCardTrendDirection = \"up\" | \"down\" | \"flat\";\n\nexport interface StatCardTrend {\n /** Direction indicator (up / down / flat) */\n direction: StatCardTrendDirection;\n /** Human-readable delta label (e.g. \"+12%\", \"-3\", \"0\") */\n label: string;\n /** Optional ARIA description for screen readers */\n ariaLabel?: string;\n}\n\nexport interface StatCardProps {\n /** Short label rendered above the value (UPPERCASE styled) */\n label: string;\n /**\n * Rendered in place of `label` when the label is not plain text: a glossary\n * term carrying its definition, a unit badge, an info affordance.\n *\n * `label` stays required and stays the accessible name, so the name is a\n * string the consumer wrote rather than whatever text happens to fall out of\n * a node. Pass the same words in both.\n */\n labelNode?: ReactNode;\n /** Primary metric value (number is coerced to localised string) */\n value: string | number;\n /** Optional suffix appended to the value (e.g. \"/ 4\", \"GB\") */\n valueSuffix?: string;\n /** Optional helper line under the value (e.g. context, secondary metric) */\n hint?: ReactNode;\n /** Optional leading icon node, rendered inside an accent badge */\n icon?: ReactNode;\n /** Visual tone, mirrors Badge variants. Default: \"default\" */\n tone?: StatCardTone;\n /** Optional trend indicator under the value */\n trend?: StatCardTrend;\n /** Click handler. Renders the card as keyboard-accessible button. */\n onClick?: () => void;\n /** Render skeletons instead of value/label content while loading */\n loading?: boolean;\n /** Optional aria label override (defaults to label + value) */\n ariaLabel?: string;\n /** Extra class name applied to the root */\n className?: string;\n /** Test id for unit tests */\n testId?: string;\n /**\n * Formatter for numeric values (e.g. abbreviate to \"1.2K\", append \"%\").\n * Defaults to `toLocaleString`. Ignored when `value` is a string.\n */\n format?: (value: number) => string;\n /**\n * Count up to a numeric value on mount and on change. Off by default so\n * existing consumers render the final value immediately; opt in for\n * dashboard hero metrics. Suppressed under `prefers-reduced-motion`.\n */\n animate?: boolean;\n /**\n * Optional trailing visual on the value line (e.g. a sparkline). Kept as a\n * slot so the card does not depend on any particular chart component.\n */\n sparkline?: ReactNode;\n /** Visual weight. Default: \"default\" */\n emphasis?: StatCardEmphasis;\n}\n\nconst ANIMATION_DURATION_MS = 800;\n\n/**\n * Counts from the previous value to `target` with an ease-out-cubic curve.\n * When `enabled` is false the target is returned directly and no animation\n * frame is ever scheduled.\n */\nfunction useAnimatedValue(target: number, enabled: boolean): number {\n const [displayValue, setDisplayValue] = useState(enabled ? 0 : target);\n const previousValue = useRef(enabled ? 0 : target);\n const frameRef = useRef<number | null>(null);\n\n useEffect(() => {\n if (!enabled) {\n previousValue.current = target;\n setDisplayValue(target);\n return;\n }\n\n const startValue = previousValue.current;\n const startTime = performance.now();\n\n const step = (now: number): void => {\n const progress = Math.min((now - startTime) / ANIMATION_DURATION_MS, 1);\n const eased = 1 - Math.pow(1 - progress, 3);\n setDisplayValue(Math.round(startValue + (target - startValue) * eased));\n\n if (progress < 1) {\n frameRef.current = requestAnimationFrame(step);\n } else {\n previousValue.current = target;\n }\n };\n\n frameRef.current = requestAnimationFrame(step);\n\n return () => {\n if (frameRef.current !== null) {\n cancelAnimationFrame(frameRef.current);\n }\n };\n }, [target, enabled]);\n\n return enabled ? displayValue : target;\n}\n\nconst TREND_GLYPH: Record<StatCardTrendDirection, string> = {\n up: \"▲\",\n down: \"▼\",\n flat: \"•\",\n};\n\nfunction formatValue(\n value: string | number,\n format?: (value: number) => string,\n): string {\n if (typeof value === \"number\") {\n return format ? format(value) : value.toLocaleString();\n }\n return value;\n}\n\nfunction StatCardComponent({\n label,\n labelNode,\n value,\n valueSuffix,\n hint,\n icon,\n tone = \"default\",\n trend,\n onClick,\n loading = false,\n ariaLabel,\n className = \"\",\n testId,\n format,\n animate = false,\n sparkline,\n emphasis = \"default\",\n}: StatCardProps): JSX.Element {\n const prefersReducedMotion = usePrefersReducedMotion();\n const isNumeric = typeof value === \"number\";\n const shouldAnimate = animate && isNumeric && !loading && !prefersReducedMotion;\n const animatedValue = useAnimatedValue(isNumeric ? value : 0, shouldAnimate);\n\n const displayValue = formatValue(\n isNumeric && shouldAnimate ? animatedValue : value,\n format,\n );\n\n // The aria-label always describes the settled value, never an in-flight\n // animation frame, so assistive tech is not read a counting-up number.\n const composedAriaLabel =\n ariaLabel ??\n (loading ? label : `${label}: ${formatValue(value, format)}${valueSuffix ?? \"\"}`);\n\n const rootClass = [\n \"stat-card\",\n \"corner-accent\",\n `stat-card--tone-${tone}`,\n emphasis !== \"default\" ? `stat-card--${emphasis}` : \"\",\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <BaseCard\n className={rootClass}\n onClick={onClick}\n role={onClick ? undefined : \"group\"}\n ariaLabel={composedAriaLabel}\n testId={testId}\n >\n <div className=\"stat-card__header\">\n <span className=\"stat-card__label\">{labelNode ?? label}</span>\n {icon && (\n <span className=\"stat-card__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n </div>\n\n <div className=\"stat-card__body\">\n {loading ? (\n <Skeleton width=\"60%\" height=\"2rem\" />\n ) : sparkline ? (\n // Only wrap when a sparkline is present, so cards without one keep\n // the exact DOM they had before the slot existed.\n <span className=\"stat-card__value-line\">\n <span className=\"stat-card__value-row\">\n <span className=\"stat-card__value\">{displayValue}</span>\n {valueSuffix && (\n <span className=\"stat-card__value-suffix\">{valueSuffix}</span>\n )}\n </span>\n <span className=\"stat-card__sparkline\">{sparkline}</span>\n </span>\n ) : (\n <span className=\"stat-card__value-row\">\n <span className=\"stat-card__value\">{displayValue}</span>\n {valueSuffix && (\n <span className=\"stat-card__value-suffix\">{valueSuffix}</span>\n )}\n </span>\n )}\n\n {trend && !loading && (\n <span\n className={`stat-card__trend stat-card__trend--${trend.direction}`}\n aria-label={trend.ariaLabel ?? trend.label}\n >\n <span aria-hidden=\"true\">{TREND_GLYPH[trend.direction]}</span>\n <span>{trend.label}</span>\n </span>\n )}\n </div>\n\n {hint !== undefined && hint !== null && (\n <div className=\"stat-card__hint\">\n {loading ? <Skeleton width=\"80%\" height=\"0.85rem\" /> : hint}\n </div>\n )}\n </BaseCard>\n );\n}\n\nexport const StatCard = memo(StatCardComponent);\n"],"mappings":";;;;;;;AAwFA,IAAM,IAAwB;AAO9B,SAAS,EAAiB,GAAgB,GAA0B;CAClE,IAAM,CAAC,GAAc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EL,CAAA,CAAA;;GAEJ,KAA+B,QAC9B,kBAAC,OAAD;IAAK,WAAU;IACZ,UAAA,IAAU,kBAAC,GAAD;KAAU,OAAM;KAAM,QAAO;IAAW,CAAA,IAAI;GACpD,CAAA;EAEC;;AAEd;AAEA,IAAa,IAAW,EAAK,CAAiB"}
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { TabTagType, TabTagLabels } from './tabTags';
|
|
3
|
-
export type { TabTagType, TabTagLabels } from './tabTags';
|
|
4
|
-
export { TAG_CONFIG } from './tabTags';
|
|
5
2
|
export interface TabItem {
|
|
6
3
|
id: string;
|
|
7
4
|
label: string;
|
|
8
5
|
content: ReactNode;
|
|
9
6
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Optional extra trailing node rendered next to the tab label (e.g. a
|
|
21
|
-
* count badge). Distinct from `tag` (which uses a fixed preset). Use this
|
|
22
|
-
* when migrating segmented controls that rendered their own inline count
|
|
23
|
-
* pill alongside the label.
|
|
7
|
+
* Trailing node rendered next to the tab label: a count pill, a status
|
|
8
|
+
* badge, whatever the consumer's vocabulary calls for.
|
|
9
|
+
*
|
|
10
|
+
* This used to sit beside a `tag` prop that took one of four fixed names,
|
|
11
|
+
* required / recommended / beta / experimental, and rendered a Badge for
|
|
12
|
+
* it. Those are one product's guide vocabulary, and the arrangement had
|
|
13
|
+
* already split across the boundary: the badge variant lived here while the
|
|
14
|
+
* label text had to be passed in from the consumer's locale bundle. A
|
|
15
|
+
* consumer that wants that badge renders it here, and owns both halves.
|
|
24
16
|
*/
|
|
25
17
|
labelExtra?: ReactNode;
|
|
26
18
|
/**
|
|
@@ -98,10 +90,5 @@ export interface TabsProps {
|
|
|
98
90
|
scrollLeftLabel?: string;
|
|
99
91
|
/** Accessible label for the right scroll-arrow button. Default: "Scroll right" */
|
|
100
92
|
scrollRightLabel?: string;
|
|
101
|
-
/**
|
|
102
|
-
* English defaults for every guide-tag badge label (required / recommended
|
|
103
|
-
* / beta / experimental). Override individual entries to translate them.
|
|
104
|
-
*/
|
|
105
|
-
tagLabels?: TabTagLabels;
|
|
106
93
|
}
|
|
107
|
-
export declare function Tabs({ tabs, groups, defaultTab, activeTab: controlledTab, onTabChange, className, panelClassName, ariaLabel, showOverflowControls, showGroupLabels, overflowMode: explicitOverflowMode, variant, fillContainer, renderPanel, moreTabsLabel, selectTabLabel, scrollLeftLabel, scrollRightLabel,
|
|
94
|
+
export declare function Tabs({ tabs, groups, defaultTab, activeTab: controlledTab, onTabChange, className, panelClassName, ariaLabel, showOverflowControls, showGroupLabels, overflowMode: explicitOverflowMode, variant, fillContainer, renderPanel, moreTabsLabel, selectTabLabel, scrollLeftLabel, scrollRightLabel, }: TabsProps): import("react").JSX.Element;
|
|
@@ -1,54 +1,46 @@
|
|
|
1
|
-
import { Badge as e } from "../Badge/Badge2.js";
|
|
2
|
-
import { TAG_CONFIG as t } from "./tabTags.js";
|
|
3
1
|
/* empty css */
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { Fragment as
|
|
2
|
+
import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
3
|
+
import { Fragment as ee, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
4
|
//#region src/components/Tabs/Tabs.tsx
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
recommended: "Recommended",
|
|
10
|
-
beta: "Beta",
|
|
11
|
-
experimental: "Experimental"
|
|
12
|
-
};
|
|
13
|
-
function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange: p, className: m = "", panelClassName: h = "", ariaLabel: ne, showOverflowControls: g = !0, showGroupLabels: _ = !0, overflowMode: re, variant: v = "underlined", fillContainer: ie = !1, renderPanel: y = !0, moreTabsLabel: ae = "More tabs", selectTabLabel: oe = "Select tab", scrollLeftLabel: se = "Scroll left", scrollRightLabel: ce = "Scroll right", tagLabels: b = ee }) {
|
|
14
|
-
let x = re ?? (d.length > 0 ? "menu" : "dropdown"), [le, ue] = o(te || u[0]?.id || ""), [de, S] = o(!1), [fe, C] = o(!1), [w, pe] = o(!1), [T, E] = o(!1), [D, O] = o(!1), [me, k] = o(-1), A = a(null), j = a(/* @__PURE__ */ new Map()), M = a(null), N = a(null), P = a(null), F = a([]), I = a(null), L = a(0), R = a(0), z = f ?? le, B = i(() => d.length > 0 ? d.map((e) => ({
|
|
5
|
+
function s({ tabs: s, groups: c = [], defaultTab: te, activeTab: l, onTabChange: u, className: d = "", panelClassName: f = "", ariaLabel: p, showOverflowControls: m = !0, showGroupLabels: h = !0, overflowMode: g, variant: _ = "underlined", fillContainer: ne = !1, renderPanel: v = !0, moreTabsLabel: re = "More tabs", selectTabLabel: ie = "Select tab", scrollLeftLabel: y = "Scroll left", scrollRightLabel: ae = "Scroll right" }) {
|
|
6
|
+
let b = g ?? (c.length > 0 ? "menu" : "dropdown"), [x, oe] = i(te || s[0]?.id || ""), [se, S] = i(!1), [ce, C] = i(!1), [w, le] = i(!1), [T, E] = i(!1), [D, O] = i(!1), [ue, k] = i(-1), A = r(null), j = r(/* @__PURE__ */ new Map()), M = r(null), N = r(null), P = r(null), F = r([]), I = r(null), L = r(0), R = r(0), z = l ?? x, B = n(() => c.length > 0 ? c.map((e) => ({
|
|
15
7
|
group: e,
|
|
16
|
-
tabs:
|
|
8
|
+
tabs: s.filter((t) => t.groupId === e.id)
|
|
17
9
|
})) : [{
|
|
18
10
|
group: null,
|
|
19
|
-
tabs:
|
|
20
|
-
}], [
|
|
21
|
-
|
|
22
|
-
}, [
|
|
11
|
+
tabs: s
|
|
12
|
+
}], [c, s]), V = n(() => B.flatMap(({ tabs: e }) => e), [B]), H = e((e) => {
|
|
13
|
+
l || oe(e), u?.(e), O(!1);
|
|
14
|
+
}, [l, u]), U = e((e, t) => {
|
|
23
15
|
let n;
|
|
24
16
|
switch (e.key) {
|
|
25
17
|
case "ArrowRight":
|
|
26
|
-
e.preventDefault(), n = t ===
|
|
18
|
+
e.preventDefault(), n = t === s.length - 1 ? 0 : t + 1;
|
|
27
19
|
break;
|
|
28
20
|
case "ArrowLeft":
|
|
29
|
-
e.preventDefault(), n = t === 0 ?
|
|
21
|
+
e.preventDefault(), n = t === 0 ? s.length - 1 : t - 1;
|
|
30
22
|
break;
|
|
31
23
|
case "Home":
|
|
32
24
|
e.preventDefault(), n = 0;
|
|
33
25
|
break;
|
|
34
26
|
case "End":
|
|
35
|
-
e.preventDefault(), n =
|
|
27
|
+
e.preventDefault(), n = s.length - 1;
|
|
36
28
|
break;
|
|
37
29
|
default: return;
|
|
38
30
|
}
|
|
39
|
-
let r =
|
|
31
|
+
let r = s[n];
|
|
40
32
|
r && (H(r.id), j.current.get(r.id)?.focus());
|
|
41
|
-
}, [
|
|
33
|
+
}, [s, H]), de = e((e, t) => {
|
|
42
34
|
t ? j.current.set(e, t) : j.current.delete(e);
|
|
43
|
-
}, []), W =
|
|
35
|
+
}, []), W = e(() => {
|
|
44
36
|
let e = A.current;
|
|
45
|
-
if (!e || !
|
|
37
|
+
if (!e || !m) {
|
|
46
38
|
S(!1), C(!1);
|
|
47
39
|
return;
|
|
48
40
|
}
|
|
49
41
|
let { scrollLeft: t, scrollWidth: n, clientWidth: r } = e;
|
|
50
42
|
S(t > 0), C(t + r < n - 1);
|
|
51
|
-
}, [
|
|
43
|
+
}, [m]), G = e((e) => {
|
|
52
44
|
let t = A.current;
|
|
53
45
|
if (!t) return;
|
|
54
46
|
let n = t.clientWidth * .75;
|
|
@@ -56,35 +48,35 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
56
48
|
left: e === "left" ? -n : n,
|
|
57
49
|
behavior: "smooth"
|
|
58
50
|
}), I.current !== null && clearTimeout(I.current), I.current = setTimeout(W, 300);
|
|
59
|
-
}, [W]), K =
|
|
51
|
+
}, [W]), K = e(() => {
|
|
60
52
|
if (!A.current || w) return;
|
|
61
53
|
let e = j.current.get(z);
|
|
62
54
|
if (!e) return;
|
|
63
55
|
let t = A.current, n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
64
56
|
n.left < r.left ? t.scrollLeft -= r.left - n.left + 8 : n.right > r.right && (t.scrollLeft += n.right - r.right + 8);
|
|
65
|
-
}, [z, w]), q =
|
|
66
|
-
typeof window > "u" ||
|
|
67
|
-
}, [
|
|
57
|
+
}, [z, w]), q = e(() => {
|
|
58
|
+
typeof window > "u" || b !== "dropdown" || le(window.innerWidth < 480);
|
|
59
|
+
}, [b]), fe = e(() => {
|
|
68
60
|
E((e) => !e);
|
|
69
|
-
}, []),
|
|
61
|
+
}, []), pe = e((e) => {
|
|
70
62
|
e.key === "Escape" && T && (e.preventDefault(), E(!1));
|
|
71
|
-
}, [T]), J =
|
|
63
|
+
}, [T]), J = e((e) => {
|
|
72
64
|
e.touches[0] && (L.current = e.touches[0].clientX);
|
|
73
|
-
}, []), Y =
|
|
65
|
+
}, []), Y = e((e) => {
|
|
74
66
|
e.touches[0] && (R.current = e.touches[0].clientX);
|
|
75
|
-
}, []), X =
|
|
67
|
+
}, []), X = e(() => {
|
|
76
68
|
if (!L.current || !R.current) return;
|
|
77
69
|
let e = L.current - R.current;
|
|
78
70
|
if (Math.abs(e) > 50) {
|
|
79
|
-
let t =
|
|
71
|
+
let t = s.findIndex((e) => e.id === z), n = s[t + 1], r = s[t - 1];
|
|
80
72
|
e > 0 && n ? H(n.id) : e < 0 && r && H(r.id);
|
|
81
73
|
}
|
|
82
74
|
L.current = 0, R.current = 0;
|
|
83
75
|
}, [
|
|
84
76
|
z,
|
|
85
|
-
|
|
77
|
+
s,
|
|
86
78
|
H
|
|
87
|
-
]),
|
|
79
|
+
]), me = e((e) => {
|
|
88
80
|
let t = V.length;
|
|
89
81
|
switch (e.key) {
|
|
90
82
|
case "Escape":
|
|
@@ -107,10 +99,10 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
107
99
|
break;
|
|
108
100
|
case "End": e.preventDefault(), k(t - 1), F.current[t - 1]?.focus();
|
|
109
101
|
}
|
|
110
|
-
}, [V.length]),
|
|
102
|
+
}, [V.length]), he = e((e) => {
|
|
111
103
|
e.key === "Escape" && D && (e.preventDefault(), O(!1), k(-1));
|
|
112
104
|
}, [D]);
|
|
113
|
-
|
|
105
|
+
t(() => {
|
|
114
106
|
if (!T) return;
|
|
115
107
|
let e = (e) => {
|
|
116
108
|
M.current && !M.current.contains(e.target) && E(!1);
|
|
@@ -118,7 +110,7 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
118
110
|
return document.addEventListener("mousedown", e), () => {
|
|
119
111
|
document.removeEventListener("mousedown", e);
|
|
120
112
|
};
|
|
121
|
-
}, [T]),
|
|
113
|
+
}, [T]), t(() => {
|
|
122
114
|
if (!D) return;
|
|
123
115
|
let e = (e) => {
|
|
124
116
|
N.current && !N.current.contains(e.target) && (O(!1), k(-1));
|
|
@@ -128,7 +120,7 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
128
120
|
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
129
121
|
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
130
122
|
};
|
|
131
|
-
}, [D]),
|
|
123
|
+
}, [D]), t(() => {
|
|
132
124
|
if (D && F.current.length > 0) {
|
|
133
125
|
let e = V.findIndex((e) => e.id === z), t = e >= 0 ? e : 0;
|
|
134
126
|
k(t), requestAnimationFrame(() => {
|
|
@@ -139,16 +131,16 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
139
131
|
D,
|
|
140
132
|
V,
|
|
141
133
|
z
|
|
142
|
-
]),
|
|
143
|
-
if (!
|
|
144
|
-
let e =
|
|
134
|
+
]), t(() => {
|
|
135
|
+
if (!s.find((e) => e.id === z)) {
|
|
136
|
+
let e = s[0];
|
|
145
137
|
e && H(e.id);
|
|
146
138
|
}
|
|
147
139
|
}, [
|
|
148
|
-
|
|
140
|
+
s,
|
|
149
141
|
z,
|
|
150
142
|
H
|
|
151
|
-
]),
|
|
143
|
+
]), t(() => {
|
|
152
144
|
q(), W();
|
|
153
145
|
let e = () => {
|
|
154
146
|
q(), W();
|
|
@@ -156,79 +148,73 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
156
148
|
return window.addEventListener("resize", e), () => {
|
|
157
149
|
window.removeEventListener("resize", e);
|
|
158
150
|
};
|
|
159
|
-
}, [q, W]),
|
|
151
|
+
}, [q, W]), t(() => {
|
|
160
152
|
K();
|
|
161
|
-
}, [z, K]),
|
|
153
|
+
}, [z, K]), t(() => {
|
|
162
154
|
W();
|
|
163
|
-
}, [
|
|
155
|
+
}, [s, W]), t(() => () => {
|
|
164
156
|
I.current !== null && clearTimeout(I.current);
|
|
165
157
|
}, []);
|
|
166
|
-
let Z =
|
|
158
|
+
let Z = s.find((e) => e.id === z)?.content, ge = s.find((e) => e.id === z)?.label, _e = c.length > 0;
|
|
167
159
|
F.current = [];
|
|
168
|
-
let Q = (e
|
|
169
|
-
let
|
|
170
|
-
return /* @__PURE__ */
|
|
171
|
-
ref: (
|
|
172
|
-
|
|
160
|
+
let Q = (e, t) => {
|
|
161
|
+
let n = e.id === z;
|
|
162
|
+
return /* @__PURE__ */ o("button", {
|
|
163
|
+
ref: (t) => {
|
|
164
|
+
de(e.id, t);
|
|
173
165
|
},
|
|
174
166
|
role: "tab",
|
|
175
|
-
"aria-selected":
|
|
176
|
-
"aria-controls":
|
|
177
|
-
id: `tab-${
|
|
178
|
-
tabIndex:
|
|
179
|
-
className: `tabs__tab${
|
|
167
|
+
"aria-selected": n,
|
|
168
|
+
"aria-controls": v ? `tabpanel-${e.id}` : void 0,
|
|
169
|
+
id: `tab-${e.id}`,
|
|
170
|
+
tabIndex: n ? 0 : -1,
|
|
171
|
+
className: `tabs__tab${n ? " tabs__tab--active" : ""}`,
|
|
180
172
|
onClick: () => {
|
|
181
|
-
H(
|
|
173
|
+
H(e.id);
|
|
182
174
|
},
|
|
183
175
|
onKeyDown: (e) => {
|
|
184
|
-
U(e,
|
|
176
|
+
U(e, t), (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") && e.stopPropagation();
|
|
185
177
|
},
|
|
186
178
|
children: [
|
|
187
|
-
|
|
188
|
-
/* @__PURE__ */
|
|
179
|
+
e.labelPrefix,
|
|
180
|
+
/* @__PURE__ */ a("span", {
|
|
189
181
|
className: "tabs__tab-label",
|
|
190
|
-
children:
|
|
191
|
-
}),
|
|
192
|
-
o && /* @__PURE__ */ c(e, {
|
|
193
|
-
variant: o.variant,
|
|
194
|
-
size: "small",
|
|
195
|
-
className: "tabs__tag-badge",
|
|
196
|
-
children: s
|
|
182
|
+
children: e.label
|
|
197
183
|
}),
|
|
198
|
-
|
|
184
|
+
e.labelExtra
|
|
199
185
|
]
|
|
200
|
-
},
|
|
201
|
-
},
|
|
186
|
+
}, e.id);
|
|
187
|
+
}, ve = () => _e ? B.map(({ group: e, tabs: t }, n) => /* @__PURE__ */ o("div", {
|
|
202
188
|
className: "tabs__group",
|
|
203
|
-
children: [e && /* @__PURE__ */
|
|
189
|
+
children: [e && /* @__PURE__ */ o(ee, { children: [n > 0 && /* @__PURE__ */ a("div", {
|
|
204
190
|
className: "tabs__separator",
|
|
205
191
|
role: "separator",
|
|
206
192
|
"aria-hidden": "true"
|
|
207
|
-
}),
|
|
193
|
+
}), h && /* @__PURE__ */ a("span", {
|
|
208
194
|
className: "tabs__group-label",
|
|
209
195
|
children: e.label
|
|
210
|
-
})] }), /* @__PURE__ */
|
|
196
|
+
})] }), /* @__PURE__ */ a("div", {
|
|
211
197
|
className: "tabs__group-tabs",
|
|
212
198
|
children: t.map((e) => {
|
|
213
|
-
let t =
|
|
214
|
-
return
|
|
199
|
+
let t = s.findIndex((t) => t.id === e.id);
|
|
200
|
+
return Q(e, t);
|
|
215
201
|
})
|
|
216
202
|
})]
|
|
217
|
-
}, e?.id || "default")) :
|
|
203
|
+
}, e?.id || "default")) : s.map((e, t) => Q(e, t)), ye = () => b !== "menu" || !m ? null : /* @__PURE__ */ o("div", {
|
|
218
204
|
className: "tabs__overflow",
|
|
219
205
|
ref: N,
|
|
220
|
-
children: [/* @__PURE__ */
|
|
206
|
+
children: [/* @__PURE__ */ a("button", {
|
|
221
207
|
ref: P,
|
|
222
208
|
type: "button",
|
|
223
209
|
className: "tabs__overflow-btn",
|
|
224
210
|
onClick: () => {
|
|
225
211
|
O(!D);
|
|
226
212
|
},
|
|
227
|
-
onKeyDown:
|
|
228
|
-
"aria-label":
|
|
213
|
+
onKeyDown: he,
|
|
214
|
+
"aria-label": re,
|
|
229
215
|
"aria-expanded": D,
|
|
230
216
|
"aria-haspopup": "menu",
|
|
231
|
-
children: /* @__PURE__ */
|
|
217
|
+
children: /* @__PURE__ */ o("svg", {
|
|
232
218
|
width: "20",
|
|
233
219
|
height: "20",
|
|
234
220
|
viewBox: "0 0 24 24",
|
|
@@ -238,75 +224,70 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
238
224
|
strokeLinecap: "round",
|
|
239
225
|
strokeLinejoin: "round",
|
|
240
226
|
children: [
|
|
241
|
-
/* @__PURE__ */
|
|
227
|
+
/* @__PURE__ */ a("circle", {
|
|
242
228
|
cx: "12",
|
|
243
229
|
cy: "12",
|
|
244
230
|
r: "1"
|
|
245
231
|
}),
|
|
246
|
-
/* @__PURE__ */
|
|
232
|
+
/* @__PURE__ */ a("circle", {
|
|
247
233
|
cx: "12",
|
|
248
234
|
cy: "5",
|
|
249
235
|
r: "1"
|
|
250
236
|
}),
|
|
251
|
-
/* @__PURE__ */
|
|
237
|
+
/* @__PURE__ */ a("circle", {
|
|
252
238
|
cx: "12",
|
|
253
239
|
cy: "19",
|
|
254
240
|
r: "1"
|
|
255
241
|
})
|
|
256
242
|
]
|
|
257
243
|
})
|
|
258
|
-
}), D && /* @__PURE__ */
|
|
244
|
+
}), D && /* @__PURE__ */ a("div", {
|
|
259
245
|
className: "tabs__overflow-menu",
|
|
260
246
|
role: "menu",
|
|
261
|
-
onKeyDown:
|
|
262
|
-
children: B.map(({ group:
|
|
247
|
+
onKeyDown: me,
|
|
248
|
+
children: B.map(({ group: e, tabs: t }) => /* @__PURE__ */ o("div", {
|
|
263
249
|
className: "tabs__overflow-group",
|
|
264
|
-
children: [
|
|
250
|
+
children: [e && h && /* @__PURE__ */ a("div", {
|
|
265
251
|
className: "tabs__overflow-group-label",
|
|
266
|
-
children:
|
|
267
|
-
}),
|
|
268
|
-
let
|
|
269
|
-
return /* @__PURE__ */
|
|
252
|
+
children: e.label
|
|
253
|
+
}), t.map((e) => {
|
|
254
|
+
let t = e.id === z, n = V.findIndex((t) => t.id === e.id);
|
|
255
|
+
return /* @__PURE__ */ o("button", {
|
|
270
256
|
ref: (e) => {
|
|
271
|
-
e && (F.current[
|
|
257
|
+
e && (F.current[n] = e);
|
|
272
258
|
},
|
|
273
259
|
role: "menuitem",
|
|
274
|
-
tabIndex:
|
|
275
|
-
className: `tabs__overflow-item ${
|
|
260
|
+
tabIndex: ue === n ? 0 : -1,
|
|
261
|
+
className: `tabs__overflow-item ${t ? "tabs__overflow-item--active" : ""}`,
|
|
276
262
|
onClick: () => {
|
|
277
|
-
H(
|
|
263
|
+
H(e.id);
|
|
278
264
|
},
|
|
279
265
|
children: [
|
|
280
|
-
|
|
281
|
-
/* @__PURE__ */
|
|
282
|
-
|
|
283
|
-
variant: o.variant,
|
|
284
|
-
size: "small",
|
|
285
|
-
children: s
|
|
286
|
-
}),
|
|
287
|
-
n.labelExtra
|
|
266
|
+
e.labelPrefix,
|
|
267
|
+
/* @__PURE__ */ a("span", { children: e.label }),
|
|
268
|
+
e.labelExtra
|
|
288
269
|
]
|
|
289
|
-
},
|
|
270
|
+
}, e.id);
|
|
290
271
|
})]
|
|
291
|
-
},
|
|
272
|
+
}, e?.id || "default"))
|
|
292
273
|
})]
|
|
293
|
-
}), $ =
|
|
294
|
-
return
|
|
295
|
-
className: `tabs tabs--mobile-dropdown ${
|
|
296
|
-
children: [/* @__PURE__ */
|
|
274
|
+
}), $ = _ === "segmented" || _ === "compact";
|
|
275
|
+
return b === "dropdown" && w && !$ ? /* @__PURE__ */ o("div", {
|
|
276
|
+
className: `tabs tabs--mobile-dropdown ${d}`,
|
|
277
|
+
children: [/* @__PURE__ */ o("div", {
|
|
297
278
|
className: "tabs__dropdown-container",
|
|
298
279
|
ref: M,
|
|
299
|
-
children: [/* @__PURE__ */
|
|
280
|
+
children: [/* @__PURE__ */ o("button", {
|
|
300
281
|
className: "tabs__dropdown-trigger",
|
|
301
|
-
onClick:
|
|
302
|
-
onKeyDown:
|
|
282
|
+
onClick: fe,
|
|
283
|
+
onKeyDown: pe,
|
|
303
284
|
"aria-expanded": T,
|
|
304
285
|
"aria-haspopup": "listbox",
|
|
305
|
-
"aria-label":
|
|
306
|
-
children: [/* @__PURE__ */
|
|
286
|
+
"aria-label": p || ie,
|
|
287
|
+
children: [/* @__PURE__ */ a("span", {
|
|
307
288
|
className: "tabs__dropdown-label",
|
|
308
|
-
children:
|
|
309
|
-
}), /* @__PURE__ */
|
|
289
|
+
children: ge
|
|
290
|
+
}), /* @__PURE__ */ a("svg", {
|
|
310
291
|
className: `tabs__dropdown-arrow ${T ? "tabs__dropdown-arrow--open" : ""}`,
|
|
311
292
|
width: "16",
|
|
312
293
|
height: "16",
|
|
@@ -314,7 +295,7 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
314
295
|
fill: "none",
|
|
315
296
|
xmlns: "http://www.w3.org/2000/svg",
|
|
316
297
|
"aria-hidden": "true",
|
|
317
|
-
children: /* @__PURE__ */
|
|
298
|
+
children: /* @__PURE__ */ a("path", {
|
|
318
299
|
d: "M4 6L8 10L12 6",
|
|
319
300
|
stroke: "currentColor",
|
|
320
301
|
strokeWidth: "2",
|
|
@@ -322,10 +303,10 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
322
303
|
strokeLinejoin: "round"
|
|
323
304
|
})
|
|
324
305
|
})]
|
|
325
|
-
}), T && /* @__PURE__ */
|
|
306
|
+
}), T && /* @__PURE__ */ a("div", {
|
|
326
307
|
className: "tabs__dropdown-menu",
|
|
327
308
|
role: "listbox",
|
|
328
|
-
children:
|
|
309
|
+
children: s.map((e) => /* @__PURE__ */ a("button", {
|
|
329
310
|
role: "option",
|
|
330
311
|
"aria-selected": e.id === z,
|
|
331
312
|
className: `tabs__dropdown-item ${e.id === z ? "tabs__dropdown-item--active" : ""}`,
|
|
@@ -335,37 +316,37 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
335
316
|
children: e.label
|
|
336
317
|
}, e.id))
|
|
337
318
|
})]
|
|
338
|
-
}),
|
|
319
|
+
}), v && /* @__PURE__ */ a("div", {
|
|
339
320
|
id: `tabpanel-${z}`,
|
|
340
321
|
role: "tabpanel",
|
|
341
322
|
"aria-labelledby": `tab-${z}`,
|
|
342
|
-
className: `tabs__panel ${
|
|
323
|
+
className: `tabs__panel ${f}`.trim(),
|
|
343
324
|
tabIndex: 0,
|
|
344
325
|
onTouchStart: J,
|
|
345
326
|
onTouchMove: Y,
|
|
346
327
|
onTouchEnd: X,
|
|
347
328
|
children: Z
|
|
348
329
|
})]
|
|
349
|
-
}) : /* @__PURE__ */
|
|
350
|
-
className: `tabs ${
|
|
351
|
-
children: [/* @__PURE__ */
|
|
330
|
+
}) : /* @__PURE__ */ o("div", {
|
|
331
|
+
className: `tabs ${b === "menu" ? "tabs--overflow-menu" : ""} ${_ === "segmented" ? "tabs--variant-segmented" : _ === "compact" ? "tabs--variant-compact" : ""} ${$ && ne ? "tabs--fill-container" : ""} ${d}`.replace(/\s+/g, " ").trim(),
|
|
332
|
+
children: [/* @__PURE__ */ o("div", {
|
|
352
333
|
className: "tabs__container",
|
|
353
334
|
children: [
|
|
354
|
-
|
|
335
|
+
m && se && /* @__PURE__ */ a("button", {
|
|
355
336
|
className: "tabs__scroll-arrow tabs__scroll-arrow--left",
|
|
356
337
|
onClick: () => {
|
|
357
338
|
G("left");
|
|
358
339
|
},
|
|
359
|
-
"aria-label":
|
|
340
|
+
"aria-label": y,
|
|
360
341
|
tabIndex: -1,
|
|
361
|
-
children: /* @__PURE__ */
|
|
342
|
+
children: /* @__PURE__ */ a("svg", {
|
|
362
343
|
width: "20",
|
|
363
344
|
height: "20",
|
|
364
345
|
viewBox: "0 0 20 20",
|
|
365
346
|
fill: "none",
|
|
366
347
|
xmlns: "http://www.w3.org/2000/svg",
|
|
367
348
|
"aria-hidden": "true",
|
|
368
|
-
children: /* @__PURE__ */
|
|
349
|
+
children: /* @__PURE__ */ a("path", {
|
|
369
350
|
d: "M12 15L7 10L12 5",
|
|
370
351
|
stroke: "currentColor",
|
|
371
352
|
strokeWidth: "2",
|
|
@@ -374,36 +355,36 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
374
355
|
})
|
|
375
356
|
})
|
|
376
357
|
}),
|
|
377
|
-
/* @__PURE__ */
|
|
358
|
+
/* @__PURE__ */ a("div", {
|
|
378
359
|
ref: A,
|
|
379
360
|
className: "tabs__list",
|
|
380
361
|
role: "tablist",
|
|
381
|
-
"aria-label":
|
|
362
|
+
"aria-label": p,
|
|
382
363
|
onScroll: W,
|
|
383
364
|
onKeyDown: (e) => {
|
|
384
|
-
let t =
|
|
365
|
+
let t = s.findIndex((e) => e.id === z);
|
|
385
366
|
t < 0 || U(e, t);
|
|
386
367
|
},
|
|
387
|
-
onTouchStart:
|
|
388
|
-
onTouchMove:
|
|
389
|
-
onTouchEnd:
|
|
390
|
-
children:
|
|
368
|
+
onTouchStart: b === "dropdown" ? J : void 0,
|
|
369
|
+
onTouchMove: b === "dropdown" ? Y : void 0,
|
|
370
|
+
onTouchEnd: b === "dropdown" ? X : void 0,
|
|
371
|
+
children: ve()
|
|
391
372
|
}),
|
|
392
|
-
|
|
373
|
+
m && ce && /* @__PURE__ */ a("button", {
|
|
393
374
|
className: "tabs__scroll-arrow tabs__scroll-arrow--right",
|
|
394
375
|
onClick: () => {
|
|
395
376
|
G("right");
|
|
396
377
|
},
|
|
397
|
-
"aria-label":
|
|
378
|
+
"aria-label": ae,
|
|
398
379
|
tabIndex: -1,
|
|
399
|
-
children: /* @__PURE__ */
|
|
380
|
+
children: /* @__PURE__ */ a("svg", {
|
|
400
381
|
width: "20",
|
|
401
382
|
height: "20",
|
|
402
383
|
viewBox: "0 0 20 20",
|
|
403
384
|
fill: "none",
|
|
404
385
|
xmlns: "http://www.w3.org/2000/svg",
|
|
405
386
|
"aria-hidden": "true",
|
|
406
|
-
children: /* @__PURE__ */
|
|
387
|
+
children: /* @__PURE__ */ a("path", {
|
|
407
388
|
d: "M8 5L13 10L8 15",
|
|
408
389
|
stroke: "currentColor",
|
|
409
390
|
strokeWidth: "2",
|
|
@@ -412,20 +393,20 @@ function u({ tabs: u, groups: d = [], defaultTab: te, activeTab: f, onTabChange:
|
|
|
412
393
|
})
|
|
413
394
|
})
|
|
414
395
|
}),
|
|
415
|
-
|
|
396
|
+
ye()
|
|
416
397
|
]
|
|
417
|
-
}),
|
|
398
|
+
}), v && /* @__PURE__ */ a("div", {
|
|
418
399
|
id: `tabpanel-${z}`,
|
|
419
400
|
role: "tabpanel",
|
|
420
401
|
"aria-labelledby": `tab-${z}`,
|
|
421
|
-
className: `tabs__panel ${
|
|
402
|
+
className: `tabs__panel ${f}`.trim(),
|
|
422
403
|
tabIndex: 0,
|
|
423
404
|
children: Z
|
|
424
405
|
})]
|
|
425
406
|
});
|
|
426
407
|
}
|
|
427
408
|
//#endregion
|
|
428
|
-
export {
|
|
409
|
+
export { s as Tabs };
|
|
429
410
|
|
|
430
411
|
//# sourceMappingURL=Tabs2.js.map
|
|
431
412
|
import "../../assets/components/Tabs/Tabs.css";
|