@pyck/react 0.0.3 → 0.0.6

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 (58) hide show
  1. package/dist/checkmark-fJPHeX8N.js +62 -0
  2. package/dist/close-button-r3blTfSH.js +141 -0
  3. package/dist/components/avatar/index.js +96 -11
  4. package/dist/components/button/index.js +1 -1
  5. package/dist/components/carousel/index.js +35 -10
  6. package/dist/components/checkbox/index.js +103 -22
  7. package/dist/components/checkmark/index.js +1 -1
  8. package/dist/components/combobox/index.js +30 -6
  9. package/dist/components/data-list/index.js +19 -8
  10. package/dist/components/date-picker/index.js +1 -1
  11. package/dist/components/dialog/index.js +45 -14
  12. package/dist/components/display-date-value/index.js +2 -2
  13. package/dist/components/display-value/index.js +1 -1
  14. package/dist/components/drawer/index.js +17 -1
  15. package/dist/components/drilldown-menu/index.js +209 -78
  16. package/dist/components/field/index.js +89 -16
  17. package/dist/components/floating-panel/index.js +54 -43
  18. package/dist/components/form/index.js +115 -26
  19. package/dist/components/highlight/index.js +52 -14
  20. package/dist/components/icon/index.js +1 -1
  21. package/dist/components/image/index.js +27 -2
  22. package/dist/components/input/index.js +47 -4
  23. package/dist/components/input-group/index.js +56 -14
  24. package/dist/components/json-form-builder/index.js +243 -85
  25. package/dist/components/logo/index.js +46 -19
  26. package/dist/components/menu/index.js +28 -6
  27. package/dist/components/number-input/index.js +46 -7
  28. package/dist/components/page-header/index.js +45 -12
  29. package/dist/components/pagination/index.js +35 -13
  30. package/dist/components/progress/index.js +47 -8
  31. package/dist/components/progress-circle/index.js +66 -17
  32. package/dist/components/radio-group/index.js +47 -6
  33. package/dist/components/scroll-area/index.js +64 -9
  34. package/dist/components/segment-group/index.js +34 -5
  35. package/dist/components/select/index.js +85 -21
  36. package/dist/components/show/index.js +1 -1
  37. package/dist/components/skeleton/index.js +44 -4
  38. package/dist/components/slider/index.js +134 -37
  39. package/dist/components/spotlight/index.js +269 -125
  40. package/dist/components/steps/index.js +26 -12
  41. package/dist/components/switch/index.js +160 -29
  42. package/dist/components/table/index.js +370 -66
  43. package/dist/components/tags-input/index.js +17 -7
  44. package/dist/components/textarea/index.js +47 -4
  45. package/dist/components/toast/index.js +28 -22
  46. package/dist/components/tooltip/index.js +71 -14
  47. package/dist/components/tree-view/index.js +45 -8
  48. package/dist/display-date-value-BAU46P8s.js +40 -0
  49. package/dist/display-value-Bz71ZqgM.js +57 -0
  50. package/dist/{featured-icon-DPysOpSf.js → featured-icon-CKDv0xfF.js} +27 -4
  51. package/dist/show-DAysVQAC.js +27 -0
  52. package/dist/utils/index.js +164 -73
  53. package/package.json +21 -3
  54. package/dist/checkmark-CW-yHMvN.js +0 -18
  55. package/dist/close-button-BM7ikbYh.js +0 -52
  56. package/dist/display-date-value-gTlidtNz.js +0 -21
  57. package/dist/display-value-BNKxQ99u.js +0 -37
  58. package/dist/show-IaI-36v9.js +0 -12
@@ -7,6 +7,7 @@ import { de, enGB, enUS } from "date-fns/locale";
7
7
  import { match } from "ts-pattern";
8
8
  import { z } from "zod";
9
9
  import { parseDate as parseDate$1 } from "@ark-ui/react/date-picker";
10
+ import { c } from "react/compiler-runtime";
10
11
  import { useCallback, useEffect, useRef, useState } from "react";
11
12
  import { useEnvironmentContext } from "@ark-ui/react/environment";
12
13
 
@@ -253,30 +254,62 @@ const partition = (arr, predicate) => arr.reduce(([pass, fail], item) => predica
253
254
 
254
255
  //#endregion
255
256
  //#region src/utils/use-auto-focus.ts
256
- const useAutoFocus = (shouldFocus = true) => {
257
+ const useAutoFocus = (t0) => {
258
+ const $ = c(3);
259
+ const shouldFocus = t0 === void 0 ? true : t0;
257
260
  const ref = useRef(null);
258
- useEffect(() => {
259
- if (shouldFocus) setTimeout(() => {
260
- ref.current?.focus();
261
- }, 0);
262
- }, [shouldFocus]);
261
+ let t1;
262
+ let t2;
263
+ if ($[0] !== shouldFocus) {
264
+ t1 = () => {
265
+ if (shouldFocus) setTimeout(() => {
266
+ ref.current?.focus();
267
+ }, 0);
268
+ };
269
+ t2 = [shouldFocus];
270
+ $[0] = shouldFocus;
271
+ $[1] = t1;
272
+ $[2] = t2;
273
+ } else {
274
+ t1 = $[1];
275
+ t2 = $[2];
276
+ }
277
+ useEffect(t1, t2);
263
278
  return ref;
264
279
  };
265
280
 
266
281
  //#endregion
267
282
  //#region src/utils/use-effect-once.ts
268
283
  const useEffectOnce = (cb) => {
284
+ const $ = c(4);
269
285
  const savedCallback = useRef(cb);
270
286
  const effectGuard = useRef(false);
271
- useEffect(() => {
272
- savedCallback.current = cb;
273
- });
274
- useEffect(() => {
275
- if (effectGuard.current !== true) {
276
- effectGuard.current = true;
277
- savedCallback.current();
278
- }
279
- }, []);
287
+ let t0;
288
+ if ($[0] !== cb) {
289
+ t0 = () => {
290
+ savedCallback.current = cb;
291
+ };
292
+ $[0] = cb;
293
+ $[1] = t0;
294
+ } else t0 = $[1];
295
+ useEffect(t0);
296
+ let t1;
297
+ let t2;
298
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
299
+ t1 = () => {
300
+ if (effectGuard.current !== true) {
301
+ effectGuard.current = true;
302
+ savedCallback.current();
303
+ }
304
+ };
305
+ t2 = [];
306
+ $[2] = t1;
307
+ $[3] = t2;
308
+ } else {
309
+ t1 = $[2];
310
+ t2 = $[3];
311
+ }
312
+ useEffect(t1, t2);
280
313
  };
281
314
 
282
315
  //#endregion
@@ -298,79 +331,137 @@ function isSetStateFunction(value) {
298
331
  * ```
299
332
  */
300
333
  function useHistoryState(initialValue, options) {
334
+ const $ = c(16);
301
335
  const limit = options?.limit ?? 10;
302
- const [{ history, index }, setHistoryState] = useState({
303
- history: [initialValue],
304
- index: 0
305
- });
336
+ let t0;
337
+ if ($[0] !== initialValue) {
338
+ t0 = {
339
+ history: [initialValue],
340
+ index: 0
341
+ };
342
+ $[0] = initialValue;
343
+ $[1] = t0;
344
+ } else t0 = $[1];
345
+ const [t1, setHistoryState] = useState(t0);
346
+ const { history, index } = t1;
306
347
  if (index >= history.length || index < 0) throw Error(`Impossible State reached: ${index} | ${history.length}`);
307
348
  const state = history[index];
308
- /**
309
- * Sets a new state value and adds it to the history.
310
- * If called after undo operations, discards any "future" states.
311
- */
312
- const setState = (setStateFnOrValue) => setHistoryState((prev) => {
313
- const currentState = prev.history[prev.index];
314
- const newState = isSetStateFunction(setStateFnOrValue) ? setStateFnOrValue(currentState) : setStateFnOrValue;
315
- if (prev.index !== prev.history.length - 1) return {
316
- history: [...prev.history.slice(0, prev.index + 1), newState],
317
- index: prev.index + 1
349
+ let t2;
350
+ if ($[2] !== limit) {
351
+ t2 = (setStateFnOrValue) => setHistoryState((prev) => {
352
+ const currentState = prev.history[prev.index];
353
+ const newState = isSetStateFunction(setStateFnOrValue) ? setStateFnOrValue(currentState) : setStateFnOrValue;
354
+ if (prev.index !== prev.history.length - 1) return {
355
+ history: [...prev.history.slice(0, prev.index + 1), newState],
356
+ index: prev.index + 1
357
+ };
358
+ if (prev.history.length >= limit) return {
359
+ history: [...prev.history.slice(1), newState],
360
+ index: prev.index
361
+ };
362
+ return {
363
+ history: [...prev.history, newState],
364
+ index: prev.index + 1
365
+ };
366
+ });
367
+ $[2] = limit;
368
+ $[3] = t2;
369
+ } else t2 = $[3];
370
+ const setState = t2;
371
+ let t3;
372
+ if ($[4] !== index) {
373
+ t3 = () => index > 0;
374
+ $[4] = index;
375
+ $[5] = t3;
376
+ } else t3 = $[5];
377
+ const canUndo = t3;
378
+ let t4;
379
+ if ($[6] !== history.length || $[7] !== index) {
380
+ t4 = () => index < history.length - 1;
381
+ $[6] = history.length;
382
+ $[7] = index;
383
+ $[8] = t4;
384
+ } else t4 = $[8];
385
+ const canRedo = t4;
386
+ let t5;
387
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
388
+ t5 = () => {
389
+ setHistoryState(_temp);
318
390
  };
319
- if (prev.history.length >= limit) return {
320
- history: [...prev.history.slice(1), newState],
321
- index: prev.index
391
+ $[9] = t5;
392
+ } else t5 = $[9];
393
+ const undo = t5;
394
+ let t6;
395
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
396
+ t6 = () => {
397
+ setHistoryState(_temp2);
322
398
  };
323
- return {
324
- history: [...prev.history, newState],
325
- index: prev.index + 1
399
+ $[10] = t6;
400
+ } else t6 = $[10];
401
+ const redo = t6;
402
+ let t7;
403
+ if ($[11] !== canRedo || $[12] !== canUndo || $[13] !== setState || $[14] !== state) {
404
+ t7 = {
405
+ state,
406
+ setState,
407
+ canUndo,
408
+ undo,
409
+ canRedo,
410
+ redo
326
411
  };
327
- });
328
- /**
329
- * Returns whether there are previous states available to undo to.
330
- */
331
- const canUndo = useCallback(() => index > 0, [index]);
332
- /**
333
- * Returns whether there are future states available to redo to.
334
- */
335
- const canRedo = useCallback(() => index < history.length - 1, [index, history.length]);
412
+ $[11] = canRedo;
413
+ $[12] = canUndo;
414
+ $[13] = setState;
415
+ $[14] = state;
416
+ $[15] = t7;
417
+ } else t7 = $[15];
418
+ return t7;
419
+ }
420
+ function _temp2(prev_1) {
421
+ return {
422
+ ...prev_1,
423
+ index: Math.min(prev_1.history.length - 1, prev_1.index + 1)
424
+ };
425
+ }
426
+ function _temp(prev_0) {
336
427
  return {
337
- state,
338
- setState,
339
- canUndo,
340
- undo: useCallback(() => {
341
- setHistoryState((prev) => ({
342
- ...prev,
343
- index: Math.max(0, prev.index - 1)
344
- }));
345
- }, []),
346
- canRedo,
347
- redo: useCallback(() => {
348
- setHistoryState((prev) => ({
349
- ...prev,
350
- index: Math.min(prev.history.length - 1, prev.index + 1)
351
- }));
352
- }, [])
428
+ ...prev_0,
429
+ index: Math.max(0, prev_0.index - 1)
353
430
  };
354
431
  }
355
432
 
356
433
  //#endregion
357
434
  //#region src/utils/use-hotkey.ts
358
435
  const useHotkey = (setOpen) => {
436
+ const $ = c(4);
359
437
  const env = useEnvironmentContext();
360
- useEffect(() => {
361
- const document = env.getDocument();
362
- const hotkey = /(Mac|iPhone|iPod|iPad)/i.test(navigator?.platform) ? "metaKey" : "ctrlKey";
363
- const handleKeydown = (event) => {
364
- if (event.key?.toLowerCase() === "k" && event[hotkey]) {
365
- event.preventDefault();
366
- setOpen(true);
367
- }
368
- };
369
- document.addEventListener("keydown", handleKeydown, true);
370
- return () => {
371
- document.removeEventListener("keydown", handleKeydown, true);
438
+ let t0;
439
+ let t1;
440
+ if ($[0] !== env || $[1] !== setOpen) {
441
+ t0 = () => {
442
+ const document = env.getDocument();
443
+ const hotkey = /(Mac|iPhone|iPod|iPad)/i.test(navigator?.platform) ? "metaKey" : "ctrlKey";
444
+ const handleKeydown = (event) => {
445
+ if (event.key?.toLowerCase() === "k" && event[hotkey]) {
446
+ event.preventDefault();
447
+ setOpen(true);
448
+ }
449
+ };
450
+ document.addEventListener("keydown", handleKeydown, true);
451
+ return () => {
452
+ document.removeEventListener("keydown", handleKeydown, true);
453
+ };
372
454
  };
373
- }, [env, setOpen]);
455
+ t1 = [env, setOpen];
456
+ $[0] = env;
457
+ $[1] = setOpen;
458
+ $[2] = t0;
459
+ $[3] = t1;
460
+ } else {
461
+ t0 = $[2];
462
+ t1 = $[3];
463
+ }
464
+ useEffect(t0, t1);
374
465
  };
375
466
 
376
467
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pyck/react",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.6",
5
5
  "license": "MIT",
6
6
  "homepage": "https://pyck.ai",
7
7
  "repository": {
@@ -25,6 +25,14 @@
25
25
  "postpack": "bunx clean-package restore"
26
26
  },
27
27
  "exports": {
28
+ "./types": {
29
+ "types": "./dist/types/index.d.ts",
30
+ "default": "./dist/types/index.js"
31
+ },
32
+ "./utils": {
33
+ "types": "./dist/utils/index.d.ts",
34
+ "default": "./dist/utils/index.js"
35
+ },
28
36
  "./*": {
29
37
  "types": "./dist/components/*/index.d.ts",
30
38
  "default": "./dist/components/*/index.js"
@@ -45,7 +53,8 @@
45
53
  },
46
54
  "devDependencies": {
47
55
  "@hookform/resolvers": "5.2.2",
48
- "@pyck/styled-system": "0.0.3",
56
+ "@pyck/styled-system": "0.0.6",
57
+ "@rollup/plugin-babel": "6.1.0",
49
58
  "@storybook/react": "10.2.10",
50
59
  "@testing-library/dom": "10.4.1",
51
60
  "@testing-library/jest-dom": "6.9.1",
@@ -54,6 +63,7 @@
54
63
  "@types/react": "19.2.10",
55
64
  "@types/react-dom": "19.2.3",
56
65
  "@vitejs/plugin-react-swc": "4.2.3",
66
+ "babel-plugin-react-compiler": "1.0.0",
57
67
  "happy-dom": "20.6.3",
58
68
  "lorem-ipsum": "2.0.8",
59
69
  "react": "19.2.4",
@@ -67,7 +77,7 @@
67
77
  "zod": "4.3.6"
68
78
  },
69
79
  "peerDependencies": {
70
- "@pyck/styled-system": ">=0.0.3",
80
+ "@pyck/styled-system": ">=0.0.6",
71
81
  "react": ">=18.0.0",
72
82
  "react-dom": ">=18.0.0",
73
83
  "react-hook-form": ">=7.0.0",
@@ -77,6 +87,14 @@
77
87
  "clean-package": {
78
88
  "replace": {
79
89
  "exports": {
90
+ "./types": {
91
+ "types": "./dist/types/index.d.ts",
92
+ "default": "./dist/types/index.js"
93
+ },
94
+ "./utils": {
95
+ "types": "./dist/utils/index.d.ts",
96
+ "default": "./dist/utils/index.js"
97
+ },
80
98
  "./*": {
81
99
  "types": "./dist/components/*/index.d.ts",
82
100
  "default": "./dist/components/*/index.js"
@@ -1,18 +0,0 @@
1
- import { forwardRef } from "react";
2
- import { ark } from "@ark-ui/react/factory";
3
- import { styled } from "@pyck/styled-system/jsx";
4
- import { checkmark } from "@pyck/styled-system/recipes";
5
- import { dataAttr } from "@pyck/react/utils";
6
-
7
- //#region src/components/checkmark/checkmark.tsx
8
- const StyledCheckmark = styled(ark.svg, checkmark);
9
- const Checkmark = forwardRef(function Checkmark(props, ref) {
10
- const { checked, indeterminate, disabled, ...rest } = props;
11
- return <StyledCheckmark ref={ref} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3px" strokeLinecap="round" strokeLinejoin="round" data-state={indeterminate ? "indeterminate" : checked ? "checked" : "unchecked"} data-disabled={dataAttr(disabled)} {...rest}>
12
- <title>Checkmark</title>
13
- {indeterminate ? <path d="M5 12h14" /> : checked ? <path d="M20 6 9 17l-5-5" /> : null}
14
- </StyledCheckmark>;
15
- });
16
-
17
- //#endregion
18
- export { Checkmark as t };
@@ -1,52 +0,0 @@
1
- import { createContext, mergeProps } from "@ark-ui/react/utils";
2
- import { forwardRef, useMemo } from "react";
3
- import { ark } from "@ark-ui/react/factory";
4
- import { styled } from "@pyck/styled-system/jsx";
5
- import { button } from "@pyck/styled-system/recipes";
6
- import { XIcon } from "lucide-react";
7
- import { Loader } from "@pyck/react/loader";
8
- import { Group } from "@pyck/react/group";
9
-
10
- //#region src/components/button/button-group.tsx
11
- const ButtonGroup = forwardRef(function ButtonGroup(props, ref) {
12
- const [variantProps, otherProps] = useMemo(() => button.splitVariantProps(props), [props]);
13
- return <ButtonPropsProvider value={variantProps}>
14
- <Group ref={ref} {...otherProps} />
15
- </ButtonPropsProvider>;
16
- });
17
- const [ButtonPropsProvider, useButtonPropsContext] = createContext({
18
- name: "ButtonPropsContext",
19
- hookName: "useButtonPropsContext",
20
- providerName: "<PropsProvider />",
21
- strict: false
22
- });
23
-
24
- //#endregion
25
- //#region src/components/button/button.tsx
26
- const BaseButton = styled(ark.button, button);
27
- const Button = forwardRef(function Button(props, ref) {
28
- const propsContext = useButtonPropsContext();
29
- const { loading, loadingText, children, spinner, spinnerPlacement, ...rest } = useMemo(() => mergeProps(propsContext, props), [propsContext, props]);
30
- return <BaseButton type="button" ref={ref} {...rest} data-loading={loading ? "" : void 0} disabled={loading || rest.disabled}>
31
- {!props.asChild && loading ? <Loader spinner={spinner} text={loadingText} spinnerPlacement={spinnerPlacement}>
32
- {children}
33
- </Loader> : children}
34
- </BaseButton>;
35
- });
36
-
37
- //#endregion
38
- //#region src/components/button/icon-button.tsx
39
- const IconButton = forwardRef(function IconButton(props, ref) {
40
- return <Button px="0" py="0" ref={ref} {...props} />;
41
- });
42
-
43
- //#endregion
44
- //#region src/components/button/close-button.tsx
45
- const CloseButton = forwardRef(function CloseButton(props, ref) {
46
- return <IconButton variant="plain" color="fg.muted" aria-label="Close" ref={ref} {...props}>
47
- <XIcon />
48
- </IconButton>;
49
- });
50
-
51
- //#endregion
52
- export { ButtonGroup as i, IconButton as n, Button as r, CloseButton as t };
@@ -1,21 +0,0 @@
1
- import { t as DisplayValue } from "./display-value-BNKxQ99u.js";
2
- import { formatDate, formatDateTime, getDateFormats, isString } from "@pyck/react/utils";
3
-
4
- //#region src/components/display-date-value/display-date-value.tsx
5
- const DisplayDateValue = (props) => {
6
- const { value, format, copyable, type = "date", locale: localeProp } = props;
7
- const locale = localeProp ?? "en-US";
8
- const formatValue = (date) => {
9
- if (format && isString(format) && !isDateFormatKey(format, locale)) return formatDate(date, format, locale);
10
- if (format && isDateFormatKey(format, locale)) return formatDate(date, getDateFormats(locale)[format], locale);
11
- return formatDateTime(date, type, locale);
12
- };
13
- return <DisplayValue value={value} formatValue={formatValue} copyable={copyable} />;
14
- };
15
- const isDateFormatKey = (format, locale) => {
16
- const formats = getDateFormats(locale);
17
- return Object.keys(formats).includes(format);
18
- };
19
-
20
- //#endregion
21
- export { DisplayDateValue as t };
@@ -1,37 +0,0 @@
1
- import { HStack, VisuallyHidden } from "@pyck/styled-system/jsx";
2
- import { isString } from "@pyck/react/utils";
3
- import { Show } from "@pyck/react/show";
4
- import { Clipboard } from "@pyck/react/clipboard";
5
- import { Span } from "@pyck/react/span";
6
- import { Wrap } from "@pyck/react/wrap";
7
-
8
- //#region src/components/display-value/display-value.tsx
9
- const DisplayValue = (props) => {
10
- const { value, copyable, formatValue } = props;
11
- const formattedValue = isNotEmpty(value) ? formatValue?.(value) ?? String(value) : null;
12
- return <Show when={formattedValue != null} fallback={<>
13
- <Span color="fg.subtle" aria-hidden>
14
-
15
- </Span>
16
- <VisuallyHidden>No value</VisuallyHidden>
17
- </>}>
18
- <Wrap when={copyable} with={(children) => <Clipboard.Root value={formattedValue} timeout={400}>
19
- <Clipboard.Trigger _hover={{ "& [data-part=\"indicator\"]": { opacity: 1 } }} _active={{ "& [data-part=\"indicator\"]": { opacity: 1 } }}>
20
- <HStack>
21
- <Clipboard.Indicator color="fg.subtle" opacity="0" />
22
- <Span>{children}</Span>
23
- </HStack>
24
- </Clipboard.Trigger>
25
- </Clipboard.Root>}>
26
- {formattedValue}
27
- </Wrap>
28
- </Show>;
29
- };
30
- const isNotEmpty = (value) => {
31
- if (value == null) return false;
32
- if (isString(value) || Array.isArray(value)) return value.length > 0;
33
- return true;
34
- };
35
-
36
- //#endregion
37
- export { DisplayValue as t };
@@ -1,12 +0,0 @@
1
- import { isValidElement } from "react";
2
-
3
- //#region src/components/show/show.tsx
4
- function Show(props) {
5
- const { when, fallback, children } = props;
6
- if (!when) return fallback ?? null;
7
- const result = typeof children === "function" ? children(when) : children;
8
- return isValidElement(result) ? result : <>{result}</>;
9
- }
10
-
11
- //#endregion
12
- export { Show as t };