@sia.soul/sia-react-ui 0.1.142 → 0.1.144

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 (47) hide show
  1. package/dist/{Button-BiL3Wjsd.d.ts → Button-C8W8ZHWV.d.ts} +1 -1
  2. package/dist/{Button-O_pNB3SQ.d.cts → Button-CxKBjLda.d.cts} +1 -1
  3. package/dist/{Select-DeD4O8FL.d.ts → Select-CTSd8zum.d.ts} +14 -10
  4. package/dist/{Select-Y0e9kaxE.d.cts → Select-bKLket9n.d.cts} +14 -10
  5. package/dist/chart.cjs +1051 -335
  6. package/dist/chart.js +5 -5
  7. package/dist/chunk-4OHS7RXE.js +1004 -0
  8. package/dist/{chunk-WIRIEIRO.js → chunk-4TYHSAR3.js} +5 -5
  9. package/dist/{chunk-TUGCP3GB.js → chunk-566S64IP.js} +5 -5
  10. package/dist/{chunk-CZ2ITBRW.js → chunk-7SEGBB6V.js} +34 -5
  11. package/dist/{chunk-KY6A5IJH.js → chunk-ETQJ2DQ2.js} +1 -1
  12. package/dist/{chunk-WD56MJO2.js → chunk-F52O2MOV.js} +7 -3
  13. package/dist/{chunk-PQBCD54U.js → chunk-JRXYM5YH.js} +167 -64
  14. package/dist/{chunk-SCEHVGKV.js → chunk-LKLPCYEP.js} +2 -2
  15. package/dist/{chunk-3KYG7IU7.js → chunk-MD4CGSOR.js} +105 -61
  16. package/dist/{chunk-PGP4TEPP.js → chunk-ORSQAJ22.js} +154 -494
  17. package/dist/{chunk-SO7IJZIR.js → chunk-PD3K5U5Y.js} +2 -2
  18. package/dist/{chunk-UVHC6OEX.js → chunk-WCYVBO2N.js} +342 -123
  19. package/dist/{core-DYo5C4Si.d.cts → core-COaZfusa.d.cts} +51 -24
  20. package/dist/{core-sWwvVAmP.d.ts → core-CvfsQGuT.d.ts} +51 -24
  21. package/dist/core.cjs +1996 -1250
  22. package/dist/core.css +413 -344
  23. package/dist/core.d.cts +3 -3
  24. package/dist/core.d.ts +3 -3
  25. package/dist/core.js +18 -9
  26. package/dist/game.cjs +1984 -1169
  27. package/dist/game.css +182 -177
  28. package/dist/game.d.cts +1 -1
  29. package/dist/game.d.ts +1 -1
  30. package/dist/game.js +8 -3
  31. package/dist/index.cjs +4660 -3541
  32. package/dist/index.css +413 -344
  33. package/dist/index.d.cts +78 -81
  34. package/dist/index.d.ts +78 -81
  35. package/dist/index.js +1083 -715
  36. package/dist/markdown-editor.cjs +727 -40
  37. package/dist/markdown-editor.js +8 -3
  38. package/dist/rich-text-editor.cjs +1265 -308
  39. package/dist/rich-text-editor.js +12 -7
  40. package/dist/{select-date-range-X6a9Y-Te.d.ts → select-date-range-C8cacfmb.d.ts} +1 -1
  41. package/dist/{select-date-range-DiBQQ0Rn.d.cts → select-date-range-Dad0IdD4.d.cts} +1 -1
  42. package/dist/select-date-range.cjs +1277 -806
  43. package/dist/select-date-range.d.cts +3 -3
  44. package/dist/select-date-range.d.ts +3 -3
  45. package/dist/select-date-range.js +13 -8
  46. package/package.json +9 -2
  47. package/dist/chunk-NZMUW5XI.js +0 -292
@@ -1,5 +1,5 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-DiBQQ0Rn.cjs';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-Dad0IdD4.cjs';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.cjs';
4
- import './Select-Y0e9kaxE.cjs';
5
- import './Button-O_pNB3SQ.cjs';
4
+ import './Select-bKLket9n.cjs';
5
+ import './Button-CxKBjLda.cjs';
@@ -1,5 +1,5 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-X6a9Y-Te.js';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-C8cacfmb.js';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.js';
4
- import './Select-DeD4O8FL.js';
5
- import './Button-BiL3Wjsd.js';
4
+ import './Select-CTSd8zum.js';
5
+ import './Button-C8W8ZHWV.js';
@@ -1,13 +1,18 @@
1
1
  import {
2
2
  SelectDateRange
3
- } from "./chunk-TUGCP3GB.js";
4
- import "./chunk-PGP4TEPP.js";
5
- import "./chunk-UVHC6OEX.js";
6
- import "./chunk-SCEHVGKV.js";
7
- import "./chunk-PQBCD54U.js";
8
- import "./chunk-CZ2ITBRW.js";
9
- import "./chunk-KY6A5IJH.js";
10
- import "./chunk-NZMUW5XI.js";
3
+ } from "./chunk-566S64IP.js";
4
+ import "./chunk-ORSQAJ22.js";
5
+ import "./chunk-WCYVBO2N.js";
6
+ import "./chunk-LKLPCYEP.js";
7
+ import "./chunk-JRXYM5YH.js";
8
+ import "./chunk-7SEGBB6V.js";
9
+ import "./chunk-ETQJ2DQ2.js";
10
+ import {
11
+ initializeDefaultScrollbars
12
+ } from "./chunk-4OHS7RXE.js";
13
+
14
+ // src/select-date-range.ts
15
+ initializeDefaultScrollbars();
11
16
  export {
12
17
  SelectDateRange
13
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.142",
3
+ "version": "0.1.144",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -11,7 +11,14 @@
11
11
  "module": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts",
13
13
  "sideEffects": [
14
- "**/*.css"
14
+ "**/*.css",
15
+ "./dist/index.*",
16
+ "./dist/core.*",
17
+ "./dist/select-date-range.*",
18
+ "./dist/rich-text-editor.*",
19
+ "./dist/markdown-editor.*",
20
+ "./dist/chart.*",
21
+ "./dist/game.*"
15
22
  ],
16
23
  "exports": {
17
24
  ".": {
@@ -1,292 +0,0 @@
1
- // src/components/titleTooltip.tsx
2
- import { createRoot } from "react-dom/client";
3
- import { jsx } from "react/jsx-runtime";
4
- var documents = /* @__PURE__ */ new WeakSet();
5
- function withTitleTooltip(props) {
6
- if (!props || typeof props !== "object" || !("title" in props)) return props;
7
- const { title, ...rest } = props;
8
- if (typeof document !== "undefined") installTitleTooltips(document);
9
- return { ...rest, "data-sia-title": title == null ? void 0 : String(title) };
10
- }
11
- function installTitleTooltips(doc) {
12
- if (documents.has(doc)) return;
13
- documents.add(doc);
14
- let hovered = null;
15
- let focused = null;
16
- let keyboardFocus = true;
17
- let active = null;
18
- let pending = null;
19
- let timer;
20
- let root;
21
- let observer;
22
- let tooltipId = "";
23
- const canShow = (element) => {
24
- if (!element.hasAttribute("data-sia-title-overflow-only")) return true;
25
- return [element, ...element.querySelectorAll("*")].some((node) => {
26
- if (node.clientWidth <= 0 || node.scrollWidth <= node.clientWidth) return false;
27
- const style = doc.defaultView?.getComputedStyle(node);
28
- return style?.textOverflow === "ellipsis" && (style.overflowX === "hidden" || style.overflowX === "clip");
29
- });
30
- };
31
- const candidate = (target) => {
32
- if (!(target instanceof Element)) return null;
33
- const element = target.closest("[data-sia-title]");
34
- return element?.getAttribute("data-sia-title") && !element.closest(".sia-floating") && canShow(element) ? element : null;
35
- };
36
- const hasExplicitTooltip = (target) => target instanceof Element && Boolean(target.closest(".sia-floating"));
37
- const hide = () => {
38
- clearTimeout(timer);
39
- pending = null;
40
- observer?.disconnect();
41
- observer = void 0;
42
- if (active) {
43
- const ids = (active.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((id) => id && id !== tooltipId);
44
- if (ids.length) active.setAttribute("aria-describedby", ids.join(" "));
45
- else active.removeAttribute("aria-describedby");
46
- }
47
- active = null;
48
- root?.render(null);
49
- };
50
- const render = () => {
51
- const text = active?.getAttribute("data-sia-title");
52
- if (!active?.isConnected || !text || !canShow(active)) {
53
- hide();
54
- return;
55
- }
56
- if (!root) {
57
- const host = doc.createElement("div");
58
- host.setAttribute("data-sia-title-tooltip-host", "");
59
- doc.body.append(host);
60
- root = createRoot(host);
61
- tooltipId = `sia-title-tooltip-${Math.random().toString(36).slice(2)}`;
62
- }
63
- const ids = new Set((active.getAttribute("aria-describedby") ?? "").split(/\s+/).filter(Boolean));
64
- ids.add(tooltipId);
65
- active.setAttribute("aria-describedby", [...ids].join(" "));
66
- root.render(/* @__PURE__ */ jsx(
67
- PopupPortal,
68
- {
69
- anchorRef: { current: active },
70
- placement: "top-start",
71
- id: tooltipId,
72
- role: "tooltip",
73
- className: "sia-title-tooltip",
74
- children: text
75
- }
76
- ));
77
- };
78
- const show = (element) => {
79
- if (!element && !active && !pending) return;
80
- if (element && (element === active || element === pending)) return;
81
- hide();
82
- if (!element) return;
83
- pending = element;
84
- timer = setTimeout(() => {
85
- pending = null;
86
- if (!element.isConnected) return;
87
- active = element;
88
- render();
89
- if (!active) return;
90
- observer = new MutationObserver(() => {
91
- if (!active?.isConnected) hide();
92
- else if (active.getAttribute("data-sia-title") !== doc.getElementById(tooltipId)?.textContent) render();
93
- });
94
- observer.observe(doc.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-sia-title"] });
95
- }, 600);
96
- };
97
- doc.addEventListener("pointerover", (event) => {
98
- if (event.pointerType === "touch") return;
99
- hovered = candidate(event.target);
100
- if (hasExplicitTooltip(event.target)) hide();
101
- else show(hovered ?? focused);
102
- }, true);
103
- doc.addEventListener("pointermove", (event) => {
104
- if (event.pointerType === "touch" || event.buttons) return;
105
- hovered = candidate(event.target);
106
- if (!hasExplicitTooltip(event.target)) show(hovered ?? focused);
107
- }, true);
108
- doc.addEventListener("pointerout", (event) => {
109
- if (event.pointerType === "touch") return;
110
- hovered = candidate(event.relatedTarget);
111
- if (hasExplicitTooltip(event.relatedTarget)) hide();
112
- else show(hovered ?? focused);
113
- }, true);
114
- doc.addEventListener("focusin", (event) => {
115
- focused = keyboardFocus ? candidate(event.target) : null;
116
- if (hasExplicitTooltip(event.target)) hide();
117
- else if (keyboardFocus) show(focused ?? hovered);
118
- }, true);
119
- doc.addEventListener("focusout", (event) => {
120
- focused = keyboardFocus ? candidate(event.relatedTarget) : null;
121
- show(hovered ?? focused);
122
- }, true);
123
- doc.addEventListener("pointerdown", () => {
124
- keyboardFocus = false;
125
- focused = null;
126
- hide();
127
- }, true);
128
- doc.addEventListener("keydown", (event) => {
129
- if (event.key === "Escape") hide();
130
- else if (event.key === "Tab") keyboardFocus = true;
131
- }, true);
132
- doc.addEventListener("scroll", hide, true);
133
- doc.addEventListener("visibilitychange", () => {
134
- if (doc.hidden) {
135
- hovered = focused = null;
136
- hide();
137
- }
138
- });
139
- doc.defaultView?.addEventListener("blur", () => {
140
- hovered = focused = null;
141
- hide();
142
- });
143
- }
144
-
145
- // src/components/PopupPortal.tsx
146
- import { forwardRef, useLayoutEffect, useRef, useState } from "react";
147
- import { createPortal } from "react-dom";
148
- import { jsx as jsx2 } from "react/jsx-runtime";
149
- function setForwardedRef(ref, value) {
150
- if (typeof ref === "function") ref(value);
151
- else if (ref) ref.current = value;
152
- }
153
- function clamp(value, min, max) {
154
- return Math.min(Math.max(value, min), Math.max(min, max));
155
- }
156
- var PopupPortal = forwardRef(function PopupPortal2({
157
- anchorRef,
158
- open = true,
159
- placement = "bottom-start",
160
- offset = 6,
161
- viewportPadding = 8,
162
- className = "",
163
- style,
164
- children,
165
- ...props
166
- }, forwardedRef) {
167
- const popupRef = useRef(null);
168
- const [position, setPosition] = useState();
169
- useLayoutEffect(() => {
170
- if (!open || typeof document === "undefined") {
171
- setPosition(void 0);
172
- return;
173
- }
174
- const update = () => {
175
- const anchor = anchorRef.current;
176
- const popup = popupRef.current;
177
- if (!anchor || !popup) return;
178
- const anchorRect = anchor.getBoundingClientRect();
179
- const popupRect = popup.getBoundingClientRect();
180
- const viewportWidth = document.documentElement.clientWidth;
181
- const viewportHeight = document.documentElement.clientHeight;
182
- let resolvedPlacement = placement;
183
- const availableBelow = Math.max(0, viewportHeight - viewportPadding - anchorRect.bottom - offset);
184
- const availableAbove = Math.max(0, anchorRect.top - offset - viewportPadding);
185
- const availableRight = Math.max(0, viewportWidth - viewportPadding - anchorRect.right - offset);
186
- const availableLeft = Math.max(0, anchorRect.left - offset - viewportPadding);
187
- const horizontalSide = placement.startsWith("right") || placement.startsWith("left");
188
- if (horizontalSide) {
189
- const prefersRight = placement.startsWith("right");
190
- const fitsRight = popupRect.width <= availableRight;
191
- const fitsLeft = popupRect.width <= availableLeft;
192
- if (prefersRight && !fitsRight && (fitsLeft || availableLeft > availableRight)) {
193
- resolvedPlacement = placement.replace("right", "left");
194
- } else if (!prefersRight && !fitsLeft && (fitsRight || availableRight > availableLeft)) {
195
- resolvedPlacement = placement.replace("left", "right");
196
- }
197
- } else {
198
- const prefersBottom = placement.startsWith("bottom");
199
- const fitsBelow = popupRect.height <= availableBelow;
200
- const fitsAbove = popupRect.height <= availableAbove;
201
- if (prefersBottom && !fitsBelow && (fitsAbove || availableAbove > availableBelow)) {
202
- resolvedPlacement = placement.replace("bottom", "top");
203
- } else if (!prefersBottom && !fitsAbove && (fitsBelow || availableBelow > availableAbove)) {
204
- resolvedPlacement = placement.replace("top", "bottom");
205
- }
206
- }
207
- const resolvedHorizontalSide = resolvedPlacement.startsWith("right") || resolvedPlacement.startsWith("left");
208
- const top = resolvedHorizontalSide ? resolvedPlacement.endsWith("end") ? anchorRect.bottom - popupRect.height : anchorRect.top : resolvedPlacement.startsWith("bottom") ? anchorRect.bottom + offset : anchorRect.top - popupRect.height - offset;
209
- const availableHeight = resolvedHorizontalSide ? Math.max(0, viewportHeight - viewportPadding * 2) : resolvedPlacement.startsWith("bottom") ? availableBelow : availableAbove;
210
- const alignedLeft = resolvedHorizontalSide ? resolvedPlacement.startsWith("right") ? anchorRect.right + offset : anchorRect.left - popupRect.width - offset : resolvedPlacement.endsWith("end") ? anchorRect.right - popupRect.width : anchorRect.left;
211
- const next = {
212
- top: clamp(top, viewportPadding, viewportHeight - popupRect.height - viewportPadding),
213
- left: clamp(alignedLeft, viewportPadding, viewportWidth - popupRect.width - viewportPadding),
214
- anchorWidth: anchorRect.width,
215
- availableHeight,
216
- placement: resolvedPlacement
217
- };
218
- setPosition((current) => current && current.top === next.top && current.left === next.left && current.anchorWidth === next.anchorWidth && current.availableHeight === next.availableHeight && current.placement === next.placement ? current : next);
219
- };
220
- update();
221
- window.addEventListener("resize", update);
222
- window.addEventListener("scroll", update, true);
223
- const observer = new ResizeObserver(update);
224
- if (anchorRef.current) observer.observe(anchorRef.current);
225
- if (popupRef.current) observer.observe(popupRef.current);
226
- return () => {
227
- window.removeEventListener("resize", update);
228
- window.removeEventListener("scroll", update, true);
229
- observer.disconnect();
230
- };
231
- }, [anchorRef, offset, open, placement, viewportPadding]);
232
- if (!open || typeof document === "undefined") return null;
233
- return createPortal(
234
- /* @__PURE__ */ jsx2(
235
- "div",
236
- {
237
- ref: (node) => {
238
- popupRef.current = node;
239
- setForwardedRef(forwardedRef, node);
240
- },
241
- className: `sia-popup-portal ${className}`.trim(),
242
- "data-sia-popup-layer": "",
243
- "data-placement": position?.placement ?? placement,
244
- style: {
245
- ...style,
246
- "--sia-popup-anchor-width": `${position?.anchorWidth ?? anchorRef.current?.getBoundingClientRect().width ?? 0}px`,
247
- "--sia-popup-available-height": position ? `${position.availableHeight}px` : void 0,
248
- top: position?.top ?? 0,
249
- left: position?.left ?? 0,
250
- visibility: position ? "visible" : "hidden"
251
- },
252
- ...withTitleTooltip(props),
253
- children
254
- }
255
- ),
256
- document.body
257
- );
258
- });
259
-
260
- // src/components/shared.ts
261
- import { createContext, useCallback, useContext, useState as useState2 } from "react";
262
- var ControlSizeContext = createContext("medium");
263
- function useControlSize(size) {
264
- const inherited = useContext(ControlSizeContext);
265
- return size ?? inherited;
266
- }
267
- var PlaceholderModeContext = createContext("default");
268
- function usePlaceholderMode(mode) {
269
- const inherited = useContext(PlaceholderModeContext);
270
- return mode ?? inherited;
271
- }
272
- function useControllableState({ value, defaultValue, onChange }) {
273
- const [internalValue, setInternalValue] = useState2(defaultValue);
274
- const controlled = value !== void 0;
275
- const currentValue = controlled ? value : internalValue;
276
- const setValue = useCallback((nextValue) => {
277
- if (Object.is(currentValue, nextValue)) return;
278
- if (!controlled) setInternalValue(nextValue);
279
- onChange?.(nextValue);
280
- }, [controlled, currentValue, onChange]);
281
- return [currentValue, setValue];
282
- }
283
-
284
- export {
285
- PopupPortal,
286
- withTitleTooltip,
287
- ControlSizeContext,
288
- useControlSize,
289
- PlaceholderModeContext,
290
- usePlaceholderMode,
291
- useControllableState
292
- };