@a-type/ui 1.1.24 → 1.1.26

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 (48) hide show
  1. package/dist/cjs/components/index.d.ts +50 -0
  2. package/dist/cjs/components/index.js +71 -0
  3. package/dist/cjs/components/index.js.map +1 -0
  4. package/dist/cjs/components/input/Input.js +2 -11
  5. package/dist/cjs/components/input/Input.js.map +1 -1
  6. package/dist/cjs/components/layouts/PageContent.js +1 -1
  7. package/dist/cjs/components/layouts/PageContent.js.map +1 -1
  8. package/dist/cjs/components/provider/Provider.js +3 -1
  9. package/dist/cjs/components/provider/Provider.js.map +1 -1
  10. package/dist/cjs/components/textArea/TextArea.d.ts +2 -0
  11. package/dist/cjs/components/textArea/TextArea.js +4 -2
  12. package/dist/cjs/components/textArea/TextArea.js.map +1 -1
  13. package/dist/cjs/hooks/useRotatingShuffledValue.d.ts +1 -0
  14. package/dist/cjs/hooks/useRotatingShuffledValue.js +19 -0
  15. package/dist/cjs/hooks/useRotatingShuffledValue.js.map +1 -0
  16. package/dist/cjs/index.d.ts +2 -0
  17. package/dist/cjs/index.js +16 -0
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/cjs/uno.preset.js +3 -3
  20. package/dist/css/main.css +4 -4
  21. package/dist/esm/components/index.d.ts +50 -0
  22. package/dist/esm/components/index.js +52 -0
  23. package/dist/esm/components/index.js.map +1 -0
  24. package/dist/esm/components/input/Input.js +3 -12
  25. package/dist/esm/components/input/Input.js.map +1 -1
  26. package/dist/esm/components/layouts/PageContent.js +1 -1
  27. package/dist/esm/components/layouts/PageContent.js.map +1 -1
  28. package/dist/esm/components/provider/Provider.js +3 -1
  29. package/dist/esm/components/provider/Provider.js.map +1 -1
  30. package/dist/esm/components/textArea/TextArea.d.ts +2 -0
  31. package/dist/esm/components/textArea/TextArea.js +4 -2
  32. package/dist/esm/components/textArea/TextArea.js.map +1 -1
  33. package/dist/esm/hooks/useRotatingShuffledValue.d.ts +1 -0
  34. package/dist/esm/hooks/useRotatingShuffledValue.js +15 -0
  35. package/dist/esm/hooks/useRotatingShuffledValue.js.map +1 -0
  36. package/dist/esm/index.d.ts +2 -0
  37. package/dist/esm/index.js +2 -0
  38. package/dist/esm/index.js.map +1 -1
  39. package/dist/esm/uno.preset.js +3 -3
  40. package/package.json +1 -1
  41. package/src/components/index.ts +50 -0
  42. package/src/components/input/Input.tsx +5 -24
  43. package/src/components/layouts/PageContent.tsx +1 -1
  44. package/src/components/provider/Provider.tsx +3 -1
  45. package/src/components/textArea/TextArea.tsx +12 -1
  46. package/src/hooks/useRotatingShuffledValue.ts +20 -0
  47. package/src/index.ts +3 -0
  48. package/src/uno.preset.ts +3 -3
@@ -0,0 +1,15 @@
1
+ // @unocss-include
2
+ import { useEffect, useState } from 'react';
3
+ export function useRotatingShuffledValue(options, intervalMs = 5000) {
4
+ const [selected, setSelected] = useState(options ? options[Math.floor(Math.random() * options.length)] : undefined);
5
+ useEffect(() => {
6
+ if (options) {
7
+ const interval = setInterval(() => {
8
+ setSelected(options[Math.floor(Math.random() * options.length)]);
9
+ }, intervalMs);
10
+ return () => clearInterval(interval);
11
+ }
12
+ }, [options, intervalMs]);
13
+ return selected;
14
+ }
15
+ //# sourceMappingURL=useRotatingShuffledValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRotatingShuffledValue.js","sourceRoot":"","sources":["../../../src/hooks/useRotatingShuffledValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,UAAU,wBAAwB,CACvC,OAAY,EACZ,UAAU,GAAG,IAAI;IAEjB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CACvC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CACzE,CAAC;IACF,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,OAAO,EAAE;YACZ,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;gBACjC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAClE,CAAC,EAAE,UAAU,CAAC,CAAC;YACf,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;SACrC;IACF,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAE1B,OAAO,QAAQ,CAAC;AACjB,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export { clsx } from 'clsx';
2
2
  export { toast } from 'react-hot-toast';
3
+ export * from './hooks.js';
4
+ export * from './components/index.js';
package/dist/esm/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // @unocss-include
2
2
  export { clsx } from 'clsx';
3
3
  export { toast } from 'react-hot-toast';
4
+ export * from './hooks.js';
5
+ export * from './components/index.js';
4
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
@@ -431,9 +431,9 @@ export default function presetAglio({ spacingIncrement = 0.25, interFontLocation
431
431
  --palette-blue-00: #00354a;
432
432
  --palette-purple-90: #f1efff;
433
433
  --palette-purple-80: #e0e0ff;
434
- --palette-purple-70: #bdc2ff;
435
- --palette-purple-60: #a0a8ff;
436
- --palette-purple-50: #7c87f3;
434
+ --palette-purple-70: #c8cdff;
435
+ --palette-purple-60: #aab1ff;
436
+ --palette-purple-50: #8490f4;
437
437
  --palette-purple-40: #6d78d7;
438
438
  --palette-purple-30: #6068c0;
439
439
  --palette-purple-20: #5a62a7;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-type/ui",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "/dist",
@@ -0,0 +1,50 @@
1
+ export * from './actions/index.js';
2
+ export * from './avatar/index.js';
3
+ export * from './button/index.js';
4
+ export * from './camera/index.js';
5
+ export * from './card/index.js';
6
+ export * from './checkbox/index.js';
7
+ export * from './chip/index.js';
8
+ export * from './collapsible/index.js';
9
+ export * from './colorPicker/index.js';
10
+ export * from './contextMenu/contextMenu.js';
11
+ export * from './datePicker/index.js';
12
+ export * from './dialog/index.js';
13
+ export * from './divider/index.js';
14
+ export * from './dropdownMenu/index.js';
15
+ export * from './editableText/EditableText.js';
16
+ export * from './errorBoundary/index.js';
17
+ export * from './forms/index.js';
18
+ export * from './horizontalList/HorizontalList.js';
19
+ export * from './icon/index.js';
20
+ export * from './imageUploader/index.js';
21
+ export * from './infiniteLoadTrigger/InfiniteLoadTrigger.js';
22
+ export * from './input/index.js';
23
+ export * from './layouts/index.js';
24
+ export * from './liveUpdateTextField/index.js';
25
+ export * from './marquee/marquee.js';
26
+ export * from './masonry/masonry.js';
27
+ export * from './navBar/index.js';
28
+ export * from './note/index.js';
29
+ export * from './numberStepper/index.js';
30
+ export * from './particles/index.js';
31
+ export * from './peek/index.js';
32
+ export * from './popover/index.js';
33
+ export * from './provider/Provider.js';
34
+ export * from './relativeTime/index.js';
35
+ export * from './richEditor/index.js';
36
+ export * from './scrollArea/ScrollArea.js';
37
+ export * from './select/index.js';
38
+ export * from './skeletons/skeletons.js';
39
+ export * from './slider/index.js';
40
+ export { Slot, type SlotProps, Slottable } from '@radix-ui/react-slot';
41
+ export * from './spinner/index.js';
42
+ export * from './switch/index.js';
43
+ export * from './tabs/tabs.js';
44
+ export * from './textArea/index.js';
45
+ export * from './toasts/toasts.js';
46
+ export * from './toggleGroup/toggleGroup.js';
47
+ export * from './tooltip/index.js';
48
+ export * from './typography/index.js';
49
+ export * from './utility/HideWhileKeyboardOpen.js';
50
+ export * from './utility/SlotDiv.js';
@@ -1,13 +1,7 @@
1
1
  import classNames from 'clsx';
2
- import {
3
- ComponentProps,
4
- FocusEvent,
5
- forwardRef,
6
- useCallback,
7
- useEffect,
8
- useState,
9
- } from 'react';
2
+ import { ComponentProps, FocusEvent, forwardRef, useCallback } from 'react';
10
3
  import { Slot } from '@radix-ui/react-slot';
4
+ import { useRotatingShuffledValue } from '../../hooks/useRotatingShuffledValue.js';
11
5
 
12
6
  export const inputClassName = classNames(
13
7
  'layer-components:(px-5 py-[5px] text-md font-sans rounded-full bg-white select-auto min-w-60px color-black border-solid border-1 border-gray-7 shadow-sm-inset)',
@@ -50,23 +44,10 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
50
44
  [onFocus, autoSelect],
51
45
  );
52
46
 
53
- const [randomPlaceholder, setRandomPlaceholder] = useState<
54
- string | undefined
55
- >(
56
- placeholders
57
- ? placeholders[Math.floor(Math.random() * placeholders.length)]
58
- : undefined,
47
+ const randomPlaceholder = useRotatingShuffledValue(
48
+ placeholders ?? [],
49
+ placeholdersIntervalMs,
59
50
  );
60
- useEffect(() => {
61
- if (placeholders) {
62
- const interval = setInterval(() => {
63
- setRandomPlaceholder(
64
- placeholders[Math.floor(Math.random() * placeholders.length)],
65
- );
66
- }, placeholdersIntervalMs);
67
- return () => clearInterval(interval);
68
- }
69
- }, [placeholders, placeholdersIntervalMs]);
70
51
 
71
52
  const Component = asChild ? Slot : 'input';
72
53
 
@@ -40,7 +40,7 @@ export function PageContent({
40
40
  className={classNames(
41
41
  'layer-components:(w-full min-w-0 flex flex-col mb-120px px-4 py-4 flex-1)',
42
42
  {
43
- 'layer-variants:flex-1': fullHeight,
43
+ 'layer-variants:(flex-1 mb-auto)': fullHeight,
44
44
  'layer-variants:(p-0 sm:p-4)': noPadding,
45
45
  },
46
46
  innerProps?.className,
@@ -28,7 +28,9 @@ export function Provider({
28
28
  }: ProviderProps) {
29
29
  useVisualViewportOffset(disableViewportOffset);
30
30
  const supportedVirtualKeyboardBehavior =
31
- 'virtualKeyboard' in navigator ? virtualKeyboardBehavior : 'displace';
31
+ typeof navigator !== 'undefined' && 'virtualKeyboard' in navigator
32
+ ? virtualKeyboardBehavior
33
+ : 'displace';
32
34
  useVirtualKeyboardBehavior(supportedVirtualKeyboardBehavior);
33
35
 
34
36
  const otherStuff = (
@@ -7,12 +7,12 @@ import {
7
7
  forwardRef,
8
8
  HTMLProps,
9
9
  useCallback,
10
- useEffect,
11
10
  useLayoutEffect,
12
11
  useRef,
13
12
  useState,
14
13
  } from 'react';
15
14
  import { inputClassName } from '../input.js';
15
+ import { useRotatingShuffledValue } from '../../hooks/useRotatingShuffledValue.js';
16
16
 
17
17
  export interface TextAreaProps
18
18
  extends Omit<HTMLProps<HTMLTextAreaElement>, 'ref'> {
@@ -21,6 +21,8 @@ export interface TextAreaProps
21
21
  autoSelect?: boolean;
22
22
  // if auto-size, pad the height by this many px
23
23
  padBottomPixels?: number;
24
+ placeholders?: string[];
25
+ placeholdersIntervalMs?: number;
24
26
  }
25
27
 
26
28
  export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
@@ -33,6 +35,9 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
33
35
  rows,
34
36
  padBottomPixels = 0,
35
37
  onChange,
38
+ placeholder,
39
+ placeholders,
40
+ placeholdersIntervalMs = 5000,
36
41
  ...rest
37
42
  },
38
43
  ref,
@@ -78,6 +83,11 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
78
83
  [autoSelect, onFocus],
79
84
  );
80
85
 
86
+ const randomPlaceholder = useRotatingShuffledValue(
87
+ placeholders ?? [],
88
+ placeholdersIntervalMs,
89
+ );
90
+
81
91
  return (
82
92
  <textarea
83
93
  ref={finalRef}
@@ -94,6 +104,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
94
104
  rows={autoSize ? 1 : rows}
95
105
  onChange={handleChange}
96
106
  onFocus={handleFocus}
107
+ placeholder={placeholder ?? randomPlaceholder}
97
108
  {...rest}
98
109
  />
99
110
  );
@@ -0,0 +1,20 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ export function useRotatingShuffledValue<T>(
4
+ options: T[],
5
+ intervalMs = 5000,
6
+ ): T | undefined {
7
+ const [selected, setSelected] = useState<T | undefined>(
8
+ options ? options[Math.floor(Math.random() * options.length)] : undefined,
9
+ );
10
+ useEffect(() => {
11
+ if (options) {
12
+ const interval = setInterval(() => {
13
+ setSelected(options[Math.floor(Math.random() * options.length)]);
14
+ }, intervalMs);
15
+ return () => clearInterval(interval);
16
+ }
17
+ }, [options, intervalMs]);
18
+
19
+ return selected;
20
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  export { clsx } from 'clsx';
2
2
  export { toast } from 'react-hot-toast';
3
+
4
+ export * from './hooks.js';
5
+ export * from './components/index.js';
package/src/uno.preset.ts CHANGED
@@ -465,9 +465,9 @@ export default function presetAglio({
465
465
  --palette-blue-00: #00354a;
466
466
  --palette-purple-90: #f1efff;
467
467
  --palette-purple-80: #e0e0ff;
468
- --palette-purple-70: #bdc2ff;
469
- --palette-purple-60: #a0a8ff;
470
- --palette-purple-50: #7c87f3;
468
+ --palette-purple-70: #c8cdff;
469
+ --palette-purple-60: #aab1ff;
470
+ --palette-purple-50: #8490f4;
471
471
  --palette-purple-40: #6d78d7;
472
472
  --palette-purple-30: #6068c0;
473
473
  --palette-purple-20: #5a62a7;