wimui 0.67.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/components/_internal/InlineDisclosure.cjs +2 -0
  2. package/dist/components/_internal/InlineDisclosure.d.ts +22 -0
  3. package/dist/components/_internal/InlineDisclosure.js +47 -0
  4. package/dist/components/_internal/inline-disclosure.module.cjs +2 -0
  5. package/dist/components/_internal/inline-disclosure.module.js +9 -0
  6. package/dist/components/data-display/AvatarGroup/AvatarGroup.cjs +1 -1
  7. package/dist/components/data-display/AvatarGroup/AvatarGroup.d.ts +10 -3
  8. package/dist/components/data-display/AvatarGroup/AvatarGroup.js +55 -27
  9. package/dist/components/data-display/AvatarGroup/avatar-group.module.cjs +1 -1
  10. package/dist/components/data-display/AvatarGroup/avatar-group.module.js +8 -6
  11. package/dist/components/layout/OverflowList/OverflowList.cjs +2 -0
  12. package/dist/components/layout/OverflowList/OverflowList.d.ts +81 -0
  13. package/dist/components/layout/OverflowList/OverflowList.js +85 -0
  14. package/dist/components/layout/OverflowList/getVisibleCount.cjs +2 -0
  15. package/dist/components/layout/OverflowList/getVisibleCount.d.ts +30 -0
  16. package/dist/components/layout/OverflowList/getVisibleCount.js +26 -0
  17. package/dist/components/layout/OverflowList/overflow-list.module.cjs +2 -0
  18. package/dist/components/layout/OverflowList/overflow-list.module.js +10 -0
  19. package/dist/components/navigation/Breadcrumb/Breadcrumb.cjs +1 -1
  20. package/dist/components/navigation/Breadcrumb/Breadcrumb.d.ts +12 -0
  21. package/dist/components/navigation/Breadcrumb/Breadcrumb.js +88 -53
  22. package/dist/i18n/generated/components.d.ts +1 -1
  23. package/dist/i18n/generated/data-display.cjs +1 -1
  24. package/dist/i18n/generated/data-display.d.ts +1 -1
  25. package/dist/i18n/generated/data-display.js +12 -3
  26. package/dist/i18n/generated/keys.d.ts +2 -1
  27. package/dist/i18n/generated/navigation.cjs +2 -0
  28. package/dist/i18n/generated/navigation.d.ts +3 -0
  29. package/dist/i18n/generated/navigation.js +12 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.js +171 -170
  32. package/dist/layout.cjs +1 -1
  33. package/dist/layout.d.ts +1 -0
  34. package/dist/layout.js +2 -1
  35. package/dist/llms-full.txt +37 -3
  36. package/dist/llms.txt +2 -1
  37. package/dist/locales/en/components.json +2 -1
  38. package/dist/locales/en/data-display.json +3 -0
  39. package/dist/locales/ja/components.json +2 -1
  40. package/dist/locales/ja/data-display.json +3 -0
  41. package/dist/locales/pt/components.json +2 -1
  42. package/dist/locales/pt/data-display.json +3 -0
  43. package/dist/styles.css +1 -1
  44. package/dist/wimui.umd.css +1 -1
  45. package/dist/wimui.umd.js +5 -5
  46. package/package.json +30 -30
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("./useInlineFloating.cjs"),n=require("./inline-disclosure.module.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("classnames");i=e.__toESM(i,1);let a=require("react/jsx-runtime");var o=({trigger:e,label:o,triggerClassName:s,children:c})=>{let[l,u]=(0,r.useState)(!1),d=(0,r.useId)(),f=(0,r.useRef)(null),p=(0,r.useRef)(null),{setReference:m,setFloating:h,floatingProps:g}=t.useInlineFloating({open:l});return(0,r.useEffect)(()=>{if(!l)return;let e=e=>{f.current?.contains(e.target)||u(!1)},t=e=>{e.key===`Escape`&&f.current?.contains(document.activeElement)&&(e.stopPropagation(),u(!1),p.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[l]),(0,a.jsxs)(`span`,{ref:e=>{f.current=e,m(e)},className:n.default.root,onBlur:e=>{l&&!e.currentTarget.contains(e.relatedTarget)&&u(!1)},children:[(0,a.jsx)(`button`,{ref:p,type:`button`,className:(0,i.default)(n.default.trigger,s),"aria-label":o,"aria-expanded":l,"aria-controls":l?d:void 0,onClick:()=>u(e=>!e),children:e}),l&&(0,a.jsx)(`ul`,{id:d,ref:h,className:n.default.panel,...g,children:c})]})};exports.InlineDisclosure=o;
@@ -0,0 +1,22 @@
1
+ import { default as React } from 'react';
2
+ export type InlineDisclosureProps = {
3
+ /** ボタンの中身(「…」のアイコン・「+3」の文字など) */
4
+ trigger: React.ReactNode;
5
+ /** ボタンの読み上げの名前。中身の文字で名前が足りるなら渡さない */
6
+ label?: string;
7
+ /** ボタンに足すクラス(見た目は部品ごとに決める。押せる大きさの下限はこちらで持つ) */
8
+ triggerClassName?: string;
9
+ /** 一覧の中身。`<li>` を並べる */
10
+ children: React.ReactNode;
11
+ };
12
+ /**
13
+ * 隠れた項目を開くボタンと、その隣に描く一覧(disclosure: `aria-expanded` / `aria-controls`)。
14
+ * OverflowList の「+N」から、畳んだ項目へ届く道に使う(Breadcrumb・AvatarGroup)。
15
+ *
16
+ * Composition Contract:
17
+ * - Managed by: 部品の内側(OverflowList の renderOverflow の中)
18
+ * - Scroll lock: No
19
+ * - 一覧はポータルへ出さず、引き金の隣に描く(位置は useInlineFloating。floating-ui を読まない)
20
+ * - Escape・外側の押下・フォーカスが外へ出たときに閉じる。Escape ではボタンへフォーカスを戻す
21
+ */
22
+ export declare const InlineDisclosure: ({ trigger, label, triggerClassName, children }: InlineDisclosureProps) => React.JSX.Element;
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { useInlineFloating as e } from "./useInlineFloating.js";
3
+ import t from "./inline-disclosure.module.js";
4
+ import { useEffect as n, useId as r, useRef as i, useState as a } from "react";
5
+ import o from "classnames";
6
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ //#region src/components/_internal/InlineDisclosure.tsx
8
+ var l = ({ trigger: l, label: u, triggerClassName: d, children: f }) => {
9
+ let [p, m] = a(!1), h = r(), g = i(null), _ = i(null), { setReference: v, setFloating: y, floatingProps: b } = e({ open: p });
10
+ return n(() => {
11
+ if (!p) return;
12
+ let e = (e) => {
13
+ g.current?.contains(e.target) || m(!1);
14
+ }, t = (e) => {
15
+ e.key === "Escape" && g.current?.contains(document.activeElement) && (e.stopPropagation(), m(!1), _.current?.focus());
16
+ };
17
+ return document.addEventListener("pointerdown", e), document.addEventListener("keydown", t), () => {
18
+ document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", t);
19
+ };
20
+ }, [p]), /* @__PURE__ */ c("span", {
21
+ ref: (e) => {
22
+ g.current = e, v(e);
23
+ },
24
+ className: t.root,
25
+ onBlur: (e) => {
26
+ p && !e.currentTarget.contains(e.relatedTarget) && m(!1);
27
+ },
28
+ children: [/* @__PURE__ */ s("button", {
29
+ ref: _,
30
+ type: "button",
31
+ className: o(t.trigger, d),
32
+ "aria-label": u,
33
+ "aria-expanded": p,
34
+ "aria-controls": p ? h : void 0,
35
+ onClick: () => m((e) => !e),
36
+ children: l
37
+ }), p && /* @__PURE__ */ s("ul", {
38
+ id: h,
39
+ ref: y,
40
+ className: t.panel,
41
+ ...b,
42
+ children: f
43
+ })]
44
+ });
45
+ };
46
+ //#endregion
47
+ export { l as InlineDisclosure };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ var e=`_root_hquse_23`,t=`_trigger_hquse_27`,n=`_panel_hquse_64`,r={root:e,trigger:t,panel:n};exports.default=r,exports.panel=n,exports.root=e,exports.trigger=t;
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ //#region src/components/_internal/inline-disclosure.module.scss
3
+ var e = "_root_hquse_23", t = "_trigger_hquse_27", n = "_panel_hquse_64", r = {
4
+ root: e,
5
+ trigger: t,
6
+ panel: n
7
+ };
8
+ //#endregion
9
+ export { r as default, n as panel, e as root, t as trigger };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../Avatar/Avatar.cjs"),n=require("./avatar-group.module.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("classnames");i=e.__toESM(i,1);let a=require("react/jsx-runtime");var o=({children:e,max:o,size:s=`md`,total:c,className:l})=>{let u=r.default.Children.toArray(e),d=c||u.length,f=o?u.slice(0,o):u,p=d-f.length;return(0,a.jsxs)(`div`,{className:(0,i.default)(`wim-avatar-group`,n.default.root,l),children:[f.map((e,a)=>{if(r.default.isValidElement(e)){let o=e.type;if(o===t.Avatar||typeof o!=`string`&&o?.displayName===`Avatar`||typeof o!=`string`&&o?.name===`Avatar`){let t=e.props;return r.default.cloneElement(e,{size:s||t.size,className:(0,i.default)(t.className,n.default.avatar),key:a})}}return e}),p>0&&(0,a.jsxs)(`span`,{className:(0,i.default)(n.default.excess,n.default[s]),children:[`+`,p]})]})};o.displayName=`AvatarGroup`,exports.AvatarGroup=o;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../../layout/OverflowList/OverflowList.cjs"),i=require("../../_internal/InlineDisclosure.cjs"),a=require("../Avatar/Avatar.cjs"),o=require("../../../i18n/generated/data-display.cjs"),s=require("./avatar-group.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=e=>{if(!c.default.isValidElement(e))return!1;let t=e.type;return t===a.Avatar||typeof t!=`string`&&t?.displayName===`Avatar`||typeof t!=`string`&&t?.name===`Avatar`},f=({children:e,max:a,size:f=`md`,total:p,overflow:m=`count`,className:h})=>{let{t:g}=t.useWimTranslation(o.dataDisplayNs),_=c.default.Children.toArray(e),v=(e,t)=>d(e)?c.default.cloneElement(e,{size:f||e.props.size,className:(0,l.default)(e.props.className,s.default.avatar),key:t}):e;if(m===`collapse`)return(0,u.jsx)(r.OverflowList,{className:(0,l.default)(`wim-avatar-group`,s.default.collapse,h),gap:`0`,items:_,renderItem:v,renderOverflow:e=>(0,u.jsx)(i.InlineDisclosure,{triggerClassName:(0,l.default)(s.default.excess,s.default[f]),trigger:(0,u.jsxs)(u.Fragment,{children:[`+`,e.length,` `,(0,u.jsx)(n.VisuallyHidden,{children:g(`avatar_group.show_everyone`)})]}),children:e.map((e,t)=>{if(!d(e))return(0,u.jsx)(`li`,{children:e},t);let n=e.props.alt||e.props.initials||``;return(0,u.jsxs)(`li`,{className:s.default.person,children:[c.default.cloneElement(e,{size:`sm`,alt:``,"aria-hidden":!0}),(0,u.jsx)(`span`,{children:n})]},t)})})});let y=p||_.length,b=a?_.slice(0,a):_,x=y-b.length;return(0,u.jsxs)(`div`,{className:(0,l.default)(`wim-avatar-group`,s.default.root,h),children:[b.map(v),x>0&&(0,u.jsxs)(`span`,{className:(0,l.default)(s.default.excess,s.default[f]),children:[`+`,x]})]})};f.displayName=`AvatarGroup`,exports.AvatarGroup=f;
@@ -3,12 +3,19 @@ import { ComponentSizeBasic } from '../../../types/tokens';
3
3
  type AvatarGroupProps = {
4
4
  /** Avatar elements to group */
5
5
  children: React.ReactNode;
6
- /** Maximum number of avatars to show before collapsing into a count */
6
+ /** Maximum number of avatars to show before collapsing into a count. Ignored with `overflow="collapse"`. */
7
7
  max?: number;
8
8
  /** Size applied to the avatars */
9
9
  size?: ComponentSizeBasic;
10
- /** Total number of avatars (used to compute the overflow count) */
10
+ /** Total number of avatars (used to compute the overflow count). Ignored with `overflow="collapse"`. */
11
11
  total?: number;
12
+ /**
13
+ * How the avatars that do not fit are handled. `"count"` cuts them by `max` / `total` and shows
14
+ * "+N" as text; `"collapse"` shows as many as fit the width and turns "+N" into a button that
15
+ * lists the hidden people by name.
16
+ * @default "count"
17
+ */
18
+ overflow?: "count" | "collapse";
12
19
  /** Additional class names */
13
20
  className?: string;
14
21
  };
@@ -16,7 +23,7 @@ type AvatarGroupProps = {
16
23
  * Component for displaying multiple avatars bundled together.
17
24
  */
18
25
  export declare const AvatarGroup: {
19
- ({ children, max, size, total, className, }: AvatarGroupProps): React.JSX.Element;
26
+ ({ children, max, size, total, overflow, className, }: AvatarGroupProps): React.JSX.Element;
20
27
  displayName: string;
21
28
  };
22
29
  export {};
@@ -1,33 +1,61 @@
1
1
  "use client";
2
- import { Avatar as e } from "../Avatar/Avatar.js";
3
- import t from "./avatar-group.module.js";
4
- import n from "react";
5
- import r from "classnames";
6
- import { jsxs as i } from "react/jsx-runtime";
2
+ import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
3
+ import { VisuallyHidden as t } from "../../layout/VisuallyHidden/VisuallyHidden.js";
4
+ import { OverflowList as n } from "../../layout/OverflowList/OverflowList.js";
5
+ import { InlineDisclosure as r } from "../../_internal/InlineDisclosure.js";
6
+ import { Avatar as i } from "../Avatar/Avatar.js";
7
+ import { dataDisplayNs as a } from "../../../i18n/generated/data-display.js";
8
+ import o from "./avatar-group.module.js";
9
+ import s from "react";
10
+ import c from "classnames";
11
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
7
12
  //#region src/components/data-display/AvatarGroup/AvatarGroup.tsx
8
- var a = ({ children: a, max: o, size: s = "md", total: c, className: l }) => {
9
- let u = n.Children.toArray(a), d = c || u.length, f = o ? u.slice(0, o) : u, p = d - f.length;
10
- return /* @__PURE__ */ i("div", {
11
- className: r("wim-avatar-group", t.root, l),
12
- children: [f.map((i, a) => {
13
- if (n.isValidElement(i)) {
14
- let o = i.type;
15
- if (o === e || typeof o != "string" && o?.displayName === "Avatar" || typeof o != "string" && o?.name === "Avatar") {
16
- let e = i.props;
17
- return n.cloneElement(i, {
18
- size: s || e.size,
19
- className: r(e.className, t.avatar),
20
- key: a
21
- });
22
- }
23
- }
24
- return i;
25
- }), p > 0 && /* @__PURE__ */ i("span", {
26
- className: r(t.excess, t[s]),
27
- children: ["+", p]
13
+ var f = (e) => {
14
+ if (!s.isValidElement(e)) return !1;
15
+ let t = e.type;
16
+ return t === i || typeof t != "string" && t?.displayName === "Avatar" || typeof t != "string" && t?.name === "Avatar";
17
+ }, p = ({ children: i, max: p, size: m = "md", total: h, overflow: g = "count", className: _ }) => {
18
+ let { t: v } = e(a), y = s.Children.toArray(i), b = (e, t) => f(e) ? s.cloneElement(e, {
19
+ size: m || e.props.size,
20
+ className: c(e.props.className, o.avatar),
21
+ key: t
22
+ }) : e;
23
+ if (g === "collapse") return /* @__PURE__ */ u(n, {
24
+ className: c("wim-avatar-group", o.collapse, _),
25
+ gap: "0",
26
+ items: y,
27
+ renderItem: b,
28
+ renderOverflow: (e) => /* @__PURE__ */ u(r, {
29
+ triggerClassName: c(o.excess, o[m]),
30
+ trigger: /* @__PURE__ */ d(l, { children: [
31
+ "+",
32
+ e.length,
33
+ " ",
34
+ /* @__PURE__ */ u(t, { children: v("avatar_group.show_everyone") })
35
+ ] }),
36
+ children: e.map((e, t) => {
37
+ if (!f(e)) return /* @__PURE__ */ u("li", { children: e }, t);
38
+ let n = e.props.alt || e.props.initials || "";
39
+ return /* @__PURE__ */ d("li", {
40
+ className: o.person,
41
+ children: [s.cloneElement(e, {
42
+ size: "sm",
43
+ alt: "",
44
+ "aria-hidden": !0
45
+ }), /* @__PURE__ */ u("span", { children: n })]
46
+ }, t);
47
+ })
48
+ })
49
+ });
50
+ let x = h || y.length, S = p ? y.slice(0, p) : y, C = x - S.length;
51
+ return /* @__PURE__ */ d("div", {
52
+ className: c("wim-avatar-group", o.root, _),
53
+ children: [S.map(b), C > 0 && /* @__PURE__ */ d("span", {
54
+ className: c(o.excess, o[m]),
55
+ children: ["+", C]
28
56
  })]
29
57
  });
30
58
  };
31
- a.displayName = "AvatarGroup";
59
+ p.displayName = "AvatarGroup";
32
60
  //#endregion
33
- export { a as AvatarGroup };
61
+ export { p as AvatarGroup };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_root_1mpz7_2`,t=`_avatar_1mpz7_7`,n=`_excess_1mpz7_13`,r=`_sm_1mpz7_22`,i=`_md_1mpz7_25`,a=`_lg_1mpz7_28`,o={root:e,avatar:t,excess:n,sm:r,md:i,lg:a};exports.avatar=t,exports.default=o,exports.excess=n,exports.lg=a,exports.md=i,exports.root=e,exports.sm=r;
2
+ var e=`_root_zjd50_2`,t=`_avatar_zjd50_7`,n=`_collapse_zjd50_8`,r=`_excess_zjd50_15`,i=`_sm_zjd50_24`,a=`_md_zjd50_27`,o=`_lg_zjd50_30`,s=`_person_zjd50_33`,c={root:e,avatar:t,collapse:n,excess:r,sm:i,md:a,lg:o,person:s};exports.avatar=t,exports.collapse=n,exports.default=c,exports.excess=r,exports.lg=o,exports.md=a,exports.person=s,exports.root=e,exports.sm=i;
@@ -1,12 +1,14 @@
1
1
  "use client";
2
2
  //#region src/components/data-display/AvatarGroup/avatar-group.module.scss
3
- var e = "_root_1mpz7_2", t = "_avatar_1mpz7_7", n = "_excess_1mpz7_13", r = "_sm_1mpz7_22", i = "_md_1mpz7_25", a = "_lg_1mpz7_28", o = {
3
+ var e = "_root_zjd50_2", t = "_avatar_zjd50_7", n = "_collapse_zjd50_8", r = "_excess_zjd50_15", i = "_sm_zjd50_24", a = "_md_zjd50_27", o = "_lg_zjd50_30", s = "_person_zjd50_33", c = {
4
4
  root: e,
5
5
  avatar: t,
6
- excess: n,
7
- sm: r,
8
- md: i,
9
- lg: a
6
+ collapse: n,
7
+ excess: r,
8
+ sm: i,
9
+ md: a,
10
+ lg: o,
11
+ person: s
10
12
  };
11
13
  //#endregion
12
- export { t as avatar, o as default, n as excess, a as lg, i as md, e as root, r as sm };
14
+ export { t as avatar, n as collapse, c as default, r as excess, o as lg, a as md, s as person, e as root, i as sm };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../utilities/style-utils.cjs"),r=require("../../../hooks/useMergedRef.cjs"),i=require("./getVisibleCount.cjs"),a=require("./overflow-list.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=o.default.forwardRef(({items:e,renderItem:l,renderOverflow:u,collapseFrom:d=`end`,minVisibleItems:f=0,alwaysRenderOverflow:p=!1,onOverflow:m,gap:h=`sm`,listElement:g,asChild:_=!1,className:v,style:y,children:b,...x},S)=>{let C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=r.useMergedRef(S,C),[E,D]=(0,o.useState)(e.length),O=(0,o.useCallback)(()=>{let t=C.current,n=w.current;if(!t||!n)return;let r=getComputedStyle(t),a=t.clientWidth-(parseFloat(r.paddingLeft)||0)-(parseFloat(r.paddingRight)||0),o=parseFloat(getComputedStyle(n).columnGap)||0,s=e=>{let t=getComputedStyle(e);return e.getBoundingClientRect().width+(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0)},c=Array.from(n.children),l=c.slice(0,e.length).map(s),u=c[e.length]?s(c[e.length]):0,m=i.pinnedCount(d,l.length),h=l.slice(0,m).reduce((e,t)=>e+t+o,0),g=l.slice(m),_=m+i.getVisibleCount({itemWidths:d===`end`?g:[...g].reverse(),overflowWidth:u,available:a-h,gap:o,minVisibleItems:Math.max(f-m,0),alwaysRenderOverflow:p});D(e=>e===_?e:_)},[e.length,d,f,p]);(0,o.useLayoutEffect)(O),(0,o.useEffect)(()=>{let e=C.current,t=w.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>O());return n.observe(e),n.observe(t),()=>n.disconnect()},[O]);let{visible:k,hidden:A,overflowAt:j}=i.splitItems(d,e.length,E),M=A.length,N=A.map(t=>e[t]),P=M>0||p,F=(0,o.useRef)(m);(0,o.useLayoutEffect)(()=>{F.current=m});let I=(0,o.useRef)(null);(0,o.useEffect)(()=>{let t=I.current;t&&t.items===e&&t.count===M&&t.from===d||(I.current={items:e,count:M,from:d},(t||M!==0)&&F.current?.(i.splitItems(d,e.length,e.length-M).hidden.map(t=>e[t])))},[e,M,d]);let L=P?(0,c.jsx)(o.default.Fragment,{children:u(N)},`overflow`):null,R=g??`div`,z=k.map(t=>(0,c.jsx)(o.default.Fragment,{children:l(e[t],t)},t)),B=k.filter(e=>e<j).length;z.splice(B,0,L);let V=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(R,{className:a.default.row,children:z}),(0,c.jsx)(`div`,{className:a.default.measure,"aria-hidden":`true`,inert:!0,children:(0,c.jsxs)(R,{ref:w,className:a.default.measureRow,children:[e.map((e,t)=>(0,c.jsx)(o.default.Fragment,{children:l(e,t)},t)),u(e)]})})]});return(0,c.jsxs)(_?t.Root:`div`,{ref:T,className:(0,s.default)(`wim-overflow-list`,a.default.root,v),"data-collapse-from":d,"data-hidden-count":M,...x,style:{...y,"--wim-overflow-list-gap":n.getSpacingValue(h)},children:[V,_?(0,c.jsx)(t.Slottable,{children:b}):null]})});l.displayName=`OverflowList`,exports.OverflowList=l;
@@ -0,0 +1,81 @@
1
+ import { default as React } from 'react';
2
+ import { WimSpacing } from '../../../types/tokens';
3
+ import { CollapseFrom } from './getVisibleCount';
4
+ export type OverflowListProps<T> = Omit<React.ComponentPropsWithoutRef<"div">, "children"> & {
5
+ /**
6
+ * Items to lay out in a single row, in reading order.
7
+ */
8
+ items: T[];
9
+ /**
10
+ * Renders one item. Return a single element: each top-level element is measured as one item.
11
+ */
12
+ renderItem: (item: T, index: number) => React.ReactNode;
13
+ /**
14
+ * Renders the overflow indicator from the items that did not fit (for example a "+N" button
15
+ * that opens a Popover listing them). Return a single element. Not rendered while every item
16
+ * fits, unless `alwaysRenderOverflow` is set. The hidden items are not in the DOM, so the
17
+ * indicator is how users — including keyboard and screen reader users — reach them.
18
+ */
19
+ renderOverflow: (hiddenItems: T[]) => React.ReactNode;
20
+ /**
21
+ * The side items are collapsed from. `"end"` keeps the first items (tags, toolbars);
22
+ * `"start"` keeps the last ones (a path keeps the current folder); `"middle"` keeps the first
23
+ * item and collapses from the second one, with the indicator right after the first item
24
+ * (a breadcrumb keeps its root and the current page).
25
+ * @default "end"
26
+ */
27
+ collapseFrom?: CollapseFrom;
28
+ /**
29
+ * Renders the row as a list. `renderItem` and `renderOverflow` must then return `<li>`
30
+ * elements. Without it, the row is a `div`, which a list may not contain.
31
+ */
32
+ listElement?: "ul" | "ol";
33
+ /**
34
+ * Items that stay visible however narrow the row gets. They may then overflow the row.
35
+ * @default 0
36
+ */
37
+ minVisibleItems?: number;
38
+ /**
39
+ * Renders the overflow indicator even when every item fits (it receives an empty array).
40
+ * @default false
41
+ */
42
+ alwaysRenderOverflow?: boolean;
43
+ /**
44
+ * Called with the hidden items whenever the set of hidden items changes.
45
+ */
46
+ onOverflow?: (hiddenItems: T[]) => void;
47
+ /**
48
+ * Gap between items: a spacing token name (`"sm"`, `"md"`, …).
49
+ * @default "sm"
50
+ */
51
+ gap?: WimSpacing;
52
+ /**
53
+ * If true, the list will be rendered as its child, merging its props onto that child.
54
+ */
55
+ asChild?: boolean;
56
+ /**
57
+ * The element that becomes the root (in place of `div`) when `asChild` is set. The items are
58
+ * rendered inside it. Ignored without `asChild`.
59
+ */
60
+ children?: React.ReactNode;
61
+ };
62
+ /**
63
+ * Lays out items in a single row and collapses the ones that do not fit into an overflow
64
+ * indicator ("+N"), recomputed whenever the row or an item changes width. It measures and
65
+ * collapses; what the indicator shows (a count, a Popover, a Menu) is up to `renderOverflow`.
66
+ *
67
+ * The list fills its container. Its own minimum width is 0 and its preferred width is every item
68
+ * in one row, whatever is folded at the moment, so it also folds inside a table cell or an
69
+ * inline-block and grows back when there is room.
70
+ *
71
+ * Composition Contract:
72
+ * - Managed by: App consumption
73
+ * - Scroll lock: No
74
+ * - Does not own the hidden items' disclosure — compose Popover / Menu in `renderOverflow`
75
+ * - Renders each item twice: once visible, once in an invisible, inert measuring layer
76
+ */
77
+ export declare const OverflowList: (<T>(props: OverflowListProps<T> & {
78
+ ref?: React.ForwardedRef<HTMLDivElement>;
79
+ }) => React.ReactElement) & {
80
+ displayName?: string;
81
+ };
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
3
+ import { getSpacingValue as n } from "../../../utilities/style-utils.js";
4
+ import { useMergedRef as r } from "../../../hooks/useMergedRef.js";
5
+ import { getVisibleCount as i, pinnedCount as a, splitItems as o } from "./getVisibleCount.js";
6
+ import s from "./overflow-list.module.js";
7
+ import c, { useCallback as l, useEffect as u, useLayoutEffect as d, useRef as f, useState as p } from "react";
8
+ import m from "classnames";
9
+ import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
10
+ var v = c.forwardRef(({ items: v, renderItem: y, renderOverflow: b, collapseFrom: x = "end", minVisibleItems: S = 0, alwaysRenderOverflow: C = !1, onOverflow: w, gap: T = "sm", listElement: E, asChild: D = !1, className: O, style: k, children: A, ...j }, M) => {
11
+ let N = f(null), P = f(null), F = r(M, N), [I, L] = p(v.length), R = l(() => {
12
+ let e = N.current, t = P.current;
13
+ if (!e || !t) return;
14
+ let n = getComputedStyle(e), r = e.clientWidth - (parseFloat(n.paddingLeft) || 0) - (parseFloat(n.paddingRight) || 0), o = parseFloat(getComputedStyle(t).columnGap) || 0, s = (e) => {
15
+ let t = getComputedStyle(e);
16
+ return e.getBoundingClientRect().width + (parseFloat(t.marginLeft) || 0) + (parseFloat(t.marginRight) || 0);
17
+ }, c = Array.from(t.children), l = c.slice(0, v.length).map(s), u = c[v.length] ? s(c[v.length]) : 0, d = a(x, l.length), f = l.slice(0, d).reduce((e, t) => e + t + o, 0), p = l.slice(d), m = d + i({
18
+ itemWidths: x === "end" ? p : [...p].reverse(),
19
+ overflowWidth: u,
20
+ available: r - f,
21
+ gap: o,
22
+ minVisibleItems: Math.max(S - d, 0),
23
+ alwaysRenderOverflow: C
24
+ });
25
+ L((e) => e === m ? e : m);
26
+ }, [
27
+ v.length,
28
+ x,
29
+ S,
30
+ C
31
+ ]);
32
+ d(R), u(() => {
33
+ let e = N.current, t = P.current;
34
+ if (!e || !t || typeof ResizeObserver > "u") return;
35
+ let n = new ResizeObserver(() => R());
36
+ return n.observe(e), n.observe(t), () => n.disconnect();
37
+ }, [R]);
38
+ let { visible: z, hidden: B, overflowAt: V } = o(x, v.length, I), H = B.length, U = B.map((e) => v[e]), W = H > 0 || C, G = f(w);
39
+ d(() => {
40
+ G.current = w;
41
+ });
42
+ let K = f(null);
43
+ u(() => {
44
+ let e = K.current;
45
+ e && e.items === v && e.count === H && e.from === x || (K.current = {
46
+ items: v,
47
+ count: H,
48
+ from: x
49
+ }, (e || H !== 0) && G.current?.(o(x, v.length, v.length - H).hidden.map((e) => v[e])));
50
+ }, [
51
+ v,
52
+ H,
53
+ x
54
+ ]);
55
+ let q = W ? /* @__PURE__ */ g(c.Fragment, { children: b(U) }, "overflow") : null, J = E ?? "div", Y = z.map((e) => /* @__PURE__ */ g(c.Fragment, { children: y(v[e], e) }, e)), X = z.filter((e) => e < V).length;
56
+ Y.splice(X, 0, q);
57
+ let Z = /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(J, {
58
+ className: s.row,
59
+ children: Y
60
+ }), /* @__PURE__ */ g("div", {
61
+ className: s.measure,
62
+ "aria-hidden": "true",
63
+ inert: !0,
64
+ children: /* @__PURE__ */ _(J, {
65
+ ref: P,
66
+ className: s.measureRow,
67
+ children: [v.map((e, t) => /* @__PURE__ */ g(c.Fragment, { children: y(e, t) }, t)), b(v)]
68
+ })
69
+ })] });
70
+ return /* @__PURE__ */ _(D ? e : "div", {
71
+ ref: F,
72
+ className: m("wim-overflow-list", s.root, O),
73
+ "data-collapse-from": x,
74
+ "data-hidden-count": H,
75
+ ...j,
76
+ style: {
77
+ ...k,
78
+ "--wim-overflow-list-gap": n(T)
79
+ },
80
+ children: [Z, D ? /* @__PURE__ */ g(t, { children: A }) : null]
81
+ });
82
+ });
83
+ v.displayName = "OverflowList";
84
+ //#endregion
85
+ export { v as OverflowList };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ var e=.5,t=(e,t)=>e===`middle`?Math.min(1,t):0,n=(e,n,r)=>{let i=t(e,n),a=Math.min(Math.max(r,i),n),o=n-a,s=(e,t)=>Array.from({length:Math.max(t-e,0)},(t,n)=>e+n);return e===`end`?{visible:s(0,a),hidden:s(a,n),overflowAt:a}:{visible:[...s(0,i),...s(i+o,n)],hidden:s(i,i+o),overflowAt:i}},r=({itemWidths:t,overflowWidth:n,available:r,gap:i,minVisibleItems:a,alwaysRenderOverflow:o})=>{let s=t.length,c=Math.min(Math.max(a,0),s);if(!o&&(e=>e.reduce((e,t,n)=>e+t+(n>0?i:0),0))(t)<=r+e)return s;let l=n,u=0;for(let n of t){let t=l+i+n;if(t>r+e)break;l=t,u+=1}return Math.max(u,c)};exports.getVisibleCount=r,exports.pinnedCount=t,exports.splitItems=n;
@@ -0,0 +1,30 @@
1
+ type VisibleCountInput = {
2
+ /** 各項目の幅。残す側の端から並べる(`collapseFrom="end"` なら先頭から) */
3
+ itemWidths: number[];
4
+ /** 「+N」の幅 */
5
+ overflowWidth: number;
6
+ /** 並びに使える幅 */
7
+ available: number;
8
+ gap: number;
9
+ minVisibleItems: number;
10
+ alwaysRenderOverflow: boolean;
11
+ };
12
+ export type CollapseFrom = "start" | "end" | "middle";
13
+ /** `"middle"` のとき、畳まずに残す先頭の項目の数 */
14
+ export declare const pinnedCount: (collapseFrom: CollapseFrom, total: number) => number;
15
+ /**
16
+ * 見えている項目の数(`shown`)から、並べる順(項目の添字と「+N」の位置)と、畳んだ項目の添字を出す。
17
+ * - `"end"`: 先頭から見せ、「+N」は末尾
18
+ * - `"start"`: 末尾から見せ、「+N」は先頭
19
+ * - `"middle"`: 先頭の 1 つを残し、2 つ目から畳む。「+N」は先頭のすぐ後ろ
20
+ */
21
+ export declare const splitItems: (collapseFrom: CollapseFrom, total: number, shown: number) => {
22
+ visible: number[];
23
+ hidden: number[];
24
+ overflowAt: number;
25
+ };
26
+ /**
27
+ * 収まる項目の数。バレルには載せない(OverflowList の中だけで使う計算)。
28
+ */
29
+ export declare const getVisibleCount: ({ itemWidths, overflowWidth, available, gap, minVisibleItems, alwaysRenderOverflow, }: VisibleCountInput) => number;
30
+ export {};
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ //#region src/components/layout/OverflowList/getVisibleCount.ts
3
+ var e = .5, t = (e, t) => e === "middle" ? Math.min(1, t) : 0, n = (e, n, r) => {
4
+ let i = t(e, n), a = Math.min(Math.max(r, i), n), o = n - a, s = (e, t) => Array.from({ length: Math.max(t - e, 0) }, (t, n) => e + n);
5
+ return e === "end" ? {
6
+ visible: s(0, a),
7
+ hidden: s(a, n),
8
+ overflowAt: a
9
+ } : {
10
+ visible: [...s(0, i), ...s(i + o, n)],
11
+ hidden: s(i, i + o),
12
+ overflowAt: i
13
+ };
14
+ }, r = ({ itemWidths: t, overflowWidth: n, available: r, gap: i, minVisibleItems: a, alwaysRenderOverflow: o }) => {
15
+ let s = t.length, c = Math.min(Math.max(a, 0), s);
16
+ if (!o && ((e) => e.reduce((e, t, n) => e + t + (n > 0 ? i : 0), 0))(t) <= r + e) return s;
17
+ let l = n, u = 0;
18
+ for (let n of t) {
19
+ let t = l + i + n;
20
+ if (t > r + e) break;
21
+ l = t, u += 1;
22
+ }
23
+ return Math.max(u, c);
24
+ };
25
+ //#endregion
26
+ export { r as getVisibleCount, t as pinnedCount, n as splitItems };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ var e=`_root_sh3ee_2`,t=`_row_sh3ee_10`,n=`_measureRow_sh3ee_11`,r=`_measure_sh3ee_11`,i={root:e,row:t,measureRow:n,measure:r};exports.default=i,exports.measure=r,exports.measureRow=n,exports.root=e,exports.row=t;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ //#region src/components/layout/OverflowList/overflow-list.module.scss
3
+ var e = "_root_sh3ee_2", t = "_row_sh3ee_10", n = "_measureRow_sh3ee_11", r = "_measure_sh3ee_11", i = {
4
+ root: e,
5
+ row: t,
6
+ measureRow: n,
7
+ measure: r
8
+ };
9
+ //#endregion
10
+ export { i as default, r as measure, n as measureRow, e as root, t as row };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../i18n/generated/common.cjs"),i=require("../../../icon/chevron-right.cjs"),a=require("../../media/Icon/Icon.cjs"),o=require("./breadcrumb.module.cjs"),s=require("../Link/Link.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=(0,c.forwardRef)(({items:e,separator:c,size:d=`md`,className:f,ariaLabel:p,asChild:m,children:h,...g},_)=>{let{t:v}=n.useWimTranslation(r.commonNs),y=p??v(`a11y.breadcrumb`),b=m?t.Root:`nav`,x=(0,u.jsx)(a.Icon,{component:i.default,size:d,className:o.default.separatorIcon});return(0,u.jsxs)(b,{ref:_,"aria-label":y,className:(0,l.default)(`wim-breadcrumb`,o.default.root,o.default[d],f),onKeyDown:e=>{let t=e.currentTarget,n=Array.from(t.querySelectorAll(`.${o.default.link}, .${o.default.label}.${o.default.current}`)),r=n.indexOf(document.activeElement);r!==-1&&(e.key===`ArrowRight`?(e.preventDefault(),n[(r+1)%n.length].focus()):e.key===`ArrowLeft`&&(e.preventDefault(),n[(r-1+n.length)%n.length].focus()))},...g,children:[(0,u.jsx)(`ol`,{className:o.default.list,children:e.map((t,n)=>{let r=n===e.length-1;return(0,u.jsxs)(`li`,{className:o.default.item,children:[(0,u.jsx)(`div`,{className:o.default.content,children:t.href&&!r?(0,u.jsx)(s.Link,{href:t.href,size:d,priority:`secondary`,iconName:t.iconName,className:o.default.link,styles:{label:o.default.linkLabel},children:t.label}):(0,u.jsxs)(`span`,{className:(0,l.default)(o.default.label,r&&o.default.current),"aria-current":r?`page`:void 0,tabIndex:r?0:void 0,role:r?`link`:void 0,children:[t.iconName&&(0,u.jsx)(a.Icon,{name:t.iconName,size:d,className:o.default.labelIcon}),t.label]})}),!r&&(0,u.jsx)(`span`,{className:o.default.separator,"aria-hidden":`true`,children:c||x})]},n)})}),m?(0,u.jsx)(t.Slottable,{children:h}):null]})});d.displayName=`Breadcrumb`,exports.Breadcrumb=d;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../i18n/generated/common.cjs"),i=require("../../../icon/chevron-right.cjs"),a=require("../../../icon/more-horizontal.cjs"),o=require("../../media/Icon/Icon.cjs"),s=require("../../layout/OverflowList/OverflowList.cjs"),c=require("../../../i18n/generated/navigation.cjs"),l=require("./breadcrumb.module.cjs"),u=require("../Link/Link.cjs"),d=require("../../_internal/InlineDisclosure.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("classnames");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=(0,f.forwardRef)(({items:e,separator:f,size:h=`md`,overflow:g=`wrap`,moreLabel:_,className:v,ariaLabel:y,asChild:b,children:x,...S},C)=>{let{t:w}=n.useWimTranslation([r.commonNs,c.navigationNs]),T=y??w(`a11y.breadcrumb`),E=b?t.Root:`nav`,D=(0,m.jsx)(o.Icon,{component:i.default,size:h,className:l.default.separatorIcon}),O=(t,n)=>{let r=n===e.length-1;return(0,m.jsxs)(`li`,{className:l.default.item,children:[(0,m.jsx)(`div`,{className:l.default.content,children:t.href&&!r?(0,m.jsx)(u.Link,{href:t.href,size:h,priority:`secondary`,iconName:t.iconName,className:l.default.link,styles:{label:l.default.linkLabel},children:t.label}):(0,m.jsxs)(`span`,{className:(0,p.default)(l.default.label,r&&l.default.current),"aria-current":r?`page`:void 0,tabIndex:r?0:void 0,role:r?`link`:void 0,children:[t.iconName&&(0,m.jsx)(o.Icon,{name:t.iconName,size:h,className:l.default.labelIcon}),t.label]})}),!r&&(0,m.jsx)(`span`,{className:l.default.separator,"aria-hidden":`true`,children:f||D})]},n)};return(0,m.jsxs)(E,{ref:C,"aria-label":T,className:(0,p.default)(`wim-breadcrumb`,l.default.root,l.default[h],v),onKeyDown:e=>{let t=e.currentTarget,n=Array.from(t.querySelectorAll(`.${l.default.link}, .${l.default.label}.${l.default.current}, button[aria-expanded]`)).filter(e=>!e.closest(`[aria-hidden="true"]`)),r=n.indexOf(document.activeElement);r!==-1&&(e.key===`ArrowRight`?(e.preventDefault(),n[(r+1)%n.length].focus()):e.key===`ArrowLeft`&&(e.preventDefault(),n[(r-1+n.length)%n.length].focus()))},...S,children:[g===`collapse`?(0,m.jsx)(s.OverflowList,{listElement:`ol`,collapseFrom:`middle`,minVisibleItems:Math.min(e.length,2),gap:`0`,items:e,renderItem:(e,t)=>O(e,t),renderOverflow:e=>(0,m.jsxs)(`li`,{className:l.default.item,children:[(0,m.jsx)(d.InlineDisclosure,{trigger:(0,m.jsx)(o.Icon,{component:a.default,size:h}),label:(_??(e=>w(`a11y.breadcrumb_more`,{count:e})))(e.length),children:e.map((e,t)=>(0,m.jsx)(`li`,{children:e.href?(0,m.jsx)(u.Link,{href:e.href,size:h,priority:`secondary`,iconName:e.iconName,children:e.label}):(0,m.jsx)(`span`,{className:l.default.label,children:e.label})},t))}),(0,m.jsx)(`span`,{className:l.default.separator,"aria-hidden":`true`,children:f||D})]})}):(0,m.jsx)(`ol`,{className:l.default.list,children:e.map((e,t)=>O(e,t))}),b?(0,m.jsx)(t.Slottable,{children:x}):null]})});h.displayName=`Breadcrumb`,exports.Breadcrumb=h;
@@ -20,6 +20,18 @@ type BreadcrumbProps = {
20
20
  * @default "md"
21
21
  */
22
22
  size?: ComponentSizeBasic;
23
+ /**
24
+ * What happens when the items do not fit on one line. `"wrap"` moves them onto more lines;
25
+ * `"collapse"` keeps the first item and the current page and folds the levels in between
26
+ * into a "…" button that lists them.
27
+ * @default "wrap"
28
+ */
29
+ overflow?: "wrap" | "collapse";
30
+ /**
31
+ * Accessible name of the "…" button, from the number of hidden levels. Defaults to a localized
32
+ * "Show hidden levels (n)".
33
+ */
34
+ moreLabel?: (count: number) => string;
23
35
  /**
24
36
  * Additional CSS class name for the container.
25
37
  */