@smwb/ui-react 2.6.0 → 2.6.2

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.
@@ -1 +1 @@
1
- .smwb-table{width:100%;white-space:nowrap;border-collapse:collapse;overflow:scroll}.smwb-table.smwb-hovered tbody tr:hover{background:var(--smui-onSurfaceHover);cursor:pointer}.smwb-table__error{margin-bottom:10px}.smwb-table__container{display:flex;overflow-x:auto;border:1px solid var(--smui-tableBorderColor);border-radius:4px;flex-direction:column}.smwb-table__container.smwb-withPagination{border-radius:4px 4px 0 0}.smwb-table__wrapper{display:flex;flex-direction:column;background-color:var(--smui-surfaceBackground)}.smwb-table__wrapper_loading{pointer-events:none}.smwb-table__cell{position:relative;-webkit-line-clamp:1;-webkit-box-orient:vertical;text-overflow:ellipsis;white-space:nowrap;padding:0 16px;height:52px;vertical-align:middle;overflow:hidden;word-wrap:break-word}.smwb-table__cell.smwb-head-cell{height:56px;text-align:left;font-weight:500}.smwb-table__cell.smwb-head-cell.smwb-sortable{cursor:pointer}.smwb-table__cell.smwb-head-cell .smwb-head-cell__content{align-items:center;display:inline-flex;vertical-align:middle;gap:5px;user-select:none}.smwb-table__cell.smwb-head-cell .smwb-head-cell__content input{font-weight:500}.smwb-table__cell.smwb-head-cell.smwb-align_left{text-align:left}.smwb-table__cell.smwb-head-cell.smwb-align_center{text-align:center}.smwb-table__cell.smwb-head-cell.smwb-align_right{text-align:right}.smwb-table__cell.smwb-head-cell .smwb-head-cell__icon{flex-shrink:0;display:none;transition:all .15s ease-in-out;fill:var(--smui-primaryTextColor)}.smwb-table__cell.smwb-head-cell.smwb-sorted_asc .smwb-head-cell__icon{display:inline-flex;transform:rotate(0)}.smwb-table__cell.smwb-head-cell.smwb-sorted_desc .smwb-head-cell__icon{display:inline-flex;transform:rotate(180deg)}.smwb-table__head .smwb-table__row{border-top:none}.smwb-table__row{border-top:1px solid var(--smui-tableBorderColor)}.smwb-table.smwb-dense .smwb-table__cell{padding:0 16px;height:36px;vertical-align:middle}.smwb-table.smwb-dense .smwb-table__cell.smwb-head-cell{height:40px}.smwb-table.smwb-dense .smwb-table__row{border-top:1px solid var(--smui-tableBorderColor)}.smwb-table__loader{width:100%;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;top:50%;left:50%;transform:translate(-50%,-50%)}.smwb-table__loader__row{height:100px;position:relative}.smwb-scrollbar::-webkit-scrollbar-thumb{background-color:var(--smui-scrollThumbColor);border-radius:999px}.smwb-scrollbar::-webkit-scrollbar{width:6px;height:6px}.smwb-scrollbar::-webkit-scrollbar-track{background-color:transparent}.smwb-head-cell_sortable .smwb-head-cell__content{cursor:pointer;user-select:none;outline:none}.smwb-head-cell_sortable .smwb-head-cell__content:focus-visible{outline:2px solid var(--smui-primaryColor);outline-offset:2px}.smwb-table__row_selected{background-color:var(--smui-onSurfaceHover)}.smwb-table__caption{caption-side:top;text-align:left;padding:8px 12px;color:var(--smui-onSurfaceVariant)}.smwb-table_sticky-header{overflow:visible}.smwb-table__container:has(.smwb-table_sticky-header){overflow:visible}.smwb-table_sticky-header .smwb-table__head .smwb-table__cell{position:sticky;top:0;z-index:2;background-color:var(--smui-surfaceBackground)}
1
+ .smwb-table{width:100%;white-space:nowrap;border-collapse:collapse;overflow:scroll}.smwb-table.smwb-hovered tbody tr:hover{background:var(--smui-onSurfaceHover);cursor:pointer}.smwb-table__error{margin-bottom:10px}.smwb-table__container{display:flex;overflow-x:auto;border:1px solid var(--smui-tableBorderColor);border-radius:4px;flex-direction:column}.smwb-table__container.smwb-withPagination{border-radius:4px 4px 0 0}.smwb-table__wrapper{display:flex;flex-direction:column;background-color:var(--smui-surfaceBackground)}.smwb-table__wrapper_loading{pointer-events:none}.smwb-table__cell{position:relative;-webkit-line-clamp:1;-webkit-box-orient:vertical;text-overflow:ellipsis;white-space:nowrap;padding:0 16px;height:52px;vertical-align:middle;overflow:hidden;word-wrap:break-word}.smwb-table__cell.smwb-head-cell{height:56px;text-align:left;font-weight:500}.smwb-table__cell.smwb-head-cell.smwb-sortable,.smwb-table__cell.smwb-head-cell.smwb-head-cell_sortable{cursor:pointer}.smwb-table__cell.smwb-head-cell .smwb-head-cell__content{align-items:center;display:inline-flex;vertical-align:middle;gap:5px;user-select:none}.smwb-table__cell.smwb-head-cell .smwb-head-cell__content input{font-weight:500}.smwb-table__cell.smwb-head-cell.smwb-align_left{text-align:left}.smwb-table__cell.smwb-head-cell.smwb-align_center{text-align:center}.smwb-table__cell.smwb-head-cell.smwb-align_right{text-align:right}.smwb-table__cell.smwb-head-cell .smwb-head-cell__icon{flex-shrink:0;transition:opacity .15s ease-in-out;opacity:.4}.smwb-table__cell.smwb-head-cell.smwb-head-cell_sorted .smwb-head-cell__icon,.smwb-table__cell.smwb-head-cell.smwb-head-cell_sortable:hover .smwb-head-cell__icon,.smwb-table__cell.smwb-head-cell .smwb-head-cell__content:focus-visible .smwb-head-cell__icon{opacity:1}.smwb-table__cell.smwb-head-cell.smwb-sorted_asc .smwb-head-cell__icon{opacity:1;transform:rotate(0)}.smwb-table__cell.smwb-head-cell.smwb-sorted_desc .smwb-head-cell__icon{opacity:1;transform:rotate(180deg)}.smwb-table__head .smwb-table__row{border-top:none}.smwb-table__row{border-top:1px solid var(--smui-tableBorderColor)}.smwb-table.smwb-dense .smwb-table__cell{padding:0 16px;height:36px;vertical-align:middle}.smwb-table.smwb-dense .smwb-table__cell.smwb-head-cell{height:40px}.smwb-table.smwb-dense .smwb-table__row{border-top:1px solid var(--smui-tableBorderColor)}.smwb-table__loader{width:100%;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;top:50%;left:50%;transform:translate(-50%,-50%)}.smwb-table__loader__row{height:100px;position:relative}.smwb-scrollbar::-webkit-scrollbar-thumb{background-color:var(--smui-scrollThumbColor);border-radius:999px}.smwb-scrollbar::-webkit-scrollbar{width:6px;height:6px}.smwb-scrollbar::-webkit-scrollbar-track{background-color:transparent}.smwb-head-cell_sortable .smwb-head-cell__content{cursor:pointer;user-select:none;outline:none}.smwb-head-cell_sortable .smwb-head-cell__content:focus-visible{outline:2px solid var(--smui-primaryColor);outline-offset:2px}.smwb-table__row_selected{background-color:var(--smui-onSurfaceHover)}.smwb-table__caption{caption-side:top;text-align:left;padding:8px 12px;color:var(--smui-onSurfaceVariant)}.smwb-table_sticky-header{overflow:visible}.smwb-table__container:has(.smwb-table_sticky-header){overflow:visible}.smwb-table_sticky-header .smwb-table__head .smwb-table__cell{position:sticky;top:0;z-index:2;background-color:var(--smui-surfaceBackground)}
@@ -1 +1 @@
1
- .smwb-tree__wrapper .smwb-tree__node:first-child{border-left:0}.smwb-tree__wrapper .smwb-tree__node:first-child:before{opacity:0}.smwb-tree__node{padding-left:30px;margin-left:9px;position:relative;border-left:1px solid var(--smui-primaryColor)}.smwb-tree__node:last-child{border-left-color:transparent}.smwb-tree__node:before{position:absolute;top:0;left:-1px;height:20px;width:25px;border-bottom:1px solid var(--smui-primaryColor);border-left:1px solid var(--smui-primaryColor);content:"";font-weight:600;font-size:14px}.smwb-tree__node__label{position:relative;display:inline-flex;align-items:center;gap:10px}.smwb-tree__node__content{display:flex;align-items:center;gap:10px;height:40px;cursor:pointer;user-select:none}.smwb-tree__node_selected>.smwb-tree__node__content{background-color:var(--smui-onSurfaceHover);border-radius:4px}.smwb-tree__node__checkbox{flex-shrink:0;width:18px;height:18px;min-width:18px;min-height:18px;margin:0;cursor:pointer;accent-color:var(--smui-checkboxCheckedBg)}.smwb-tree__node__loading{padding:4px 8px 4px 28px;font-size:13px;color:var(--smui-onSurfaceVariant)}
1
+ .smwb-tree__wrapper .smwb-tree__node:first-child{border-left:0}.smwb-tree__wrapper .smwb-tree__node:first-child:before{opacity:0}.smwb-tree__node{padding-left:30px;margin-left:9px;position:relative;border-left:1px solid var(--smui-primaryColor)}.smwb-tree__node:last-child{border-left-color:transparent}.smwb-tree__node:before{position:absolute;top:0;left:-1px;height:20px;width:25px;border-bottom:1px solid var(--smui-primaryColor);border-left:1px solid var(--smui-primaryColor);content:"";font-weight:600;font-size:14px}.smwb-tree__node__label{position:relative;display:inline-flex;align-items:center;gap:10px;min-width:0;overflow-wrap:break-word}.smwb-tree__node__label>.smwb-icon__wrapper{flex:none}.smwb-tree__node__content{display:flex;align-items:center;gap:10px;min-height:40px;cursor:pointer;user-select:none}.smwb-tree__node_selected>.smwb-tree__node__content{background-color:var(--smui-onSurfaceHover);border-radius:4px}.smwb-tree__node__checkbox{flex-shrink:0;width:18px;height:18px;min-width:18px;min-height:18px;margin:0;cursor:pointer;accent-color:var(--smui-checkboxCheckedBg)}.smwb-tree__node__loading{padding:4px 8px 4px 28px;font-size:13px;color:var(--smui-onSurfaceVariant)}
@@ -1,5 +1,5 @@
1
- import { jsx as o, jsxs as _ } from "react/jsx-runtime";
2
- import h from "clsx";
1
+ import { jsx as o, jsxs as h } from "react/jsx-runtime";
2
+ import p from "clsx";
3
3
  import { Icon as x } from "../../base/icon/icon.js";
4
4
  const y = ({
5
5
  children: i,
@@ -10,21 +10,22 @@ const y = ({
10
10
  sortable: e,
11
11
  sortDirection: d,
12
12
  onSort: s,
13
- ...r
13
+ ..._
14
14
  }) => {
15
- const n = d !== void 0 ? d : m ? "asc" : t ? "desc" : !1, f = e ? n === "asc" ? "ascending" : n === "desc" ? "descending" : "none" : void 0, p = n === "asc" ? "expand_more" : n === "desc" ? "expand_less" : "", w = (c) => {
15
+ const n = d !== void 0 ? d : m ? "asc" : t ? "desc" : !1, r = e ? n === "asc" ? "ascending" : n === "desc" ? "descending" : "none" : void 0, f = n === "asc" ? "expand_more" : n === "desc" ? "expand_less" : "unfold_more", w = (c) => {
16
16
  e && s && (c.key === "Enter" || c.key === " ") && (c.preventDefault(), s());
17
17
  };
18
18
  return /* @__PURE__ */ o(
19
19
  "th",
20
20
  {
21
- ...r,
22
- "aria-sort": f,
23
- className: h("smwb-table__cell", "smwb-head-cell", l, {
21
+ ..._,
22
+ "aria-sort": r,
23
+ className: p("smwb-table__cell", "smwb-head-cell", l, {
24
24
  [`smwb-align_${a}`]: !!a,
25
- "smwb-head-cell_sortable": e
25
+ "smwb-head-cell_sortable": e,
26
+ "smwb-head-cell_sorted": !!e && n !== !1
26
27
  }),
27
- children: /* @__PURE__ */ _(
28
+ children: /* @__PURE__ */ h(
28
29
  "span",
29
30
  {
30
31
  className: "smwb-head-cell__content",
@@ -34,7 +35,7 @@ const y = ({
34
35
  tabIndex: e ? 0 : void 0,
35
36
  children: [
36
37
  i,
37
- /* @__PURE__ */ o(x, { name: p, size: 18, weight: 800 })
38
+ e && /* @__PURE__ */ o(x, { className: "smwb-head-cell__icon", name: f, size: 18, weight: 800 })
38
39
  ]
39
40
  }
40
41
  )
@@ -1 +1 @@
1
- {"version":3,"file":"tableHeadCell.js","sources":["../../../../src/components/dataDisplay/table/tableHeadCell.tsx"],"sourcesContent":["import React, { PropsWithChildren, ThHTMLAttributes } from \"react\";\nimport cn from \"clsx\";\nimport Icon from \"../../base/icon/icon\";\n\nexport type SortDirection = \"asc\" | \"desc\" | false;\n\nexport interface TableHeadCellProps extends ThHTMLAttributes<HTMLTableCellElement> {\n className?: string;\n cellAlign?: \"left\" | \"right\" | \"center\";\n /** @deprecated use `sortDirection=\"desc\"`. */\n isSortedByDesc?: boolean;\n /** @deprecated use `sortDirection=\"asc\"`. */\n isSortedByAsc?: boolean;\n /** Enables the interactive sort affordance with keyboard/aria support. */\n sortable?: boolean;\n /** Current sort direction for this column. */\n sortDirection?: SortDirection;\n /** Invoked when the user activates the sort control. */\n onSort?: () => void;\n}\n\nconst TableHeadCell = ({\n children,\n className,\n cellAlign = \"left\",\n isSortedByAsc,\n isSortedByDesc,\n sortable,\n sortDirection,\n onSort,\n ...props\n}: PropsWithChildren<TableHeadCellProps>) => {\n const direction: SortDirection =\n sortDirection !== undefined ? sortDirection : isSortedByAsc ? \"asc\" : isSortedByDesc ? \"desc\" : false;\n\n const ariaSort = sortable\n ? direction === \"asc\"\n ? \"ascending\"\n : direction === \"desc\"\n ? \"descending\"\n : \"none\"\n : undefined;\n\n const iconName = direction === \"asc\" ? \"expand_more\" : direction === \"desc\" ? \"expand_less\" : \"\";\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n if (sortable && onSort && (event.key === \"Enter\" || event.key === \" \")) {\n event.preventDefault();\n onSort();\n }\n };\n\n return (\n <th\n {...props}\n aria-sort={ariaSort}\n className={cn(\"smwb-table__cell\", \"smwb-head-cell\", className, {\n [`smwb-align_${cellAlign}`]: !!cellAlign,\n \"smwb-head-cell_sortable\": sortable,\n })}\n >\n <span\n className=\"smwb-head-cell__content\"\n onClick={sortable ? onSort : undefined}\n onKeyDown={sortable ? onKeyDown : undefined}\n role={sortable ? \"button\" : undefined}\n tabIndex={sortable ? 0 : undefined}\n >\n {children}\n <Icon name={iconName} size={18} weight={800} />\n </span>\n </th>\n );\n};\n\nexport default TableHeadCell;\n"],"names":["TableHeadCell","children","className","cellAlign","isSortedByAsc","isSortedByDesc","sortable","sortDirection","onSort","props","direction","ariaSort","iconName","onKeyDown","event","jsx","cn","jsxs","Icon"],"mappings":";;;AAqBA,MAAMA,IAAgB,CAAC;AAAA,EACrB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACL,MAA6C;AAC3C,QAAMC,IACJH,MAAkB,SAAYA,IAAgBH,IAAgB,QAAQC,IAAiB,SAAS,IAE5FM,IAAWL,IACbI,MAAc,QACZ,cACAA,MAAc,SACZ,eACA,SACJ,QAEEE,IAAWF,MAAc,QAAQ,gBAAgBA,MAAc,SAAS,gBAAgB,IAExFG,IAAY,CAACC,MAAgD;AACjE,IAAIR,KAAYE,MAAWM,EAAM,QAAQ,WAAWA,EAAM,QAAQ,SAChEA,EAAM,eAAA,GACNN,EAAA;AAAA,EAEJ;AAEA,SACE,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAGN;AAAA,MACJ,aAAWE;AAAA,MACX,WAAWK,EAAG,oBAAoB,kBAAkBd,GAAW;AAAA,QAC7D,CAAC,cAAcC,CAAS,EAAE,GAAG,CAAC,CAACA;AAAA,QAC/B,2BAA2BG;AAAA,MAAA,CAC5B;AAAA,MAED,UAAA,gBAAAW;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,SAASX,IAAWE,IAAS;AAAA,UAC7B,WAAWF,IAAWO,IAAY;AAAA,UAClC,MAAMP,IAAW,WAAW;AAAA,UAC5B,UAAUA,IAAW,IAAI;AAAA,UAExB,UAAA;AAAA,YAAAL;AAAA,8BACAiB,GAAA,EAAK,MAAMN,GAAU,MAAM,IAAI,QAAQ,IAAA,CAAK;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAC/C;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"tableHeadCell.js","sources":["../../../../src/components/dataDisplay/table/tableHeadCell.tsx"],"sourcesContent":["import React, { PropsWithChildren, ThHTMLAttributes } from \"react\";\nimport cn from \"clsx\";\nimport Icon from \"../../base/icon/icon\";\n\nexport type SortDirection = \"asc\" | \"desc\" | false;\n\nexport interface TableHeadCellProps extends ThHTMLAttributes<HTMLTableCellElement> {\n className?: string;\n cellAlign?: \"left\" | \"right\" | \"center\";\n /** @deprecated use `sortDirection=\"desc\"`. */\n isSortedByDesc?: boolean;\n /** @deprecated use `sortDirection=\"asc\"`. */\n isSortedByAsc?: boolean;\n /** Enables the interactive sort affordance with keyboard/aria support. */\n sortable?: boolean;\n /** Current sort direction for this column. */\n sortDirection?: SortDirection;\n /** Invoked when the user activates the sort control. */\n onSort?: () => void;\n}\n\nconst TableHeadCell = ({\n children,\n className,\n cellAlign = \"left\",\n isSortedByAsc,\n isSortedByDesc,\n sortable,\n sortDirection,\n onSort,\n ...props\n}: PropsWithChildren<TableHeadCellProps>) => {\n const direction: SortDirection =\n sortDirection !== undefined ? sortDirection : isSortedByAsc ? \"asc\" : isSortedByDesc ? \"desc\" : false;\n\n const ariaSort = sortable\n ? direction === \"asc\"\n ? \"ascending\"\n : direction === \"desc\"\n ? \"descending\"\n : \"none\"\n : undefined;\n\n /**\n * A sortable column always shows a marker: the current direction once sorted,\n * and `unfold_more` before that — otherwise nothing tells the reader the column\n * can be sorted at all. A cell that is not sortable shows nothing; it used to\n * render an `<Icon name=\"\">`, which reserved a gap and warned about a missing\n * icon under `source: \"smwb\"`.\n */\n const iconName = direction === \"asc\" ? \"expand_more\" : direction === \"desc\" ? \"expand_less\" : \"unfold_more\";\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n if (sortable && onSort && (event.key === \"Enter\" || event.key === \" \")) {\n event.preventDefault();\n onSort();\n }\n };\n\n return (\n <th\n {...props}\n aria-sort={ariaSort}\n className={cn(\"smwb-table__cell\", \"smwb-head-cell\", className, {\n [`smwb-align_${cellAlign}`]: !!cellAlign,\n \"smwb-head-cell_sortable\": sortable,\n \"smwb-head-cell_sorted\": !!sortable && direction !== false,\n })}\n >\n <span\n className=\"smwb-head-cell__content\"\n onClick={sortable ? onSort : undefined}\n onKeyDown={sortable ? onKeyDown : undefined}\n role={sortable ? \"button\" : undefined}\n tabIndex={sortable ? 0 : undefined}\n >\n {children}\n {sortable && <Icon className=\"smwb-head-cell__icon\" name={iconName} size={18} weight={800} />}\n </span>\n </th>\n );\n};\n\nexport default TableHeadCell;\n"],"names":["TableHeadCell","children","className","cellAlign","isSortedByAsc","isSortedByDesc","sortable","sortDirection","onSort","props","direction","ariaSort","iconName","onKeyDown","event","jsx","cn","jsxs","Icon"],"mappings":";;;AAqBA,MAAMA,IAAgB,CAAC;AAAA,EACrB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACL,MAA6C;AAC3C,QAAMC,IACJH,MAAkB,SAAYA,IAAgBH,IAAgB,QAAQC,IAAiB,SAAS,IAE5FM,IAAWL,IACbI,MAAc,QACZ,cACAA,MAAc,SACZ,eACA,SACJ,QASEE,IAAWF,MAAc,QAAQ,gBAAgBA,MAAc,SAAS,gBAAgB,eAExFG,IAAY,CAACC,MAAgD;AACjE,IAAIR,KAAYE,MAAWM,EAAM,QAAQ,WAAWA,EAAM,QAAQ,SAChEA,EAAM,eAAA,GACNN,EAAA;AAAA,EAEJ;AAEA,SACE,gBAAAO;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAGN;AAAA,MACJ,aAAWE;AAAA,MACX,WAAWK,EAAG,oBAAoB,kBAAkBd,GAAW;AAAA,QAC7D,CAAC,cAAcC,CAAS,EAAE,GAAG,CAAC,CAACA;AAAA,QAC/B,2BAA2BG;AAAA,QAC3B,yBAAyB,CAAC,CAACA,KAAYI,MAAc;AAAA,MAAA,CACtD;AAAA,MAED,UAAA,gBAAAO;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,SAASX,IAAWE,IAAS;AAAA,UAC7B,WAAWF,IAAWO,IAAY;AAAA,UAClC,MAAMP,IAAW,WAAW;AAAA,UAC5B,UAAUA,IAAW,IAAI;AAAA,UAExB,UAAA;AAAA,YAAAL;AAAA,YACAK,KAAY,gBAAAS,EAACG,GAAA,EAAK,WAAU,wBAAuB,MAAMN,GAAU,MAAM,IAAI,QAAQ,IAAA,CAAK;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAC7F;AAAA,EAAA;AAGN;"}
@@ -1,14 +1,14 @@
1
- import { jsx as s, Fragment as Tt, jsxs as N } from "react/jsx-runtime";
1
+ import { jsx as s, Fragment as Ht, jsxs as T } from "react/jsx-runtime";
2
2
  import '../../../assets/styles/less/components/floatingWindow/floatingWindow.entry.css';/* empty css */
3
- import { forwardRef as vt, useState as Kt, useRef as _, useId as Ot, useCallback as T, useEffect as Q } from "react";
4
- import { createPortal as Ft } from "react-dom";
5
- import { CSSTransition as Ht } from "react-transition-group";
6
- import W from "clsx";
3
+ import { forwardRef as Ut, useState as et, useRef as R, useId as $t, useCallback as A, useEffect as K } from "react";
4
+ import { createPortal as Vt } from "react-dom";
5
+ import { CSSTransition as Xt } from "react-transition-group";
6
+ import nt from "clsx";
7
7
  import { Icon as v } from "../../base/icon/icon.js";
8
- import { useControllableState as K } from "../../../hooks/useControllableState.js";
9
- import { useForkRef as Ut } from "../../../hooks/useForkRef.js";
10
- import { useSafeLayoutEffect as $t } from "../../../hooks/useSafeLayoutEffect.js";
11
- const Vt = {
8
+ import { useControllableState as O } from "../../../hooks/useControllableState.js";
9
+ import { useForkRef as Yt } from "../../../hooks/useForkRef.js";
10
+ import { useSafeLayoutEffect as Zt } from "../../../hooks/useSafeLayoutEffect.js";
11
+ const jt = {
12
12
  n: { dx: 0, dy: 1, dw: 0, dh: -1 },
13
13
  s: { dx: 0, dy: 0, dw: 0, dh: 1 },
14
14
  e: { dx: 0, dy: 0, dw: 1, dh: 0 },
@@ -17,97 +17,112 @@ const Vt = {
17
17
  nw: { dx: 1, dy: 1, dw: -1, dh: -1 },
18
18
  se: { dx: 0, dy: 0, dw: 1, dh: 1 },
19
19
  sw: { dx: 1, dy: 0, dw: -1, dh: 1 }
20
- }, Xt = ["n", "s", "e", "w", "ne", "nw", "se", "sw"], y = () => typeof window == "undefined" ? { width: 0, height: 0 } : { width: window.innerWidth, height: window.innerHeight }, Yt = { x: 24, y: 24 }, Zt = { width: 360, height: 420 }, ie = vt(
21
- function(tt, et) {
20
+ }, Gt = ["n", "s", "e", "w", "ne", "nw", "se", "sw"], u = () => typeof window == "undefined" ? { width: 0, height: 0 } : { width: window.innerWidth, height: window.innerHeight }, qt = { x: 24, y: 24 }, Bt = { width: 360, height: 420 }, de = Ut(
21
+ function(ot, it) {
22
22
  const {
23
- open: x,
24
- title: A,
25
- headerActions: nt,
26
- position: ot,
27
- defaultPosition: it = Yt,
28
- onPositionChange: rt,
29
- onMoveEnd: h,
30
- size: at,
31
- defaultSize: st = Zt,
32
- onResize: dt,
33
- onResizeEnd: u,
34
- minWidth: b = 200,
23
+ open: c,
24
+ title: I,
25
+ headerActions: rt,
26
+ position: at,
27
+ defaultPosition: st = qt,
28
+ onPositionChange: dt,
29
+ onMoveEnd: f,
30
+ size: lt,
31
+ defaultSize: ct = Bt,
32
+ onResize: wt,
33
+ onResizeEnd: p,
34
+ minWidth: P = 200,
35
35
  minHeight: D = 120,
36
36
  maxWidth: a,
37
37
  maxHeight: d,
38
- keepVisible: O = 56,
39
- moveStep: lt = 24,
40
- resizeStep: I = 24,
41
- zIndex: F,
42
- onActivate: R,
43
- collapsed: ct,
44
- defaultCollapsed: wt = !1,
45
- onCollapsedChange: ht,
46
- collapsible: ut = !0,
47
- movable: ft = !0,
48
- resizable: pt = !0,
49
- closeOnEsc: H = !1,
50
- onClose: P,
51
- moveHandleAriaLabel: mt = "Move window",
52
- resizeHandleAriaLabel: gt = "Resize window",
53
- closeAriaLabel: yt = "Close window",
54
- collapseAriaLabel: xt = "Collapse window",
55
- expandAriaLabel: bt = "Expand window",
56
- className: Pt,
57
- style: E,
58
- children: _t,
59
- ...Dt
60
- } = tt, [U, Rt] = Kt(), C = _(null), Ct = Ut(et, C), $ = Ot();
61
- $t(() => {
62
- Rt(document.body);
38
+ keepVisible: F = 56,
39
+ moveStep: ht = 24,
40
+ resizeStep: E = 24,
41
+ zIndex: H,
42
+ onActivate: M,
43
+ collapsed: ut,
44
+ defaultCollapsed: ft = !1,
45
+ onCollapsedChange: pt,
46
+ collapsible: mt = !0,
47
+ movable: gt = !0,
48
+ resizable: yt = !0,
49
+ closeOnEsc: U = !1,
50
+ onClose: _,
51
+ moveHandleAriaLabel: xt = "Move window",
52
+ resizeHandleAriaLabel: bt = "Resize window",
53
+ closeAriaLabel: Pt = "Close window",
54
+ collapseAriaLabel: _t = "Collapse window",
55
+ expandAriaLabel: Rt = "Expand window",
56
+ className: Dt,
57
+ style: S,
58
+ children: Mt,
59
+ ...Ct
60
+ } = ot, [$, kt] = et(), C = R(null), zt = Yt(it, C), V = $t();
61
+ Zt(() => {
62
+ kt(document.body);
63
63
  }, []);
64
- const [f, V] = K({
65
- value: ot,
66
- defaultValue: it,
67
- onChange: rt
68
- }), [p, X] = K({
64
+ const [m, X] = O({
69
65
  value: at,
70
66
  defaultValue: st,
71
67
  onChange: dt
72
- }), [c, Mt] = K({
73
- value: ct,
74
- defaultValue: wt,
75
- onChange: ht
76
- }), M = T(
68
+ }), [g, Y] = O({
69
+ value: lt,
70
+ defaultValue: ct,
71
+ onChange: wt
72
+ }), [w, At] = O({
73
+ value: ut,
74
+ defaultValue: ft,
75
+ onChange: pt
76
+ }), y = A(
77
77
  (t, e) => {
78
- const n = a != null ? a : e.width, i = d != null ? d : e.height, o = Math.max(b, Math.min(n, t.width)), r = Math.max(D, Math.min(i, t.height)), g = Math.min(O, o), S = Math.max(g - o, Math.min(e.width - g, t.x)), L = Math.max(0, Math.min(Math.max(0, e.height - g), t.y));
79
- return { x: S, y: L, width: o, height: r };
78
+ const n = a != null ? a : e.width, i = d != null ? d : e.height, o = Math.max(P, Math.min(n, t.width)), r = Math.max(D, Math.min(i, t.height)), b = Math.min(F, o), L = Math.max(b - o, Math.min(e.width - b, t.x)), N = Math.max(0, Math.min(Math.max(0, e.height - b), t.y));
79
+ return { x: L, y: N, width: o, height: r };
80
80
  },
81
- [O, d, a, D, b]
82
- ), w = M({ x: f.x, y: f.y, width: p.width, height: p.height }, y()), l = _(w);
83
- l.current = w;
84
- const m = T(
85
- (t) => {
86
- const e = M(t, y());
87
- (e.x !== f.x || e.y !== f.y) && V({ x: e.x, y: e.y }), (e.width !== p.width || e.height !== p.height) && X({ width: e.width, height: e.height });
81
+ [F, d, a, D, P]
82
+ ), It = A(
83
+ (t, e) => {
84
+ const n = y(t, e);
85
+ return {
86
+ ...n,
87
+ x: Math.max(0, Math.min(n.x, e.width - n.width)),
88
+ y: Math.max(0, Math.min(n.y, e.height - n.height))
89
+ };
90
+ },
91
+ [y]
92
+ ), [Et, Z] = et(!1);
93
+ K(() => {
94
+ c || Z(!1);
95
+ }, [c]);
96
+ const j = { x: m.x, y: m.y, width: g.width, height: g.height }, h = Et ? y(j, u()) : It(j, u()), l = R(h);
97
+ l.current = h;
98
+ const x = A(
99
+ (t, e = !0) => {
100
+ e && Z(!0);
101
+ const n = y(t, u());
102
+ (n.x !== m.x || n.y !== m.y) && X({ x: n.x, y: n.y }), (n.width !== g.width || n.height !== g.height) && Y({ width: n.width, height: n.height });
88
103
  },
89
- [M, f.x, f.y, V, X, p.height, p.width]
90
- ), Y = _(m);
91
- Y.current = m, Q(() => {
92
- if (!x) return;
93
- const t = () => Y.current(l.current);
104
+ [y, m.x, m.y, X, Y, g.height, g.width]
105
+ ), G = R(x);
106
+ G.current = x, K(() => {
107
+ if (!c) return;
108
+ const t = () => G.current(l.current, !1);
94
109
  return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
95
- }, [x]), Q(() => {
96
- if (!x || !H || !P) return;
110
+ }, [c]), K(() => {
111
+ if (!c || !U || !_) return;
97
112
  const t = (e) => {
98
113
  if (e.key !== "Escape") return;
99
114
  const n = C.current;
100
- !n || !n.contains(document.activeElement) || P();
115
+ !n || !n.contains(document.activeElement) || _();
101
116
  };
102
117
  return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
103
- }, [H, P, x]);
104
- const Z = T(() => {
105
- R == null || R();
118
+ }, [U, _, c]);
119
+ const q = A(() => {
120
+ M == null || M();
106
121
  const t = C.current;
107
122
  t && !t.contains(document.activeElement) && t.focus({ preventScroll: !0 });
108
- }, [R]), k = _(null), kt = (t) => {
123
+ }, [M]), k = R(null), St = (t) => {
109
124
  var n, i, o;
110
- if (!ft || (n = t.target) != null && n.closest("button,[data-no-drag]")) return;
125
+ if (!gt || (n = t.target) != null && n.closest("button,[data-no-drag]")) return;
111
126
  t.preventDefault();
112
127
  const e = l.current;
113
128
  k.current = { px: t.clientX, py: t.clientY, x: e.x, y: e.y };
@@ -115,51 +130,51 @@ const Vt = {
115
130
  (o = (i = t.currentTarget).setPointerCapture) == null || o.call(i, t.pointerId);
116
131
  } catch {
117
132
  }
118
- }, zt = (t) => {
133
+ }, Lt = (t) => {
119
134
  const e = k.current;
120
- e && m({
135
+ e && x({
121
136
  ...l.current,
122
137
  x: e.x + t.clientX - e.px,
123
138
  y: e.y + t.clientY - e.py
124
139
  });
125
- }, j = (t) => {
140
+ }, B = (t) => {
126
141
  var e, n, i, o;
127
142
  if (k.current) {
128
143
  k.current = null;
129
144
  const r = l.current;
130
- h == null || h({ x: r.x, y: r.y });
145
+ f == null || f({ x: r.x, y: r.y });
131
146
  }
132
147
  (n = (e = t.currentTarget).hasPointerCapture) != null && n.call(e, t.pointerId) && ((o = (i = t.currentTarget).releasePointerCapture) == null || o.call(i, t.pointerId));
133
- }, z = _(null), At = (t, e) => {
148
+ }, z = R(null), Nt = (t, e) => {
134
149
  var n, i;
135
- e.preventDefault(), e.stopPropagation(), z.current = { dir: t, px: e.clientX, py: e.clientY, rect: l.current }, Z();
150
+ e.preventDefault(), e.stopPropagation(), z.current = { dir: t, px: e.clientX, py: e.clientY, rect: l.current }, q();
136
151
  try {
137
152
  (i = (n = e.currentTarget).setPointerCapture) == null || i.call(n, e.pointerId);
138
153
  } catch {
139
154
  }
140
- }, It = (t) => {
155
+ }, Tt = (t) => {
141
156
  const e = z.current;
142
157
  if (!e) return;
143
- const n = Vt[e.dir], i = t.clientX - e.px, o = t.clientY - e.py, r = e.rect, g = y(), S = a != null ? a : g.width, L = d != null ? d : g.height, B = Math.min(S, Math.max(b, r.width + n.dw * i)), J = Math.min(L, Math.max(D, r.height + n.dh * o));
144
- m({
145
- x: n.dx ? r.x + r.width - B : r.x,
146
- y: n.dy ? r.y + r.height - J : r.y,
147
- width: B,
148
- height: J
158
+ const n = jt[e.dir], i = t.clientX - e.px, o = t.clientY - e.py, r = e.rect, b = u(), L = a != null ? a : b.width, N = d != null ? d : b.height, W = Math.min(L, Math.max(P, r.width + n.dw * i)), tt = Math.min(N, Math.max(D, r.height + n.dh * o));
159
+ x({
160
+ x: n.dx ? r.x + r.width - W : r.x,
161
+ y: n.dy ? r.y + r.height - tt : r.y,
162
+ width: W,
163
+ height: tt
149
164
  });
150
- }, G = (t) => {
165
+ }, J = (t) => {
151
166
  var e, n, i, o;
152
167
  if (z.current) {
153
168
  z.current = null;
154
169
  const r = l.current;
155
- u == null || u({ width: r.width, height: r.height });
170
+ p == null || p({ width: r.width, height: r.height });
156
171
  }
157
172
  (n = (e = t.currentTarget).hasPointerCapture) != null && n.call(e, t.pointerId) && ((o = (i = t.currentTarget).releasePointerCapture) == null || o.call(i, t.pointerId));
158
- }, q = (t, e) => {
159
- const n = M(e, y());
160
- t ? u == null || u({ width: n.width, height: n.height }) : h == null || h({ x: n.x, y: n.y });
161
- }, Et = (t) => {
162
- const e = l.current, n = t.shiftKey ? I : lt, o = {
173
+ }, Q = (t, e) => {
174
+ const n = y(e, u());
175
+ t ? p == null || p({ width: n.width, height: n.height }) : f == null || f({ x: n.x, y: n.y });
176
+ }, Kt = (t) => {
177
+ const e = l.current, n = t.shiftKey ? E : ht, o = {
163
178
  ArrowLeft: [-n, 0],
164
179
  ArrowRight: [n, 0],
165
180
  ArrowUp: [0, -n],
@@ -168,69 +183,69 @@ const Vt = {
168
183
  if (!o) return;
169
184
  t.preventDefault();
170
185
  const r = t.shiftKey ? { ...e, width: e.width + o[0], height: e.height + o[1] } : { ...e, x: e.x + o[0], y: e.y + o[1] };
171
- m(r), q(t.shiftKey, r);
172
- }, St = (t) => {
173
- const e = l.current, n = y();
186
+ x(r), Q(t.shiftKey, r);
187
+ }, vt = (t) => {
188
+ const e = l.current, n = u();
174
189
  let i;
175
190
  if (t.key === "ArrowLeft" || t.key === "ArrowRight") {
176
191
  t.preventDefault();
177
192
  const o = t.key === "ArrowRight" ? 1 : -1;
178
- i = { ...e, width: e.width + o * I };
193
+ i = { ...e, width: e.width + o * E };
179
194
  } else if (t.key === "ArrowUp" || t.key === "ArrowDown") {
180
195
  t.preventDefault();
181
196
  const o = t.key === "ArrowDown" ? 1 : -1;
182
- i = { ...e, height: e.height + o * I };
197
+ i = { ...e, height: e.height + o * E };
183
198
  } else if (t.key === "Home")
184
- t.preventDefault(), i = { ...e, width: b, height: D };
199
+ t.preventDefault(), i = { ...e, width: P, height: D };
185
200
  else if (t.key === "End")
186
201
  t.preventDefault(), i = { ...e, width: a != null ? a : n.width, height: d != null ? d : n.height };
187
202
  else
188
203
  return;
189
- m(i), q(!0, i);
190
- }, Lt = () => Mt((t) => !t);
191
- if (!U)
192
- return /* @__PURE__ */ s(Tt, {});
193
- const Nt = {
194
- left: `${w.x}px`,
195
- top: `${w.y}px`,
196
- width: `${w.width}px`,
197
- ...c ? {} : { height: `${w.height}px` },
198
- ...F === void 0 ? {} : { zIndex: F },
199
- ...E != null ? E : {}
204
+ x(i), Q(!0, i);
205
+ }, Ot = () => At((t) => !t);
206
+ if (!$)
207
+ return /* @__PURE__ */ s(Ht, {});
208
+ const Ft = {
209
+ left: `${h.x}px`,
210
+ top: `${h.y}px`,
211
+ width: `${h.width}px`,
212
+ ...w ? {} : { height: `${h.height}px` },
213
+ ...H === void 0 ? {} : { zIndex: H },
214
+ ...S != null ? S : {}
200
215
  };
201
- return Ft(
216
+ return Vt(
202
217
  /* @__PURE__ */ s(
203
- Ht,
218
+ Xt,
204
219
  {
205
- in: x,
220
+ in: c,
206
221
  timeout: 120,
207
222
  mountOnEnter: !0,
208
223
  unmountOnExit: !0,
209
224
  appear: !0,
210
225
  classNames: { enterDone: "smwb-floating-window_entered" },
211
226
  nodeRef: C,
212
- children: /* @__PURE__ */ N(
227
+ children: /* @__PURE__ */ T(
213
228
  "div",
214
229
  {
215
- ...Dt,
216
- ref: Ct,
230
+ ...Ct,
231
+ ref: zt,
217
232
  "data-testid": "floating-window",
218
233
  role: "dialog",
219
234
  tabIndex: -1,
220
- "aria-labelledby": A ? $ : void 0,
221
- className: W("smwb-floating-window", Pt, { "smwb-collapsed": c }),
222
- style: Nt,
223
- onPointerDown: Z,
235
+ "aria-labelledby": I ? V : void 0,
236
+ className: nt("smwb-floating-window", Dt, { "smwb-collapsed": w }),
237
+ style: Ft,
238
+ onPointerDown: q,
224
239
  children: [
225
- /* @__PURE__ */ N(
240
+ /* @__PURE__ */ T(
226
241
  "div",
227
242
  {
228
243
  className: "smwb-floating-window__header",
229
244
  "data-testid": "floating-window-header",
230
- onPointerDown: kt,
231
- onPointerMove: zt,
232
- onPointerUp: j,
233
- onPointerCancel: j,
245
+ onPointerDown: St,
246
+ onPointerMove: Lt,
247
+ onPointerUp: B,
248
+ onPointerCancel: B,
234
249
  children: [
235
250
  /* @__PURE__ */ s(
236
251
  "span",
@@ -239,34 +254,34 @@ const Vt = {
239
254
  "data-testid": "floating-window-move",
240
255
  role: "button",
241
256
  tabIndex: 0,
242
- "aria-label": mt,
243
- onKeyDown: Et,
257
+ "aria-label": xt,
258
+ onKeyDown: Kt,
244
259
  children: /* @__PURE__ */ s(v, { name: "drag_indicator" })
245
260
  }
246
261
  ),
247
- A ? /* @__PURE__ */ s("span", { className: "smwb-floating-window__title", id: $, children: A }) : null,
248
- /* @__PURE__ */ N("div", { className: "smwb-floating-window__actions", "data-no-drag": !0, children: [
249
- nt,
250
- ut ? /* @__PURE__ */ s(
262
+ I ? /* @__PURE__ */ s("span", { className: "smwb-floating-window__title", id: V, children: I }) : null,
263
+ /* @__PURE__ */ T("div", { className: "smwb-floating-window__actions", "data-no-drag": !0, children: [
264
+ rt,
265
+ mt ? /* @__PURE__ */ s(
251
266
  "button",
252
267
  {
253
268
  type: "button",
254
269
  className: "smwb-floating-window__action",
255
270
  "data-testid": "floating-window-collapse",
256
- "aria-label": c ? bt : xt,
257
- "aria-expanded": !c,
258
- onClick: Lt,
259
- children: /* @__PURE__ */ s(v, { name: c ? "open_in_full" : "close_fullscreen" })
271
+ "aria-label": w ? Rt : _t,
272
+ "aria-expanded": !w,
273
+ onClick: Ot,
274
+ children: /* @__PURE__ */ s(v, { name: w ? "open_in_full" : "close_fullscreen" })
260
275
  }
261
276
  ) : null,
262
- P ? /* @__PURE__ */ s(
277
+ _ ? /* @__PURE__ */ s(
263
278
  "button",
264
279
  {
265
280
  type: "button",
266
281
  className: "smwb-floating-window__action",
267
282
  "data-testid": "floating-window-close",
268
- "aria-label": yt,
269
- onClick: P,
283
+ "aria-label": Pt,
284
+ onClick: _,
270
285
  children: /* @__PURE__ */ s(v, { name: "close" })
271
286
  }
272
287
  ) : null
@@ -274,25 +289,25 @@ const Vt = {
274
289
  ]
275
290
  }
276
291
  ),
277
- c ? null : /* @__PURE__ */ s("div", { className: "smwb-floating-window__body", "data-testid": "floating-window-body", children: _t }),
278
- pt && !c ? Xt.map((t) => /* @__PURE__ */ s(
292
+ w ? null : /* @__PURE__ */ s("div", { className: "smwb-floating-window__body", "data-testid": "floating-window-body", children: Mt }),
293
+ yt && !w ? Gt.map((t) => /* @__PURE__ */ s(
279
294
  "div",
280
295
  {
281
- className: W("smwb-floating-window__resize", `smwb-floating-window__resize_${t}`),
296
+ className: nt("smwb-floating-window__resize", `smwb-floating-window__resize_${t}`),
282
297
  "data-testid": `floating-window-resize-${t}`,
283
298
  ...t === "se" ? {
284
299
  role: "separator",
285
300
  tabIndex: 0,
286
- "aria-label": gt,
287
- "aria-valuemin": b,
288
- "aria-valuemax": Math.round(a != null ? a : y().width),
289
- "aria-valuenow": Math.round(w.width),
290
- onKeyDown: St
301
+ "aria-label": bt,
302
+ "aria-valuemin": P,
303
+ "aria-valuemax": Math.round(a != null ? a : u().width),
304
+ "aria-valuenow": Math.round(h.width),
305
+ onKeyDown: vt
291
306
  } : { "aria-hidden": !0, tabIndex: -1 },
292
- onPointerDown: (e) => At(t, e),
293
- onPointerMove: It,
294
- onPointerUp: G,
295
- onPointerCancel: G
307
+ onPointerDown: (e) => Nt(t, e),
308
+ onPointerMove: Tt,
309
+ onPointerUp: J,
310
+ onPointerCancel: J
296
311
  },
297
312
  t
298
313
  )) : null
@@ -301,11 +316,11 @@ const Vt = {
301
316
  )
302
317
  }
303
318
  ),
304
- U
319
+ $
305
320
  );
306
321
  }
307
322
  );
308
323
  export {
309
- ie as FloatingWindow
324
+ de as FloatingWindow
310
325
  };
311
326
  //# sourceMappingURL=floatingWindow.js.map