@ifhover/leaf-ui 0.16.6 → 0.17.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 (145) hide show
  1. package/dist/cjs/browser/modules/card/card.cjs +29 -14
  2. package/dist/cjs/browser/modules/card/card.cjs.map +1 -1
  3. package/dist/cjs/browser/modules/confirm/confirm.cjs +2 -2
  4. package/dist/cjs/browser/modules/confirm/confirm.cjs.map +1 -1
  5. package/dist/cjs/browser/modules/drawer/drawer.cjs +120 -61
  6. package/dist/cjs/browser/modules/drawer/drawer.cjs.map +1 -1
  7. package/dist/cjs/browser/modules/filelist/filelist.cjs +2 -2
  8. package/dist/cjs/browser/modules/filelist/filelist.cjs.map +1 -1
  9. package/dist/cjs/browser/modules/modal/base.cjs +287 -0
  10. package/dist/cjs/browser/modules/modal/base.cjs.map +1 -0
  11. package/dist/cjs/browser/modules/modal/modal.cjs +64 -209
  12. package/dist/cjs/browser/modules/modal/modal.cjs.map +1 -1
  13. package/dist/cjs/browser/modules/shared/presence.cjs +12 -6
  14. package/dist/cjs/browser/modules/shared/presence.cjs.map +1 -1
  15. package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs +14 -2
  16. package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs.map +1 -1
  17. package/dist/cjs/browser/modules/tabs/tabs.cjs +194 -174
  18. package/dist/cjs/browser/modules/tabs/tabs.cjs.map +1 -1
  19. package/dist/cjs/card/card.cjs +29 -14
  20. package/dist/cjs/card/card.cjs.map +1 -1
  21. package/dist/cjs/card/card.d.cts.map +1 -1
  22. package/dist/cjs/confirm/confirm.cjs +2 -2
  23. package/dist/cjs/confirm/confirm.cjs.map +1 -1
  24. package/dist/cjs/drawer/drawer.cjs +120 -61
  25. package/dist/cjs/drawer/drawer.cjs.map +1 -1
  26. package/dist/cjs/drawer/drawer.d.cts +6 -0
  27. package/dist/cjs/drawer/drawer.d.cts.map +1 -1
  28. package/dist/cjs/drawer/index.d.cts +1 -1
  29. package/dist/cjs/drawer/index.d.cts.map +1 -1
  30. package/dist/cjs/filelist/filelist.cjs +2 -2
  31. package/dist/cjs/filelist/filelist.cjs.map +1 -1
  32. package/dist/cjs/index.d.cts +2 -2
  33. package/dist/cjs/index.d.cts.map +1 -1
  34. package/dist/cjs/modal/base.cjs +285 -0
  35. package/dist/cjs/modal/base.cjs.map +1 -0
  36. package/dist/cjs/modal/base.d.cts +23 -0
  37. package/dist/cjs/modal/base.d.cts.map +1 -0
  38. package/dist/cjs/modal/index.d.cts +1 -1
  39. package/dist/cjs/modal/index.d.cts.map +1 -1
  40. package/dist/cjs/modal/modal.cjs +64 -209
  41. package/dist/cjs/modal/modal.cjs.map +1 -1
  42. package/dist/cjs/modal/modal.d.cts +8 -3
  43. package/dist/cjs/modal/modal.d.cts.map +1 -1
  44. package/dist/cjs/shared/presence.cjs +12 -6
  45. package/dist/cjs/shared/presence.cjs.map +1 -1
  46. package/dist/cjs/shared/presence.d.cts +1 -1
  47. package/dist/cjs/shared/presence.d.cts.map +1 -1
  48. package/dist/cjs/styles/card.css +1 -1
  49. package/dist/cjs/styles/colorpicker.css +1 -1
  50. package/dist/cjs/styles/components/card.css +1 -1
  51. package/dist/cjs/styles/components/drawer.css +1 -1
  52. package/dist/cjs/styles/components/modal.css +1 -1
  53. package/dist/cjs/styles/components/tabletanstack.css +1 -1
  54. package/dist/cjs/styles/components/tabs.css +1 -1
  55. package/dist/cjs/styles/config-provider.css +1 -1
  56. package/dist/cjs/styles/confirm.css +1 -1
  57. package/dist/cjs/styles/daterangepicker.css +1 -1
  58. package/dist/cjs/styles/drawer.css +1 -1
  59. package/dist/cjs/styles/filelist.css +1 -1
  60. package/dist/cjs/styles/index.css +79 -22
  61. package/dist/cjs/styles/index.css.map +1 -1
  62. package/dist/cjs/styles/modal.css +1 -1
  63. package/dist/cjs/styles/tabletanstack.css +1 -1
  64. package/dist/cjs/styles/tabs.css +1 -1
  65. package/dist/cjs/styles/upload.css +1 -1
  66. package/dist/cjs/tabletanstack/tabletanstack.cjs +14 -2
  67. package/dist/cjs/tabletanstack/tabletanstack.cjs.map +1 -1
  68. package/dist/cjs/tabletanstack/tabletanstack.d.cts.map +1 -1
  69. package/dist/cjs/tabs/tabs.cjs +194 -174
  70. package/dist/cjs/tabs/tabs.cjs.map +1 -1
  71. package/dist/cjs/tabs/tabs.d.cts +14 -1
  72. package/dist/cjs/tabs/tabs.d.cts.map +1 -1
  73. package/dist/esm/browser/modules/card/card.js +30 -15
  74. package/dist/esm/browser/modules/card/card.js.map +1 -1
  75. package/dist/esm/browser/modules/confirm/confirm.js +1 -1
  76. package/dist/esm/browser/modules/confirm/confirm.js.map +1 -1
  77. package/dist/esm/browser/modules/drawer/drawer.js +121 -62
  78. package/dist/esm/browser/modules/drawer/drawer.js.map +1 -1
  79. package/dist/esm/browser/modules/filelist/filelist.js +1 -1
  80. package/dist/esm/browser/modules/filelist/filelist.js.map +1 -1
  81. package/dist/esm/browser/modules/modal/base.js +249 -0
  82. package/dist/esm/browser/modules/modal/base.js.map +1 -0
  83. package/dist/esm/browser/modules/modal/modal.js +65 -207
  84. package/dist/esm/browser/modules/modal/modal.js.map +1 -1
  85. package/dist/esm/browser/modules/shared/presence.js +12 -6
  86. package/dist/esm/browser/modules/shared/presence.js.map +1 -1
  87. package/dist/esm/browser/modules/tabletanstack/tabletanstack.js +14 -2
  88. package/dist/esm/browser/modules/tabletanstack/tabletanstack.js.map +1 -1
  89. package/dist/esm/browser/modules/tabs/tabs.js +190 -173
  90. package/dist/esm/browser/modules/tabs/tabs.js.map +1 -1
  91. package/dist/esm/card/card.d.ts.map +1 -1
  92. package/dist/esm/card/card.js +30 -15
  93. package/dist/esm/card/card.js.map +1 -1
  94. package/dist/esm/confirm/confirm.js +1 -1
  95. package/dist/esm/confirm/confirm.js.map +1 -1
  96. package/dist/esm/drawer/drawer.d.ts +6 -0
  97. package/dist/esm/drawer/drawer.d.ts.map +1 -1
  98. package/dist/esm/drawer/drawer.js +121 -62
  99. package/dist/esm/drawer/drawer.js.map +1 -1
  100. package/dist/esm/drawer/index.d.ts +1 -1
  101. package/dist/esm/drawer/index.d.ts.map +1 -1
  102. package/dist/esm/filelist/filelist.js +1 -1
  103. package/dist/esm/filelist/filelist.js.map +1 -1
  104. package/dist/esm/index.d.ts +2 -2
  105. package/dist/esm/index.d.ts.map +1 -1
  106. package/dist/esm/modal/base.d.ts +23 -0
  107. package/dist/esm/modal/base.d.ts.map +1 -0
  108. package/dist/esm/modal/base.js +247 -0
  109. package/dist/esm/modal/base.js.map +1 -0
  110. package/dist/esm/modal/index.d.ts +1 -1
  111. package/dist/esm/modal/index.d.ts.map +1 -1
  112. package/dist/esm/modal/modal.d.ts +8 -3
  113. package/dist/esm/modal/modal.d.ts.map +1 -1
  114. package/dist/esm/modal/modal.js +65 -207
  115. package/dist/esm/modal/modal.js.map +1 -1
  116. package/dist/esm/shared/presence.d.ts +1 -1
  117. package/dist/esm/shared/presence.d.ts.map +1 -1
  118. package/dist/esm/shared/presence.js +12 -6
  119. package/dist/esm/shared/presence.js.map +1 -1
  120. package/dist/esm/styles/card.css +1 -1
  121. package/dist/esm/styles/colorpicker.css +1 -1
  122. package/dist/esm/styles/components/card.css +1 -1
  123. package/dist/esm/styles/components/drawer.css +1 -1
  124. package/dist/esm/styles/components/modal.css +1 -1
  125. package/dist/esm/styles/components/tabletanstack.css +1 -1
  126. package/dist/esm/styles/components/tabs.css +1 -1
  127. package/dist/esm/styles/config-provider.css +1 -1
  128. package/dist/esm/styles/confirm.css +1 -1
  129. package/dist/esm/styles/daterangepicker.css +1 -1
  130. package/dist/esm/styles/drawer.css +1 -1
  131. package/dist/esm/styles/filelist.css +1 -1
  132. package/dist/esm/styles/index.css +79 -22
  133. package/dist/esm/styles/index.css.map +1 -1
  134. package/dist/esm/styles/modal.css +1 -1
  135. package/dist/esm/styles/tabletanstack.css +1 -1
  136. package/dist/esm/styles/tabs.css +1 -1
  137. package/dist/esm/styles/upload.css +1 -1
  138. package/dist/esm/tabletanstack/tabletanstack.d.ts.map +1 -1
  139. package/dist/esm/tabletanstack/tabletanstack.js +14 -2
  140. package/dist/esm/tabletanstack/tabletanstack.js.map +1 -1
  141. package/dist/esm/tabs/tabs.d.ts +14 -1
  142. package/dist/esm/tabs/tabs.d.ts.map +1 -1
  143. package/dist/esm/tabs/tabs.js +190 -173
  144. package/dist/esm/tabs/tabs.js.map +1 -1
  145. package/package.json +2 -2
@@ -31,218 +31,69 @@ var __webpack_require__ = {};
31
31
  var __webpack_exports__ = {};
32
32
  __webpack_require__.r(__webpack_exports__);
33
33
  __webpack_require__.d(__webpack_exports__, {
34
- Modal: ()=>Modal,
35
- ModalBase: ()=>ModalBase
34
+ Modal: ()=>Modal
36
35
  });
37
36
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
38
- const external_lucide_react_namespaceObject = require("lucide-react");
39
37
  const external_react_namespaceObject = require("react");
40
- const button_cjs_namespaceObject = require("../button/button.cjs");
41
38
  const component_defaults_cjs_namespaceObject = require("../config-provider/component-defaults.cjs");
42
- const context_cjs_namespaceObject = require("../config-provider/context.cjs");
43
39
  const scrollbar_cjs_namespaceObject = require("../scrollbar/scrollbar.cjs");
44
40
  const classes_cjs_namespaceObject = require("../shared/classes.cjs");
45
- const dialog_cjs_namespaceObject = require("../shared/dialog.cjs");
46
- const inert_cjs_namespaceObject = require("../shared/inert.cjs");
47
- const overlay_owner_cjs_namespaceObject = require("../shared/overlay-owner.cjs");
48
- const presence_cjs_namespaceObject = require("../shared/presence.cjs");
49
- const scoped_portal_cjs_namespaceObject = require("../shared/scoped-portal.cjs");
50
- function ModalSurface({ open, title, description, icon, divided = true, footer, confirmText, cancelText, confirmLoading = false, confirmButtonProps, cancelButtonProps, onConfirm, onCancel, width = 480, closable = true, maskClosable = true, keyboard = true, onClose, afterClose, forceRender = false, destroyOnClose = false, preserve, initialFocus, returnFocus, container: _container, children, className, style, ...props }) {
51
- const { messages, maskBlur } = (0, context_cjs_namespaceObject.useLeafConfig)();
52
- const [pending, setPending] = (0, external_react_namespaceObject.useState)(false);
53
- const [error, setError] = (0, external_react_namespaceObject.useState)();
54
- const mounted = (0, external_react_namespaceObject.useRef)(true);
55
- const accepting = (0, external_react_namespaceObject.useRef)(false);
56
- const generation = (0, external_react_namespaceObject.useRef)(0);
57
- (0, external_react_namespaceObject.useEffect)(()=>{
58
- mounted.current = true;
59
- return ()=>{
60
- mounted.current = false;
61
- };
62
- }, []);
63
- (0, external_react_namespaceObject.useEffect)(()=>{
64
- generation.current++;
65
- accepting.current = false;
66
- setPending(false);
67
- if (open) setError(void 0);
68
- }, [
69
- open
70
- ]);
71
- const busy = pending || confirmLoading;
72
- async function accept() {
73
- if (accepting.current || busy) return;
74
- if (!onConfirm) {
75
- if (confirmButtonProps?.type !== 'submit') onClose?.();
76
- return;
77
- }
78
- accepting.current = true;
79
- const request = generation.current;
80
- setPending(true);
81
- setError(void 0);
82
- try {
83
- await onConfirm();
84
- } catch (reason) {
85
- if (mounted.current && generation.current === request) setError(reason instanceof Error ? reason.message : String(reason));
86
- } finally{
87
- if (generation.current === request) {
88
- accepting.current = false;
89
- if (mounted.current) setPending(false);
90
- }
91
- }
92
- }
93
- const cancel = ()=>{
94
- if (!busy) (onCancel ?? onClose)?.();
95
- };
96
- const actions = {
97
- cancelButton: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.ButtonControl, {
98
- type: "button",
99
- variant: "outline",
100
- ...cancelButtonProps,
101
- disabled: busy || cancelButtonProps?.disabled,
102
- onClick: (event)=>{
103
- cancelButtonProps?.onClick?.(event);
104
- if (!event.defaultPrevented) cancel();
105
- },
106
- children: cancelText ?? messages.common.cancel
107
- }),
108
- confirmButton: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.ButtonControl, {
109
- type: "button",
110
- variant: "solid",
111
- ...confirmButtonProps,
112
- loading: busy || confirmButtonProps?.loading,
113
- onClick: (event)=>{
114
- confirmButtonProps?.onClick?.(event);
115
- if (!event.defaultPrevented) accept();
116
- },
117
- children: confirmText ?? messages.common.confirm
118
- })
119
- };
120
- const renderedFooter = 'function' == typeof footer ? footer(actions) : void 0 === footer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
121
- className: "leaf-modal__actions",
41
+ const tabs_cjs_namespaceObject = require("../tabs/tabs.cjs");
42
+ const external_base_cjs_namespaceObject = require("./base.cjs");
43
+ const useBrowserLayoutEffect = "u" < typeof window ? external_react_namespaceObject.useEffect : external_react_namespaceObject.useLayoutEffect;
44
+ function ModalTabsLayout({ open, tabs, title, titleId, hasHeading, closeButton, contentRef, snapHeight, ariaLabel, ariaLabelledBy, scrollbarLabel, scrollbarLabelledBy, error, children }) {
45
+ const tabExtra = hasHeading || null == closeButton ? tabs.extra : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
46
+ className: "leaf-dialog-tab-extra leaf-modal__tab-extra",
122
47
  children: [
123
- actions.cancelButton,
124
- actions.confirmButton
48
+ tabs.extra,
49
+ closeButton
125
50
  ]
126
- }) : footer;
127
- const panel = (0, external_react_namespaceObject.useRef)(null);
128
- const content = (0, external_react_namespaceObject.useRef)(null);
129
- const backdrop = (0, external_react_namespaceObject.useRef)(null);
130
- const present = (0, presence_cjs_namespaceObject.usePresence)(open, backdrop);
131
- (0, presence_cjs_namespaceObject.useNaturalHeightTransition)(panel, content, open);
132
- const titleId = `${(0, external_react_namespaceObject.useId)()}-title`;
133
- const descriptionId = `${(0, external_react_namespaceObject.useId)()}-description`;
134
- const modalId = `${(0, external_react_namespaceObject.useId)()}-dialog`;
135
- const close = (0, external_react_namespaceObject.useRef)(cancel);
136
- close.current = cancel;
137
- const wasPresent = (0, external_react_namespaceObject.useRef)(false);
138
- (0, external_react_namespaceObject.useEffect)(()=>{
139
- if (wasPresent.current && !present) afterClose?.();
140
- wasPresent.current = present;
51
+ });
52
+ const tabLabel = tabs['aria-label'] ?? ('string' == typeof title ? title : ariaLabel);
53
+ const tabLabelledBy = tabs['aria-labelledby'] ?? (null == tabs['aria-label'] && null != title ? titleId : null == tabs['aria-label'] ? ariaLabelledBy : void 0);
54
+ const parts = (0, tabs_cjs_namespaceObject.useTabsParts)({
55
+ ...tabs,
56
+ type: 'line',
57
+ placement: 'top',
58
+ size: tabs.size ?? 'md',
59
+ 'aria-label': tabLabel,
60
+ 'aria-labelledby': tabLabelledBy,
61
+ extra: tabExtra,
62
+ className: (0, classes_cjs_namespaceObject.classes)('leaf-dialog-tabs', hasHeading && 'leaf-dialog-tabs--headed', 'leaf-modal__tabs', tabs.className),
63
+ panelsClassName: 'leaf-dialog-panels',
64
+ visibilityKey: open
65
+ });
66
+ const previousSelected = (0, external_react_namespaceObject.useRef)(parts?.selected);
67
+ useBrowserLayoutEffect(()=>{
68
+ if (previousSelected.current === parts?.selected) return;
69
+ previousSelected.current = parts?.selected;
70
+ snapHeight();
141
71
  }, [
142
- present,
143
- afterClose
72
+ parts?.selected,
73
+ snapHeight
144
74
  ]);
145
- (0, dialog_cjs_namespaceObject.useDialog)(open, panel, modalId, cancel, keyboard, {
146
- initialFocus,
147
- returnFocus
148
- });
149
- const visited = (0, external_react_namespaceObject.useRef)(false);
150
- if (open) visited.current = true;
151
- if (!present && !forceRender && ((void 0 === preserve ? destroyOnClose : !preserve) || !visited.current)) return null;
152
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
153
- hidden: !present,
154
- className: "leaf-modal-mask",
155
- "data-blur": maskBlur ? void 0 : 'off',
156
- "data-state": open ? 'open' : 'closing',
157
- "aria-hidden": !open || void 0,
158
- ...(0, inert_cjs_namespaceObject.inertProps)(!open),
75
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
159
76
  children: [
160
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
161
- ref: backdrop,
162
- type: "button",
163
- className: "leaf-modal-backdrop",
164
- tabIndex: -1,
165
- "aria-label": messages.common.close,
166
- onClick: ()=>{
167
- if (maskClosable) close.current?.();
168
- }
77
+ parts && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
78
+ ...parts.rootProps,
79
+ children: parts.header
169
80
  }),
170
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
171
- ...props,
172
- ref: panel,
173
- id: props.id ?? modalId,
174
- role: props.role ?? 'dialog',
175
- "aria-modal": "true",
176
- "aria-labelledby": null != title ? titleId : props['aria-labelledby'],
177
- "aria-describedby": [
178
- props['aria-describedby'],
179
- null != description && descriptionId
180
- ].filter(Boolean).join(' ') || void 0,
181
- tabIndex: -1,
182
- className: (0, classes_cjs_namespaceObject.classes)('leaf-modal', divided && 'leaf-modal--divided', className),
183
- style: {
184
- width,
185
- ...style
186
- },
187
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(overlay_owner_cjs_namespaceObject.OverlayOwner.Provider, {
188
- value: modalId,
81
+ (parts?.hasPanels || null != children && false !== children || null != error) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scrollbar_cjs_namespaceObject.ScrollbarControl, {
82
+ className: "leaf-modal__body",
83
+ viewportClassName: "leaf-modal__viewport",
84
+ orientation: "vertical",
85
+ "aria-labelledby": scrollbarLabelledBy,
86
+ "aria-label": scrollbarLabel,
87
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
88
+ ref: contentRef,
89
+ className: "leaf-modal__content",
189
90
  children: [
190
- (null != title || null != description || null != icon || closable) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
191
- className: (0, classes_cjs_namespaceObject.classes)('leaf-modal__header', null == description && 'leaf-modal__header--simple', null != icon && 'leaf-modal__header--icon', null == title && null == description && null == icon && 'leaf-modal__header--compact'),
192
- children: [
193
- null != icon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
194
- className: "leaf-modal__icon",
195
- "aria-hidden": "true",
196
- children: icon
197
- }),
198
- (null != title || null != description) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
199
- className: "leaf-modal__heading",
200
- children: [
201
- null != title && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h2", {
202
- id: titleId,
203
- children: title
204
- }),
205
- null != description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
206
- id: descriptionId,
207
- className: "leaf-modal__description",
208
- children: description
209
- })
210
- ]
211
- }),
212
- closable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
213
- type: "button",
214
- className: "leaf-modal__close",
215
- "aria-label": messages.common.close,
216
- onClick: ()=>close.current?.(),
217
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {
218
- size: 18,
219
- "aria-hidden": "true"
220
- })
221
- })
222
- ]
223
- }),
224
- (null != children && false !== children || null != error) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scrollbar_cjs_namespaceObject.ScrollbarControl, {
225
- className: "leaf-modal__body",
226
- viewportClassName: "leaf-modal__viewport",
227
- orientation: "vertical",
228
- "aria-labelledby": null != title ? titleId : void 0,
229
- "aria-label": null == title ? props['aria-label'] ?? messages.common.confirm : void 0,
230
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
231
- ref: content,
232
- className: "leaf-modal__content",
233
- children: [
234
- children,
235
- error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
236
- role: "alert",
237
- className: "leaf-confirm-error",
238
- children: error
239
- })
240
- ]
241
- })
242
- }),
243
- null != renderedFooter && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
244
- className: "leaf-modal__footer",
245
- children: renderedFooter
91
+ parts?.panels,
92
+ children,
93
+ error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
94
+ role: "alert",
95
+ className: "leaf-confirm-error",
96
+ children: error
246
97
  })
247
98
  ]
248
99
  })
@@ -250,25 +101,29 @@ function ModalSurface({ open, title, description, icon, divided = true, footer,
250
101
  ]
251
102
  });
252
103
  }
253
- function ModalBase(props) {
254
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scoped_portal_cjs_namespaceObject.ScopedPortal, {
255
- container: props.container,
256
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModalSurface, {
257
- ...props
258
- })
104
+ function ModalControl({ divided = true, confirmLoading = false, width = 480, closable = true, maskClosable = true, keyboard = true, forceRender = false, destroyOnClose = false, ...props }) {
105
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_base_cjs_namespaceObject.ModalBase, {
106
+ ...props,
107
+ divided: divided,
108
+ confirmLoading: confirmLoading,
109
+ width: width,
110
+ closable: closable,
111
+ maskClosable: maskClosable,
112
+ keyboard: keyboard,
113
+ forceRender: forceRender,
114
+ destroyOnClose: destroyOnClose,
115
+ renderTabsLayout: ModalTabsLayout
259
116
  });
260
117
  }
261
118
  function Modal(rawProps) {
262
119
  const props = (0, component_defaults_cjs_namespaceObject.useComponentProps)('Modal', rawProps);
263
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModalBase, {
120
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModalControl, {
264
121
  ...props
265
122
  });
266
123
  }
267
124
  exports.Modal = __webpack_exports__.Modal;
268
- exports.ModalBase = __webpack_exports__.ModalBase;
269
125
  for(var __rspack_i in __webpack_exports__)if (-1 === [
270
- "Modal",
271
- "ModalBase"
126
+ "Modal"
272
127
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
273
128
  Object.defineProperty(exports, '__esModule', {
274
129
  value: true
@@ -1 +1 @@
1
- {"version":3,"file":"modal/modal.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/modal/modal.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { X } from 'lucide-react';\nimport { type HTMLAttributes, type ReactNode, useEffect, useId, useRef, useState } from 'react';\nimport { ButtonControl, type ButtonProps } from '../button/button';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { ScrollbarControl as Scrollbar } from '../scrollbar/scrollbar';\nimport { classes } from '../shared/classes';\nimport { type DialogFocusOptions, useDialog } from '../shared/dialog';\nimport { inertProps } from '../shared/inert';\nimport { OverlayOwner } from '../shared/overlay-owner';\nimport { useNaturalHeightTransition, usePresence } from '../shared/presence';\nimport { ScopedPortal } from '../shared/scoped-portal';\n\nexport interface ModalFooterActions {\n confirmButton: ReactNode;\n cancelButton: ReactNode;\n}\nexport interface ModalProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n DialogFocusOptions {\n open: boolean;\n title?: ReactNode;\n /** Supporting text displayed below the title. */\n description?: ReactNode;\n /** Decorative header icon. */\n icon?: ReactNode;\n /** Separate the header and footer with subtle borders. */\n divided?: boolean;\n footer?: ReactNode | ((actions: ModalFooterActions) => ReactNode);\n confirmText?: ReactNode;\n cancelText?: ReactNode;\n confirmLoading?: boolean;\n confirmButtonProps?: ButtonProps;\n cancelButtonProps?: ButtonProps;\n onConfirm?: () => void | Promise<void>;\n onCancel?: () => void;\n width?: number | string;\n closable?: boolean;\n maskClosable?: boolean;\n keyboard?: boolean;\n onClose?: () => void;\n afterClose?: () => void;\n forceRender?: boolean;\n destroyOnClose?: boolean;\n preserve?: boolean;\n container?: Element | DocumentFragment | (() => Element | DocumentFragment);\n}\n\nfunction ModalSurface({\n open,\n title,\n description,\n icon,\n divided = true,\n footer,\n confirmText,\n cancelText,\n confirmLoading = false,\n confirmButtonProps,\n cancelButtonProps,\n onConfirm,\n onCancel,\n width = 480,\n closable = true,\n maskClosable = true,\n keyboard = true,\n onClose,\n afterClose,\n forceRender = false,\n destroyOnClose = false,\n preserve,\n initialFocus,\n returnFocus,\n container: _container,\n children,\n className,\n style,\n ...props\n}: ModalProps) {\n const { messages, maskBlur } = useLeafConfig();\n const [pending, setPending] = useState(false);\n const [error, setError] = useState<string>();\n const mounted = useRef(true);\n const accepting = useRef(false);\n const generation = useRef(0);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n useEffect(() => {\n generation.current++;\n accepting.current = false;\n setPending(false);\n if (open) setError(undefined);\n }, [open]);\n const busy = pending || confirmLoading;\n async function accept() {\n if (accepting.current || busy) return;\n if (!onConfirm) {\n if (confirmButtonProps?.type !== 'submit') onClose?.();\n return;\n }\n accepting.current = true;\n const request = generation.current;\n setPending(true);\n setError(undefined);\n try {\n await onConfirm();\n } catch (reason) {\n if (mounted.current && generation.current === request)\n setError(reason instanceof Error ? reason.message : String(reason));\n } finally {\n if (generation.current === request) {\n accepting.current = false;\n if (mounted.current) setPending(false);\n }\n }\n }\n const cancel = () => {\n if (!busy) (onCancel ?? onClose)?.();\n };\n const actions: ModalFooterActions = {\n cancelButton: (\n <ButtonControl\n type=\"button\"\n variant=\"outline\"\n {...cancelButtonProps}\n disabled={busy || cancelButtonProps?.disabled}\n onClick={(event) => {\n cancelButtonProps?.onClick?.(event);\n if (!event.defaultPrevented) cancel();\n }}\n >\n {cancelText ?? messages.common.cancel}\n </ButtonControl>\n ),\n confirmButton: (\n <ButtonControl\n type=\"button\"\n variant=\"solid\"\n {...confirmButtonProps}\n loading={busy || confirmButtonProps?.loading}\n onClick={(event) => {\n confirmButtonProps?.onClick?.(event);\n if (!event.defaultPrevented) void accept();\n }}\n >\n {confirmText ?? messages.common.confirm}\n </ButtonControl>\n ),\n };\n const renderedFooter =\n typeof footer === 'function' ? (\n footer(actions)\n ) : footer === undefined ? (\n <div className=\"leaf-modal__actions\">\n {actions.cancelButton}\n {actions.confirmButton}\n </div>\n ) : (\n footer\n );\n const panel = useRef<HTMLDivElement>(null);\n const content = useRef<HTMLDivElement>(null);\n const backdrop = useRef<HTMLButtonElement>(null);\n const present = usePresence(open, backdrop);\n useNaturalHeightTransition(panel, content, open);\n const titleId = `${useId()}-title`;\n const descriptionId = `${useId()}-description`;\n const modalId = `${useId()}-dialog`;\n const close = useRef(cancel);\n close.current = cancel;\n const wasPresent = useRef(false);\n useEffect(() => {\n if (wasPresent.current && !present) afterClose?.();\n wasPresent.current = present;\n }, [present, afterClose]);\n useDialog(open, panel, modalId, cancel, keyboard, { initialFocus, returnFocus });\n const visited = useRef(false);\n if (open) visited.current = true;\n if (\n !present &&\n !forceRender &&\n ((preserve === undefined ? destroyOnClose : !preserve) || !visited.current)\n )\n return null;\n return (\n <div\n hidden={!present}\n className=\"leaf-modal-mask\"\n data-blur={maskBlur ? undefined : 'off'}\n data-state={open ? 'open' : 'closing'}\n aria-hidden={!open || undefined}\n {...inertProps(!open)}\n >\n <button\n ref={backdrop}\n type=\"button\"\n className=\"leaf-modal-backdrop\"\n tabIndex={-1}\n aria-label={messages.common.close}\n onClick={() => {\n if (maskClosable) close.current?.();\n }}\n />\n {/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: dialog and alertdialog both support aria-modal. */}\n <div\n {...props}\n ref={panel}\n id={props.id ?? modalId}\n role={props.role ?? 'dialog'}\n aria-modal=\"true\"\n aria-labelledby={title != null ? titleId : props['aria-labelledby']}\n aria-describedby={\n [props['aria-describedby'], description != null && descriptionId]\n .filter(Boolean)\n .join(' ') || undefined\n }\n tabIndex={-1}\n className={classes('leaf-modal', divided && 'leaf-modal--divided', className)}\n style={{ width, ...style }}\n >\n <OverlayOwner.Provider value={modalId}>\n {(title != null || description != null || icon != null || closable) && (\n <div\n className={classes(\n 'leaf-modal__header',\n description == null && 'leaf-modal__header--simple',\n icon != null && 'leaf-modal__header--icon',\n title == null &&\n description == null &&\n icon == null &&\n 'leaf-modal__header--compact',\n )}\n >\n {icon != null && (\n <span className=\"leaf-modal__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {(title != null || description != null) && (\n <div className=\"leaf-modal__heading\">\n {title != null && <h2 id={titleId}>{title}</h2>}\n {description != null && (\n <div id={descriptionId} className=\"leaf-modal__description\">\n {description}\n </div>\n )}\n </div>\n )}\n {closable && (\n <button\n type=\"button\"\n className=\"leaf-modal__close\"\n aria-label={messages.common.close}\n onClick={() => close.current?.()}\n >\n <X size={18} aria-hidden=\"true\" />\n </button>\n )}\n </div>\n )}\n {((children != null && children !== false) || error != null) && (\n <Scrollbar\n className=\"leaf-modal__body\"\n viewportClassName=\"leaf-modal__viewport\"\n orientation=\"vertical\"\n aria-labelledby={title != null ? titleId : undefined}\n aria-label={\n title == null ? (props['aria-label'] ?? messages.common.confirm) : undefined\n }\n >\n <div ref={content} className=\"leaf-modal__content\">\n {children}\n {error && (\n <p role=\"alert\" className=\"leaf-confirm-error\">\n {error}\n </p>\n )}\n </div>\n </Scrollbar>\n )}\n {renderedFooter != null && <div className=\"leaf-modal__footer\">{renderedFooter}</div>}\n </OverlayOwner.Provider>\n </div>\n </div>\n );\n}\n// Other components reuse the dialog mechanics without inheriting public Modal defaults.\nexport function ModalBase(props: ModalProps) {\n return (\n <ScopedPortal container={props.container}>\n <ModalSurface {...props} />\n </ScopedPortal>\n );\n}\nexport function Modal(rawProps: ModalProps) {\n const props = useComponentProps('Modal', rawProps);\n return <ModalBase {...props} />;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","ModalSurface","open","title","description","icon","divided","footer","confirmText","cancelText","confirmLoading","confirmButtonProps","cancelButtonProps","onConfirm","onCancel","width","closable","maskClosable","keyboard","onClose","afterClose","forceRender","destroyOnClose","preserve","initialFocus","returnFocus","_container","children","className","style","props","messages","maskBlur","useLeafConfig","pending","setPending","useState","error","setError","mounted","useRef","accepting","generation","useEffect","undefined","busy","accept","request","reason","Error","String","cancel","actions","ButtonControl","event","renderedFooter","panel","content","backdrop","present","usePresence","useNaturalHeightTransition","titleId","useId","descriptionId","modalId","close","wasPresent","useDialog","visited","inertProps","Boolean","classes","OverlayOwner","X","Scrollbar","ModalBase","ScopedPortal","Modal","rawProps","useComponentProps"],"mappings":";;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;AC0CA,SAASI,aAAa,EACpBC,IAAI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AG7B;AACO,SAASgD,MAAMC,QAAoB;IACxC,MAAMjD,QAAQkD,AAAAA,IAAAA,uCAAAA,iBAAAA,AAAAA,EAAkB,SAASD;IACzC,OAAO,WAAP,GAAO,qCAACH,WAAAA;QAAW,GAAG9C,KAAK;;AAC7B"}
1
+ {"version":3,"file":"modal/modal.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/modal/modal.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type HTMLAttributes, type ReactNode, useEffect, useLayoutEffect, useRef } from 'react';\nimport type { ButtonProps } from '../button/button';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { ScrollbarControl as Scrollbar } from '../scrollbar/scrollbar';\nimport { classes } from '../shared/classes';\nimport type { DialogFocusOptions } from '../shared/dialog';\nimport { type TabsProps, useTabsParts } from '../tabs/tabs';\nimport { ModalBase, type ModalTabsRenderProps } from './base';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport interface ModalFooterActions {\n confirmButton: ReactNode;\n cancelButton: ReactNode;\n}\n/** Tabs controls integrated with the modal; Modal fixes the line type and top placement. */\nexport interface ModalTabsProps extends Omit<TabsProps, 'type' | 'placement' | 'children'> {}\n\nexport interface ModalProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n DialogFocusOptions {\n open: boolean;\n title?: ReactNode;\n /** Supporting text displayed below the title. */\n description?: ReactNode;\n /** Decorative header icon. */\n icon?: ReactNode;\n /** Separate the header and footer with subtle borders. */\n divided?: boolean;\n /** Embedded tabs placed below the heading, or replacing it when no title is supplied. */\n tabs?: ModalTabsProps;\n footer?: ReactNode | ((actions: ModalFooterActions) => ReactNode);\n confirmText?: ReactNode;\n cancelText?: ReactNode;\n confirmLoading?: boolean;\n confirmButtonProps?: ButtonProps;\n cancelButtonProps?: ButtonProps;\n onConfirm?: () => void | Promise<void>;\n onCancel?: () => void;\n width?: number | string;\n closable?: boolean;\n maskClosable?: boolean;\n keyboard?: boolean;\n onClose?: () => void;\n afterClose?: () => void;\n forceRender?: boolean;\n destroyOnClose?: boolean;\n preserve?: boolean;\n container?: Element | DocumentFragment | (() => Element | DocumentFragment);\n}\n\nfunction ModalTabsLayout({\n open,\n tabs,\n title,\n titleId,\n hasHeading,\n closeButton,\n contentRef,\n snapHeight,\n ariaLabel,\n ariaLabelledBy,\n scrollbarLabel,\n scrollbarLabelledBy,\n error,\n children,\n}: ModalTabsRenderProps) {\n const tabExtra =\n !hasHeading && closeButton != null ? (\n <div className=\"leaf-dialog-tab-extra leaf-modal__tab-extra\">\n {tabs.extra}\n {closeButton}\n </div>\n ) : (\n tabs.extra\n );\n const tabLabel = tabs['aria-label'] ?? (typeof title === 'string' ? title : ariaLabel);\n const tabLabelledBy =\n tabs['aria-labelledby'] ??\n (tabs['aria-label'] == null && title != null\n ? titleId\n : tabs['aria-label'] == null\n ? ariaLabelledBy\n : undefined);\n const parts = useTabsParts({\n ...tabs,\n type: 'line',\n placement: 'top',\n size: tabs.size ?? 'md',\n 'aria-label': tabLabel,\n 'aria-labelledby': tabLabelledBy,\n extra: tabExtra,\n className: classes(\n 'leaf-dialog-tabs',\n hasHeading && 'leaf-dialog-tabs--headed',\n 'leaf-modal__tabs',\n tabs.className,\n ),\n panelsClassName: 'leaf-dialog-panels',\n visibilityKey: open,\n });\n const previousSelected = useRef(parts?.selected);\n useBrowserLayoutEffect(() => {\n if (previousSelected.current === parts?.selected) return;\n previousSelected.current = parts?.selected;\n snapHeight();\n }, [parts?.selected, snapHeight]);\n\n return (\n <>\n {parts && <div {...parts.rootProps}>{parts.header}</div>}\n {(parts?.hasPanels || (children != null && children !== false) || error != null) && (\n <Scrollbar\n className=\"leaf-modal__body\"\n viewportClassName=\"leaf-modal__viewport\"\n orientation=\"vertical\"\n aria-labelledby={scrollbarLabelledBy}\n aria-label={scrollbarLabel}\n >\n <div ref={contentRef} className=\"leaf-modal__content\">\n {parts?.panels}\n {children}\n {error && (\n <p role=\"alert\" className=\"leaf-confirm-error\">\n {error}\n </p>\n )}\n </div>\n </Scrollbar>\n )}\n </>\n );\n}\n\ntype ModalControlProps = ModalProps;\n\nfunction ModalControl({\n divided = true,\n confirmLoading = false,\n width = 480,\n closable = true,\n maskClosable = true,\n keyboard = true,\n forceRender = false,\n destroyOnClose = false,\n ...props\n}: ModalControlProps) {\n return (\n <ModalBase\n {...props}\n divided={divided}\n confirmLoading={confirmLoading}\n width={width}\n closable={closable}\n maskClosable={maskClosable}\n keyboard={keyboard}\n forceRender={forceRender}\n destroyOnClose={destroyOnClose}\n renderTabsLayout={ModalTabsLayout}\n />\n );\n}\n\nexport function Modal(rawProps: ModalProps) {\n const props = useComponentProps('Modal', rawProps);\n return <ModalControl {...props} />;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","ModalTabsLayout","open","tabs","title","titleId","hasHeading","closeButton","contentRef","snapHeight","ariaLabel","ariaLabelledBy","scrollbarLabel","scrollbarLabelledBy","error","children","tabExtra","tabLabel","tabLabelledBy","undefined","parts","useTabsParts","classes","previousSelected","useRef","Scrollbar","ModalControl","divided","confirmLoading","width","closable","maskClosable","keyboard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AAU,IAAI,EACdC,iBAAiB,KAAK,EACtBC,QAAQ,GAAG,EACXC,WAAW,IAAI,EACfC,eAAe,IAAI,EACnBC,WAAW,IAAI,EACfC,cAAc,KAAK,EACnBC,iBAAiB,KAAK,EACtB,GAAGC,OACe;IAClB,OACE,AADK,WAAP,GACE,qCAACC,kCAAAA,SAASA,EAAAA;QACP,GAAGD,KAAK;QACT,SAASR;QACT,gBAAgBC;QAChB,OAAOC;QACP,UAAUC;QACV,cAAcC;QACd,UAAUC;QACV,aAAaC;QACb,gBAAgBC;QAChB,kBAAkBjC;;AAGxB;AAEO,SAASoC,MAAMC,QAAoB;IACxC,MAAMH,QAAQI,AAAAA,IAAAA,uCAAAA,iBAAAA,AAAAA,EAAkB,SAASD;IACzC,OAAO,WAAP,GAAO,qCAACZ,cAAAA;QAAc,GAAGS,KAAK;;AAChC"}
@@ -39,6 +39,7 @@ const useBrowserLayoutEffect = "u" < typeof window ? external_react_namespaceObj
39
39
  function useNaturalHeightTransition(surfaceRef, contentRef, open) {
40
40
  const enabled = (0, external_motion_cjs_namespaceObject.useMotionEnabled)();
41
41
  const sync = (0, external_react_namespaceObject.useRef)(void 0);
42
+ const snap = (0, external_react_namespaceObject.useRef)(()=>{});
42
43
  useBrowserLayoutEffect(()=>{
43
44
  const surface = surfaceRef.current;
44
45
  const content = contentRef.current;
@@ -87,6 +88,14 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
87
88
  });
88
89
  };
89
90
  sync.current = update;
91
+ snap.current = ()=>{
92
+ animation?.cancel();
93
+ reveal?.cancel();
94
+ animation = void 0;
95
+ reveal = void 0;
96
+ lastHeight = surface.offsetHeight;
97
+ lastLayout = layout();
98
+ };
90
99
  let observer;
91
100
  if ("u" > typeof ResizeObserver) {
92
101
  observer = new ResizeObserver(update);
@@ -94,12 +103,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
94
103
  for (const part of parts())observer.observe(part);
95
104
  }
96
105
  const resize = ()=>{
97
- animation?.cancel();
98
- reveal?.cancel();
99
- animation = void 0;
100
- reveal = void 0;
101
- lastHeight = surface.offsetHeight;
102
- lastLayout = layout();
106
+ snap.current();
103
107
  };
104
108
  window.addEventListener('resize', resize);
105
109
  window.visualViewport?.addEventListener('resize', resize);
@@ -110,6 +114,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
110
114
  animation?.cancel();
111
115
  reveal?.cancel();
112
116
  sync.current = void 0;
117
+ snap.current = ()=>{};
113
118
  };
114
119
  }, [
115
120
  open,
@@ -120,6 +125,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
120
125
  useBrowserLayoutEffect(()=>{
121
126
  sync.current?.();
122
127
  });
128
+ return (0, external_react_namespaceObject.useRef)(()=>snap.current()).current;
123
129
  }
124
130
  function useContentTransition(ref, view, direction = 0, layoutOnly = false) {
125
131
  const enabled = (0, external_motion_cjs_namespaceObject.useMotionEnabled)();
@@ -1 +1 @@
1
- {"version":3,"file":"shared/presence.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/shared/presence.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type RefObject, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { animateMotion, useMotionEnabled } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/** Interpolate natural dialog height, including state changes inside its children. */\nexport function useNaturalHeightTransition(\n surfaceRef: RefObject<HTMLElement | null>,\n contentRef: RefObject<HTMLElement | null>,\n open: boolean,\n) {\n const enabled = useMotionEnabled();\n const sync = useRef<(() => void) | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const surface = surfaceRef.current;\n const content = contentRef.current;\n if (!open || !enabled || !surface || !content) return;\n let animation: Animation | undefined;\n let reveal: Animation | undefined;\n let lastHeight = surface.offsetHeight;\n let lastLayout = '';\n const parts = () =>\n Array.from(surface.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(content),\n );\n const layout = () =>\n [surface.offsetWidth, content.offsetHeight, ...parts().map((part) => part.offsetHeight)].join(\n ':',\n );\n lastLayout = layout();\n const update = () => {\n const nextLayout = layout();\n if (nextLayout === lastLayout || surface.closest('[data-state=\"closing\"]')) return;\n lastLayout = nextLayout;\n // CSS height is unaffected by the separate entrance scale on the surface.\n const before =\n animation?.playState === 'running'\n ? Number.parseFloat(getComputedStyle(surface).height) || lastHeight\n : lastHeight;\n const opacity = reveal?.playState === 'running' ? getComputedStyle(content).opacity : '0.72';\n animation?.cancel();\n reveal?.cancel();\n const height = surface.offsetHeight;\n lastHeight = height;\n if (!before || !height || Math.abs(before - height) < 1) return;\n animation = animateMotion(surface, [{ height: `${before}px` }, { height: `${height}px` }], {\n durationMultiplier: 1.6,\n });\n if (animation)\n reveal = animateMotion(content, [{ opacity }, { opacity: 1 }], {\n durationMultiplier: 1.25,\n });\n };\n sync.current = update;\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(update);\n observer.observe(content);\n for (const part of parts()) observer.observe(part);\n }\n // Viewport constraints change the visible height without changing content.\n // Resizing establishes a fresh baseline instead of animating stale geometry.\n const resize = () => {\n animation?.cancel();\n reveal?.cancel();\n animation = undefined;\n reveal = undefined;\n lastHeight = surface.offsetHeight;\n lastLayout = layout();\n };\n window.addEventListener('resize', resize);\n window.visualViewport?.addEventListener('resize', resize);\n return () => {\n window.removeEventListener('resize', resize);\n window.visualViewport?.removeEventListener('resize', resize);\n observer?.disconnect();\n animation?.cancel();\n reveal?.cancel();\n sync.current = undefined;\n };\n }, [open, enabled, surfaceRef, contentRef]);\n // React updates to the header/footer are measurable before the next paint.\n useBrowserLayoutEffect(() => {\n sync.current?.();\n });\n}\n\n/** Animate a panel's explicit view change without remounting its focused controls. */\nexport function useContentTransition(\n ref: RefObject<HTMLElement | null>,\n view: string | number,\n direction = 0,\n layoutOnly = false,\n) {\n const enabled = useMotionEnabled();\n const travel = useRef(direction);\n travel.current = direction;\n const previous = useRef<{ view: string | number; height: number } | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const node = ref.current;\n if (!node) {\n previous.current = undefined;\n return;\n }\n const height = Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n const last = previous.current;\n previous.current = { view, height };\n if (!enabled || !last || last.view === view || node.closest('[data-state=\"closing\"]')) return;\n const changesHeight = last.height > 0 && height > 0 && Math.abs(last.height - height) > 1;\n if (layoutOnly && !changesHeight) return;\n const animation = animateMotion(\n node,\n [\n {\n ...(layoutOnly ? {} : { opacity: 0.45, translate: `${travel.current * 12}px 4px` }),\n ...(changesHeight ? { height: `${last.height}px`, overflow: 'clip' } : {}),\n },\n {\n ...(layoutOnly ? {} : { opacity: 1, translate: '0 0' }),\n ...(changesHeight ? { height: `${height}px`, overflow: 'clip' } : {}),\n },\n ],\n { durationMultiplier: 1.25 },\n );\n return () => {\n if (animation && changesHeight && previous.current)\n previous.current.height =\n Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n animation?.cancel();\n };\n }, [enabled, ref, view, layoutOnly]);\n}\n\n/** Keep a closing overlay mounted until its CSS transition or animation finishes. */\nexport function usePresence(open: boolean, ref: RefObject<HTMLElement | null>) {\n const enabled = useMotionEnabled();\n const [present, setPresent] = useState(open);\n if (open && !present) setPresent(true);\n useEffect(() => {\n if (open || !present) return;\n const node = ref.current;\n if (!node || !enabled) {\n setPresent(false);\n return;\n }\n const computed = getComputedStyle(node);\n const durations = [computed.animationDuration, computed.transitionDuration];\n const delays = [computed.animationDelay, computed.transitionDelay];\n const milliseconds = (value: string) => {\n const numeric = Number.parseFloat(value) || 0;\n return value.trim().endsWith('ms') ? numeric : numeric * 1000;\n };\n const duration = Math.max(\n 0,\n ...durations.flatMap((list, index) => {\n const delay = (delays[index] || '0s').split(',').map(milliseconds);\n return (list || '0s')\n .split(',')\n .map((value, i) => milliseconds(value) + (delay[i % delay.length] ?? 0));\n }),\n );\n const finish = () => setPresent(false);\n const ended = (event: Event) => {\n if (event.target === node && (!('propertyName' in event) || event.propertyName === 'opacity'))\n finish();\n };\n const timer = setTimeout(finish, duration ? duration + 32 : 0);\n node.addEventListener('animationend', ended);\n node.addEventListener('transitionend', ended);\n return () => {\n clearTimeout(timer);\n node.removeEventListener('animationend', ended);\n node.removeEventListener('transitionend', ended);\n };\n }, [open, present, ref, enabled]);\n return present;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","useNaturalHeightTransition","surfaceRef","contentRef","open","enabled","useMotionEnabled","sync","useRef","undefined","surface","content","animation","reveal","lastHeight","lastLayout","parts","Array","child","HTMLElement","layout","part","update","nextLayout","before","Number","getComputedStyle","opacity","height","Math","animateMotion","observer","ResizeObserver","resize","useContentTransition","ref","view","direction","layoutOnly","travel","previous","node","last","changesHeight","usePresence","present","setPresent","useState","computed","durations","delays","milliseconds","value","numeric","duration","list","index","delay","i","finish","ended","event","timer","setTimeout","clearTimeout"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,C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,UAAU,CAAC2B,UAAU;YAC5C,OAAOA,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQC,UAAUA,AAAU,OAAVA;QACjD;QACA,MAAMC,WAAWzB,KAAK,GAAG,CACvB,MACGoB,UAAU,OAAO,CAAC,CAACM,MAAMC;YAC1B,MAAMC,QAASP,AAAAA,CAAAA,MAAM,CAACM,MAAM,IAAI,IAAG,EAAG,KAAK,CAAC,KAAK,GAAG,CAACL;YACrD,OAAQI,AAAAA,CAAAA,QAAQ,IAAG,EAChB,KAAK,CAAC,KACN,GAAG,CAAC,CAACH,OAAOM,IAAMP,aAAaC,SAAUK,CAAAA,KAAK,CAACC,IAAID,MAAM,MAAM,CAAC,IAAI;QACzE;QAEF,MAAME,SAAS,IAAMb,WAAW;QAChC,MAAMc,QAAQ,CAACC;YACb,IAAIA,MAAM,MAAM,KAAKpB,QAAS,EAAE,mBAAkBoB,KAAI,KAAMA,AAAuB,cAAvBA,MAAM,YAAY,AAAa,GACzFF;QACJ;QACA,MAAMG,QAAQC,WAAWJ,QAAQL,WAAWA,WAAW,KAAK;QAC5Db,KAAK,gBAAgB,CAAC,gBAAgBmB;QACtCnB,KAAK,gBAAgB,CAAC,iBAAiBmB;QACvC,OAAO;YACLI,aAAaF;YACbrB,KAAK,mBAAmB,CAAC,gBAAgBmB;YACzCnB,KAAK,mBAAmB,CAAC,iBAAiBmB;QAC5C;IACF,GAAG;QAACxD;QAAMyC;QAASV;QAAK9B;KAAQ;IAChC,OAAOwC;AACT"}
1
+ {"version":3,"file":"shared/presence.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/shared/presence.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type RefObject, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { animateMotion, useMotionEnabled } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/** Interpolate natural dialog height, including state changes inside its children. */\nexport function useNaturalHeightTransition(\n surfaceRef: RefObject<HTMLElement | null>,\n contentRef: RefObject<HTMLElement | null>,\n open: boolean,\n) {\n const enabled = useMotionEnabled();\n const sync = useRef<(() => void) | undefined>(undefined);\n const snap = useRef<() => void>(() => {});\n useBrowserLayoutEffect(() => {\n const surface = surfaceRef.current;\n const content = contentRef.current;\n if (!open || !enabled || !surface || !content) return;\n let animation: Animation | undefined;\n let reveal: Animation | undefined;\n let lastHeight = surface.offsetHeight;\n let lastLayout = '';\n const parts = () =>\n Array.from(surface.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(content),\n );\n const layout = () =>\n [surface.offsetWidth, content.offsetHeight, ...parts().map((part) => part.offsetHeight)].join(\n ':',\n );\n lastLayout = layout();\n const update = () => {\n const nextLayout = layout();\n if (nextLayout === lastLayout || surface.closest('[data-state=\"closing\"]')) return;\n lastLayout = nextLayout;\n // CSS height is unaffected by the separate entrance scale on the surface.\n const before =\n animation?.playState === 'running'\n ? Number.parseFloat(getComputedStyle(surface).height) || lastHeight\n : lastHeight;\n const opacity = reveal?.playState === 'running' ? getComputedStyle(content).opacity : '0.72';\n animation?.cancel();\n reveal?.cancel();\n const height = surface.offsetHeight;\n lastHeight = height;\n if (!before || !height || Math.abs(before - height) < 1) return;\n animation = animateMotion(surface, [{ height: `${before}px` }, { height: `${height}px` }], {\n durationMultiplier: 1.6,\n });\n if (animation)\n reveal = animateMotion(content, [{ opacity }, { opacity: 1 }], {\n durationMultiplier: 1.25,\n });\n };\n sync.current = update;\n // 切换标签页时立即刷新高度基线,避免触发容器高度缓动。\n snap.current = () => {\n animation?.cancel();\n reveal?.cancel();\n animation = undefined;\n reveal = undefined;\n lastHeight = surface.offsetHeight;\n lastLayout = layout();\n };\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(update);\n observer.observe(content);\n for (const part of parts()) observer.observe(part);\n }\n // Viewport constraints change the visible height without changing content.\n // Resizing establishes a fresh baseline instead of animating stale geometry.\n const resize = () => {\n snap.current();\n };\n window.addEventListener('resize', resize);\n window.visualViewport?.addEventListener('resize', resize);\n return () => {\n window.removeEventListener('resize', resize);\n window.visualViewport?.removeEventListener('resize', resize);\n observer?.disconnect();\n animation?.cancel();\n reveal?.cancel();\n sync.current = undefined;\n snap.current = () => {};\n };\n }, [open, enabled, surfaceRef, contentRef]);\n // React updates to the header/footer are measurable before the next paint.\n useBrowserLayoutEffect(() => {\n sync.current?.();\n });\n return useRef(() => snap.current()).current;\n}\n\n/** Animate a panel's explicit view change without remounting its focused controls. */\nexport function useContentTransition(\n ref: RefObject<HTMLElement | null>,\n view: string | number,\n direction = 0,\n layoutOnly = false,\n) {\n const enabled = useMotionEnabled();\n const travel = useRef(direction);\n travel.current = direction;\n const previous = useRef<{ view: string | number; height: number } | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const node = ref.current;\n if (!node) {\n previous.current = undefined;\n return;\n }\n const height = Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n const last = previous.current;\n previous.current = { view, height };\n if (!enabled || !last || last.view === view || node.closest('[data-state=\"closing\"]')) return;\n const changesHeight = last.height > 0 && height > 0 && Math.abs(last.height - height) > 1;\n if (layoutOnly && !changesHeight) return;\n const animation = animateMotion(\n node,\n [\n {\n ...(layoutOnly ? {} : { opacity: 0.45, translate: `${travel.current * 12}px 4px` }),\n ...(changesHeight ? { height: `${last.height}px`, overflow: 'clip' } : {}),\n },\n {\n ...(layoutOnly ? {} : { opacity: 1, translate: '0 0' }),\n ...(changesHeight ? { height: `${height}px`, overflow: 'clip' } : {}),\n },\n ],\n { durationMultiplier: 1.25 },\n );\n return () => {\n if (animation && changesHeight && previous.current)\n previous.current.height =\n Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n animation?.cancel();\n };\n }, [enabled, ref, view, layoutOnly]);\n}\n\n/** Keep a closing overlay mounted until its CSS transition or animation finishes. */\nexport function usePresence(open: boolean, ref: RefObject<HTMLElement | null>) {\n const enabled = useMotionEnabled();\n const [present, setPresent] = useState(open);\n if (open && !present) setPresent(true);\n useEffect(() => {\n if (open || !present) return;\n const node = ref.current;\n if (!node || !enabled) {\n setPresent(false);\n return;\n }\n const computed = getComputedStyle(node);\n const durations = [computed.animationDuration, computed.transitionDuration];\n const delays = [computed.animationDelay, computed.transitionDelay];\n const milliseconds = (value: string) => {\n const numeric = Number.parseFloat(value) || 0;\n return value.trim().endsWith('ms') ? numeric : numeric * 1000;\n };\n const duration = Math.max(\n 0,\n ...durations.flatMap((list, index) => {\n const delay = (delays[index] || '0s').split(',').map(milliseconds);\n return (list || '0s')\n .split(',')\n .map((value, i) => milliseconds(value) + (delay[i % delay.length] ?? 0));\n }),\n );\n const finish = () => setPresent(false);\n const ended = (event: Event) => {\n if (event.target === node && (!('propertyName' in event) || event.propertyName === 'opacity'))\n finish();\n };\n const timer = setTimeout(finish, duration ? duration + 32 : 0);\n node.addEventListener('animationend', ended);\n node.addEventListener('transitionend', ended);\n return () => {\n clearTimeout(timer);\n node.removeEventListener('animationend', ended);\n node.removeEventListener('transitionend', ended);\n };\n }, [open, present, ref, enabled]);\n return present;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","useNaturalHeightTransition","surfaceRef","contentRef","open","enabled","useMotionEnabled","sync","useRef","undefined","snap","surface","content","animation","reveal","lastHeight","lastLayout","parts","Array","child","HTMLElement","layout","part","update","nextLayout","before","Number","getComputedStyle","opacity","height","Math","animateMotion","observer","ResizeObserver","resize","useContentTransition","ref","view","direction","layoutOnly","travel","previous","node","last","changesHeight","usePresence","present","setPresent","useState","computed","durations","delays","milliseconds","value","numeric","duration","list","index","delay","i","finish","ended","event","timer","setTimeout","clearTimeout"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;ACHA,MAAMI,yBAAyB,AAAkB,MAAlB,OAAOC,SAAyBC,+BAAAA,SAASA,GAAGC,+BAAAA,eAAeA;AAGnF,SAASC,2BACdC,UAAyC,EACzCC,UAAyC,EACzCC,IAAa;IAEb,MAAMC,UAAUC,AAAAA,IAAAA,oCAAAA,gBAAAA,AAAAA;IAChB,MAAMC,O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,MAAM,KAAKpB,QAAS,EAAE,mBAAkBoB,KAAI,KAAMA,AAAuB,cAAvBA,MAAM,YAAY,AAAa,GACzFF;QACJ;QACA,MAAMG,QAAQC,WAAWJ,QAAQL,WAAWA,WAAW,KAAK;QAC5Db,KAAK,gBAAgB,CAAC,gBAAgBmB;QACtCnB,KAAK,gBAAgB,CAAC,iBAAiBmB;QACvC,OAAO;YACLI,aAAaF;YACbrB,KAAK,mBAAmB,CAAC,gBAAgBmB;YACzCnB,KAAK,mBAAmB,CAAC,iBAAiBmB;QAC5C;IACF,GAAG;QAACzD;QAAM0C;QAASV;QAAK/B;KAAQ;IAChC,OAAOyC;AACT"}
@@ -61,6 +61,15 @@ function warnDevelopment(key, message) {
61
61
  developmentWarnings.add(key);
62
62
  console.warn(`Leaf UI: ${message}`);
63
63
  }
64
+ const SELECTION_CONTENT_WIDTH = 34;
65
+ function resolvePx(value, fallback) {
66
+ if ('number' == typeof value) return Number.isFinite(value) && value >= 0 ? value : fallback;
67
+ if ('string' == typeof value) {
68
+ const match = /^\s*(?:0+(?:\.0+)?|(\d+(?:\.\d+)?)\s*px)\s*$/iu.exec(value);
69
+ if (match) return Number(match[1] ?? 0);
70
+ }
71
+ return fallback;
72
+ }
64
73
  function hasSortingModel(table) {
65
74
  return Boolean(table.options.getSortedRowModel || table.options.manualSorting);
66
75
  }
@@ -548,6 +557,7 @@ function ordinaryRows(rows) {
548
557
  function DataTableContentControl({ className, ...props }) {
549
558
  const config = useDataTableContext();
550
559
  const { table, tableRef, loading, error, emptyContent, onRetry, selection, resizable, virtual } = config;
560
+ const { theme } = (0, context_cjs_namespaceObject.useLeafConfig)();
551
561
  const t = (0, use_text_cjs_namespaceObject.useText)();
552
562
  const viewport = (0, external_react_namespaceObject.useRef)(null);
553
563
  const [availableWidth, setAvailableWidth] = (0, external_react_namespaceObject.useState)(0);
@@ -579,10 +589,12 @@ function DataTableContentControl({ className, ...props }) {
579
589
  const expandable = config.expandable && !config.renderRowHeader;
580
590
  const utilityCount = Number(Boolean(selection)) + Number(expandable);
581
591
  const colSpan = Math.max(1, columns.length + utilityCount);
592
+ const selectionBorderWidth = config.bordered ? resolvePx(theme.components?.Table?.borderWidth ?? theme.tokens?.borderWidth, 1) : 0;
593
+ const selectionWidth = SELECTION_CONTENT_WIDTH + selectionBorderWidth;
582
594
  const layout = (0, external_column_sizing_cjs_namespaceObject.getColumnLayout)(table, columns, {
583
595
  forceFixed: Boolean(resizable || virtual || columns.some((column)=>column.getIsPinned())),
584
596
  availableWidth,
585
- utilityWidth: (selection ? 32 : 0) + (expandable ? 48 : 0)
597
+ utilityWidth: (selection ? selectionWidth : 0) + (expandable ? 48 : 0)
586
598
  });
587
599
  const status = null != error && false !== error ? 'error' : rows.length && columns.length ? null : loading ? 'loading' : 'empty';
588
600
  const expanded = table.getState().expanded;
@@ -646,7 +658,7 @@ function DataTableContentControl({ className, ...props }) {
646
658
  children: [
647
659
  selection && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {
648
660
  style: {
649
- width: 32
661
+ width: config.bordered ? `calc(${SELECTION_CONTENT_WIDTH}px + var(--leaf-table-border-width))` : SELECTION_CONTENT_WIDTH
650
662
  }
651
663
  }),
652
664
  expandable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {