@zuzjs/ui 0.5.3 → 0.5.5

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 (70) hide show
  1. package/dist/bin.js +29 -3
  2. package/dist/comps/accordion.d.ts +12 -0
  3. package/dist/comps/accordion.js +13 -0
  4. package/dist/comps/alert.d.ts +15 -0
  5. package/dist/comps/alert.js +15 -0
  6. package/dist/comps/animate.d.ts +1 -1
  7. package/dist/comps/avatar.d.ts +13 -0
  8. package/dist/comps/avatar.js +11 -0
  9. package/dist/comps/base.d.ts +4 -13
  10. package/dist/comps/base.js +3 -2
  11. package/dist/comps/box.d.ts +2 -2
  12. package/dist/comps/box.js +10 -3
  13. package/dist/comps/button.d.ts +3 -5
  14. package/dist/comps/button.js +12 -3
  15. package/dist/comps/checkbox.d.ts +1 -1
  16. package/dist/comps/checkbox.js +19 -0
  17. package/dist/comps/contextmenu.d.ts +1 -1
  18. package/dist/comps/cover.d.ts +1 -1
  19. package/dist/comps/cover.js +15 -0
  20. package/dist/comps/drawer.js +5 -1
  21. package/dist/comps/editor.js +8 -1
  22. package/dist/comps/form.d.ts +35 -5
  23. package/dist/comps/form.js +67 -21
  24. package/dist/comps/heading.js +13 -0
  25. package/dist/comps/icon.d.ts +4 -5
  26. package/dist/comps/icon.js +15 -3
  27. package/dist/comps/image.d.ts +1 -1
  28. package/dist/comps/input.d.ts +2 -8
  29. package/dist/comps/input.js +5 -5
  30. package/dist/comps/password.d.ts +3 -0
  31. package/dist/comps/password.js +30 -0
  32. package/dist/comps/select.d.ts +2 -1
  33. package/dist/comps/select.js +28 -3
  34. package/dist/comps/sheet.js +3 -0
  35. package/dist/comps/spinner.d.ts +1 -1
  36. package/dist/comps/spinner.js +1 -0
  37. package/dist/comps/tabview.js +8 -1
  38. package/dist/comps/textwheel.d.ts +1 -1
  39. package/dist/comps/textwheel.js +2 -0
  40. package/dist/comps/useBase/base.types.d.ts +64 -0
  41. package/dist/comps/useBase/base.types.js +1 -0
  42. package/dist/comps/useBase/index.d.ts +10 -0
  43. package/dist/comps/useBase/index.js +62 -0
  44. package/dist/funs/colors.d.ts +6 -0
  45. package/dist/funs/colors.js +6 -0
  46. package/dist/funs/css.d.ts +3 -1
  47. package/dist/funs/css.js +183 -15
  48. package/dist/funs/events.js +3 -0
  49. package/dist/funs/index.d.ts +6 -0
  50. package/dist/funs/index.js +36 -2
  51. package/dist/funs/stylesheet.d.ts +1 -0
  52. package/dist/funs/stylesheet.js +66 -1
  53. package/dist/hooks/index.d.ts +1 -0
  54. package/dist/hooks/index.js +1 -0
  55. package/dist/hooks/useImage.d.ts +2 -0
  56. package/dist/hooks/useImage.js +22 -0
  57. package/dist/hooks/useKeyBind.d.ts +3 -0
  58. package/dist/hooks/useKeyBind.js +4 -0
  59. package/dist/hooks/useMounted.d.ts +15 -0
  60. package/dist/hooks/useMounted.js +16 -1
  61. package/dist/hooks/useToast.d.ts +1 -1
  62. package/dist/hooks/useToast.js +1 -1
  63. package/dist/index.d.ts +5 -0
  64. package/dist/index.js +5 -0
  65. package/dist/styles.css +1 -1
  66. package/dist/types/enums.d.ts +115 -1
  67. package/dist/types/enums.js +137 -0
  68. package/dist/types/index.d.ts +3 -0
  69. package/dist/types/interfaces.d.ts +11 -2
  70. package/package.json +1 -1
@@ -1,21 +1,46 @@
1
- "use client";
2
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useEffect, useImperativeHandle, useRef, useState, useTransition } from "react";
4
- import With from "./base";
5
- import { isEmail, withPost } from "../funs";
2
+ import { forwardRef, startTransition, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
3
+ import Box from "./box";
4
+ import useBase from "./useBase";
6
5
  import Sheet from "./sheet";
7
- import { FORMVALIDATION, SHEET } from "../types/enums";
8
6
  import Cover from "./cover";
7
+ import { FORMVALIDATION, SHEET } from "../types/enums";
8
+ import { isEmail, withPost } from "../funs";
9
+ /**
10
+ * {@link Form} is a controlled component designed to handle form data submission, validation, and display of loading or error states.
11
+ * It allows for optional server-side submission through an action endpoint and customizable success/error handling callbacks.
12
+ *
13
+ * The component also provides an interface for controlling loading and error states from a parent component using {@link FormHandler}.
14
+ *
15
+ * @param props - Properties to configure form behavior, validation messages, submission handling, and visual feedback.
16
+ * @param ref - Reference to the {@link FormHandler} interface, exposing methods to control loading and error states from the parent.
17
+ */
9
18
  const Form = forwardRef((props, ref) => {
10
- const { as, spinner, action, errors, cover, children, withData, onSuccess, onSubmit, onError, ...rest } = props;
19
+ const { name, cover, spinner, errors, action, children, withData, onSubmit, onError, onSuccess, ...pops } = props;
20
+ const { className, style, rest } = useBase(pops);
11
21
  const [loading, setLoading] = useState(false);
12
- const [isLoading, startTransition] = useTransition();
13
- const [sheetType, setSheetType] = useState(SHEET.Default);
14
22
  const sheet = useRef(null);
15
- const _ref = useRef(null);
16
- const _nodes = (query) => _ref.current.querySelectorAll(query);
17
- const _validate = (el) => {
23
+ const innerRef = useRef(null);
24
+ /**
25
+ * Utility function to select multiple DOM elements within the form based on a CSS query.
26
+ * @param query - CSS selector to match elements inside the form.
27
+ */
28
+ const _nodes = useCallback((query) => {
29
+ if (innerRef.current)
30
+ return innerRef.current.querySelectorAll(query);
31
+ return [];
32
+ }, [innerRef.current]);
33
+ /**
34
+ * Validates form fields based on their type and custom attributes.
35
+ *
36
+ * @param el - The element to validate.
37
+ * @returns Whether the element meets the required validation criteria.
38
+ */
39
+ const _validate = useCallback((el) => {
18
40
  if (el.required) {
41
+ /**
42
+ * @internal
43
+ * Required field validation */
19
44
  if (el.type == `checkbox` && el.checked == false) {
20
45
  return false;
21
46
  }
@@ -25,6 +50,10 @@ const Form = forwardRef((props, ref) => {
25
50
  if (el.value == ``)
26
51
  return false;
27
52
  }
53
+ /**
54
+ * @internal
55
+ * Additional validation based on `with` attribute
56
+ */
28
57
  if (el.getAttribute(`with`)) {
29
58
  let _with = el.getAttribute(`with`);
30
59
  if (_with.includes(`@`)) {
@@ -50,7 +79,7 @@ const Form = forwardRef((props, ref) => {
50
79
  const _el = document.querySelector(`[name=${field.trim()}]`);
51
80
  if (!_el)
52
81
  return false;
53
- console.log(`matching`, _el.name, _el.value, el.name, el.value);
82
+ // console.log(`matching`, _el.name, _el.value, el.name, el.value)
54
83
  if (_el && _el.value != el.value) {
55
84
  return false;
56
85
  }
@@ -60,8 +89,13 @@ const Form = forwardRef((props, ref) => {
60
89
  }
61
90
  }
62
91
  return true;
63
- };
64
- const _buildFormData = () => {
92
+ }, [innerRef.current]);
93
+ /**
94
+ * Constructs the form data and validates the fields.
95
+ *
96
+ * @returns Form data object along with validation status and error information.
97
+ */
98
+ const _buildFormData = useCallback(() => {
65
99
  const data = {};
66
100
  const payload = {};
67
101
  let _error = null;
@@ -93,13 +127,17 @@ const Form = forwardRef((props, ref) => {
93
127
  errorMsg: _errorMsg || `Fix errors to continue...`,
94
128
  data, payload
95
129
  };
96
- };
97
- const _onSubmit = () => {
130
+ }, [innerRef.current]);
131
+ /**
132
+ * Handler for form submission that validates and processes the form data.
133
+ */
134
+ const _onSubmit = useCallback(() => {
98
135
  const { error, errorMsg, payload } = _buildFormData();
99
136
  if (error) {
100
137
  sheet.current.show(errorMsg, 4, SHEET.Error);
101
138
  }
102
139
  else if (action) {
140
+ // If `action` is defined, submit the form data to the specified endpoint
103
141
  startTransition(async () => {
104
142
  setLoading(true);
105
143
  sheet.current.hide();
@@ -125,18 +163,21 @@ const Form = forwardRef((props, ref) => {
125
163
  else {
126
164
  onSubmit && onSubmit(payload);
127
165
  }
128
- };
129
- const _init = () => {
166
+ }, [action, sheet.current, innerRef.current]);
167
+ /**
168
+ * Initializes the form by adding click event listeners to submit buttons.
169
+ */
170
+ const _init = useCallback(() => {
130
171
  const _submit = _nodes(`[type=submit]`);
131
172
  if (!_submit || _submit.length == 0) {
132
- console.error(`You should add at least 1 button with type=\`SUBMIT\``);
173
+ console.warn(`You should add at least 1 button with type=\`SUBMIT\``);
133
174
  }
134
175
  else {
135
176
  _submit.forEach(el => {
136
177
  el.addEventListener(`click`, _onSubmit);
137
178
  });
138
179
  }
139
- };
180
+ }, [innerRef.current]);
140
181
  useImperativeHandle(ref, () => ({
141
182
  setLoading(mod) {
142
183
  if (mod) {
@@ -152,6 +193,11 @@ const Form = forwardRef((props, ref) => {
152
193
  }
153
194
  }));
154
195
  useEffect(_init, []);
155
- return _jsxs(With, { as: as, className: `rel`, ref: _ref, propsToRemove: [`withData`, `action`, `onSubmit`, `onSuccess`, `onError`], ...rest, children: [_jsx(Sheet, { ref: sheet, as: `toast-form` }), loading && _jsx(Cover, { message: cover ? cover.message || undefined : `working`, ...{ spinner, color: cover ? `color` in cover ? cover.color : `#ffffff` : `#ffffff` } }), children] });
196
+ return _jsxs(Box, { ...{
197
+ className: `${className} rel --form${name ? `-${name.replace(/\s+/g, `-`)}` : ``}`,
198
+ style,
199
+ propsToRemove: [`withData`, `action`, `onSubmit`, `onSuccess`, `onError`],
200
+ ...rest
201
+ }, ref: innerRef, children: [_jsx(Sheet, { ref: sheet, as: `toast-form` }), loading && _jsx(Cover, { message: cover ? cover.message || undefined : `working`, ...{ spinner, color: cover ? `color` in cover ? cover.color : `#ffffff` : `#ffffff` } }), children] });
156
202
  });
157
203
  export default Form;
@@ -7,4 +7,17 @@ const Heading = forwardRef((props, ref) => {
7
7
  props.html ? _jsx("span", { ...({ dangerouslySetInnerHTML: { __html: html } }) }) : props.children
8
8
  : null });
9
9
  });
10
+ // import { Ref } from "react"
11
+ // import { css, cleanProps } from "../funs";
12
+ // import { UIProps } from "../types/interfaces";
13
+ // const Heading = ( props: UIProps<HTMLHeadingElement> ) => {
14
+ // const { children, ref, h, html } = props
15
+ // let Tag : string = `h${h || 1}`;
16
+ // const HeadingTag = Tag as `h1` | `h2` | `h3` | `h4` | `h5` | `h6`
17
+ // const { cx } = css.Build(props.as)
18
+ // return <HeadingTag
19
+ // ref={ref}
20
+ // className={cx.join(` `)}
21
+ // {...(cleanProps(props) as UIProps<HTMLHeadingElement>)}>{props.html ? <span { ...({dangerouslySetInnerHTML:{ __html: html }}) as UIProps<HTMLSpanElement>} /> : children}</HeadingTag>
22
+ // }
10
23
  export default Heading;
@@ -1,7 +1,6 @@
1
- import { animationProps } from "./base";
2
- declare const Icon: import("react").ForwardRefExoticComponent<{
1
+ import { Props } from "./useBase/base.types";
2
+ export interface IconProps extends Props<`div`> {
3
3
  name: string;
4
- as?: string;
5
- animate?: animationProps;
6
- } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
4
+ }
5
+ declare const Icon: import("react").ForwardRefExoticComponent<IconProps & import("react").RefAttributes<HTMLDivElement>>;
7
6
  export default Icon;
@@ -1,8 +1,20 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import With from "./base";
3
+ // import With, { Props } from "./base";
4
+ import Box from "./box";
5
+ import useBase from "./useBase";
4
6
  const Icon = forwardRef((props, ref) => {
5
- const { as, name, ...rest } = props;
6
- return _jsx(With, { className: `icon-${name}`, as: as, ...rest, ref: ref });
7
+ const { name, ...pops } = props;
8
+ const { className, style, rest } = useBase(pops);
9
+ return _jsx(Box, { ...{
10
+ className: `${className} icon-${name}`,
11
+ style,
12
+ ...rest
13
+ } });
14
+ // return <With
15
+ // className={`icon-${name}`}
16
+ // as={as}
17
+ // {...rest}
18
+ // ref={ref} />
7
19
  });
8
20
  export default Icon;
@@ -1,5 +1,5 @@
1
- import { animationProps } from "./base";
2
1
  import React from "react";
2
+ import { animationProps } from "../types/interfaces";
3
3
  interface ImageProps {
4
4
  width: string | number;
5
5
  height: string | number;
@@ -1,9 +1,3 @@
1
- import { animationProps } from "./base";
2
- import { FORMVALIDATION } from "../types/enums";
3
- declare const Input: import("react").ForwardRefExoticComponent<{
4
- required?: FORMVALIDATION;
5
- textarea?: any;
6
- as?: string;
7
- animate?: animationProps;
8
- } & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
1
+ import { Props } from "./useBase/base.types";
2
+ declare const Input: import("react").ForwardRefExoticComponent<Props<"input"> & import("react").RefAttributes<HTMLInputElement>>;
9
3
  export default Input;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import With from "./base";
2
+ import { forwardRef, useRef } from "react";
3
+ import useBase from "./useBase";
4
4
  const Input = forwardRef((props, ref) => {
5
- const { as, textarea, value, ...rest } = props;
6
- return textarea ? _jsx(With, { tag: `textarea`, as: as, ...rest, value: value, ref: ref })
7
- : _jsx(With, { tag: `input`, as: as, value: value, ...rest, ref: ref });
5
+ const _innerRef = useRef(null);
6
+ const { className, style, rest } = useBase(props);
7
+ return _jsx("input", { className: className, style: style, ref: _innerRef, ...rest });
8
8
  });
9
9
  export default Input;
@@ -0,0 +1,3 @@
1
+ import { Props } from "./useBase/base.types";
2
+ declare const Password: import("react").ForwardRefExoticComponent<Omit<Props<"input">, "type"> & import("react").RefAttributes<HTMLInputElement>>;
3
+ export default Password;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState } from "react";
3
+ import Input from "./input";
4
+ import Box from "./box";
5
+ import Button from "./button";
6
+ import useBase from "./useBase";
7
+ const Icons = {
8
+ on: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", children: [_jsx("path", { fill: "#333", d: "M12 20.5c-4.299 0-8.24-3.023-10.544-8.086a1 1 0 010-.828C3.759 6.523 7.701 3.5 12 3.5s8.24 3.023 10.544 8.086a1.001 1.001 0 010 .828 18.14 18.14 0 01-1.391 2.52 1 1 0 11-1.666-1.106A15.87 15.87 0 0020.529 12C18.543 7.92 15.379 5.5 12 5.5S5.457 7.92 3.471 12c1.986 4.08 5.15 6.5 8.529 6.5a7.964 7.964 0 005.036-1.92 1 1 0 111.265 1.55A9.94 9.94 0 0112 20.5z" }), _jsx("path", { fill: "#333", d: "M12 16a4.004 4.004 0 01-3.929-4.756 1 1 0 011.965.375A2 2 0 1014 12a2.034 2.034 0 00-2.053-1.999 1.04 1.04 0 01-1.043-.947.963.963 0 01.902-1.05L12 8a4 4 0 010 8z" })] }),
9
+ off: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", children: [_jsx("path", { fill: "#333", d: "M12 15c-4.132 0-7.98-1.214-10.294-3.249a1 1 0 111.32-1.502C4.986 11.972 8.34 13 12 13s7.014-1.028 8.974-2.751a1 1 0 111.32 1.502C19.98 13.786 16.132 15 12 15z" }), _jsx("path", { fill: "#333", d: "M12 18a1 1 0 01-1-1v-3a1 1 0 012 0v3a1 1 0 01-1 1zM7.749 17.667a.964.964 0 01-.17-.014 1 1 0 01-.817-1.155l.505-2.935a1 1 0 111.97.339l-.504 2.935a1 1 0 01-.984.83zM3.636 16.306a1.001 1.001 0 01-.942-1.336l.978-2.745a1 1 0 111.884.672l-.978 2.745a1 1 0 01-.942.664zM16.251 17.667a1 1 0 01-.984-.83l-.505-2.935a1 1 0 011.97-.339l.506 2.935a1 1 0 01-.816 1.155.964.964 0 01-.17.014zM20.364 16.306a1 1 0 01-.942-.664l-.978-2.745a1 1 0 111.884-.672l.978 2.745a1.001 1.001 0 01-.942 1.336z" })] })
10
+ };
11
+ const Password = forwardRef((props, ref) => {
12
+ const [visible, setVisible] = useState(false);
13
+ const { animate, ...pops } = props;
14
+ const { style } = useBase(props);
15
+ if (`type` in props) {
16
+ delete props[`type`];
17
+ }
18
+ return _jsxs(Box, { style: style, ...{
19
+ className: `--password flex aic rel`
20
+ }, children: [_jsx(Input, { ...{
21
+ ref,
22
+ type: visible ? 'text' : 'password',
23
+ ...pops
24
+ } }), _jsx(Button, { ...{
25
+ tabIndex: -1,
26
+ onClick: e => setVisible(prev => !prev),
27
+ className: `--toggle flex aic jcc abs`
28
+ }, children: visible ? Icons.on : Icons.off })] });
29
+ });
30
+ export default Password;
@@ -1,6 +1,6 @@
1
- import { animationProps } from "./base";
2
1
  import { FORMVALIDATION } from "../types/enums";
3
2
  import { dynamicObject } from "../types";
3
+ import { animationProps } from "../types/interfaces";
4
4
  export interface SelectProps {
5
5
  as?: string;
6
6
  name?: string;
@@ -9,6 +9,7 @@ export interface SelectProps {
9
9
  options: dynamicObject[];
10
10
  label?: string;
11
11
  defaultValue?: string | dynamicObject;
12
+ search?: boolean;
12
13
  onChange?: (v: string | dynamicObject) => void;
13
14
  }
14
15
  export interface SelectHandler {
@@ -5,11 +5,13 @@ import With from "./base";
5
5
  import { uuid } from "../funs";
6
6
  const chevronExpand = () => _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", className: "bi bi-chevron-expand", viewBox: "0 0 16 16", children: _jsx("path", { fillRule: "evenodd", d: "M3.646 9.146a.5.5 0 01.708 0L8 12.793l3.646-3.647a.5.5 0 01.708.708l-4 4a.5.5 0 01-.708 0l-4-4a.5.5 0 010-.708zm0-2.292a.5.5 0 00.708 0L8 3.207l3.646 3.647a.5.5 0 00.708-.708l-4-4a.5.5 0 00-.708 0l-4 4a.5.5 0 000 .708z" }) });
7
7
  const Select = forwardRef((props, ref) => {
8
- const { as, options, name, label, defaultValue, onChange, ...rest } = props;
8
+ const { as, options, name, label, defaultValue, search: withSearch, onChange, ...rest } = props;
9
9
  const _ref = useRef(null);
10
+ const _search = useRef(null);
10
11
  const _id = useMemo(() => name || uuid(), []);
11
12
  const [choosing, setChoosing] = useState(false);
12
13
  const [value, setValue] = useState(defaultValue || options[0]);
14
+ const [query, setQuery] = useState(null);
13
15
  const updateValue = (o) => {
14
16
  setValue(o);
15
17
  onChange && onChange(o);
@@ -19,13 +21,36 @@ const Select = forwardRef((props, ref) => {
19
21
  setChoosing(false);
20
22
  });
21
23
  }, []);
22
- return _jsxs(With, { className: `zuz-select-wrap rel`, children: [_jsxs(With, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, name: name, tag: `button`, as: as, className: `zuz-select rel flex aic --select`, ref: _ref, onClick: (e) => setChoosing(true), ...rest, children: [_jsx(With, { tag: `h2`, className: `zuz-selected`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), chevronExpand()] }), _jsx(With, { id: _id, className: `zuz-select-options abs flex cols`, style: {
24
+ useEffect(() => {
25
+ if (choosing) {
26
+ _search.current && _search.current.focus();
27
+ }
28
+ else {
29
+ if (_search.current) {
30
+ _search.current.value = ``;
31
+ }
32
+ setQuery(null);
33
+ }
34
+ }, [choosing]);
35
+ return _jsxs(With, { className: `zuz-select-wrap rel`, children: [_jsxs(With, { "data-value": value ? `string` == typeof value ? value : value.value : value || `-1`, name: name, tag: `button`, as: as, className: `zuz-select rel flex aic --select`, ref: _ref, onClick: (e) => setChoosing(true), ...rest, children: [_jsx(With, { tag: `h2`, className: `zuz-selected`, children: value ? `string` == typeof value ? value : value.label : label || `Choose` }), chevronExpand()] }), _jsxs(With
36
+ // popover="true"
37
+ , {
38
+ // popover="true"
39
+ id: _id, className: `zuz-select-options abs flex cols`, style: {
23
40
  pointerEvents: choosing ? `auto` : `none`,
24
41
  }, animate: {
25
42
  from: { y: 5, opacity: 0 },
26
43
  to: { y: 0, opacity: 1 },
27
44
  when: choosing,
45
+ // curve: `spring`,
28
46
  duration: .05
29
- }, children: options.map((o) => _jsx(With, { onClick: (e) => updateValue(o), className: value && (`string` == typeof o ? o : o.value) == (`string` == typeof value ? value : value.value) ? `selected` : ``, tag: `button`, children: `string` == typeof o ? o : o.label }, `option-${(`string` == typeof o ? o : o.label).replace(/\s+/g, `-`)}-${`string` == typeof o ? o : o.value}`)) })] });
47
+ }, children: [withSearch && _jsx(With, { ref: _search, onChange: (e) => {
48
+ setQuery(e.target.value == `` ? null : e.target.value);
49
+ }, tag: `input`, placeholder: `Search`, className: `--select-search` }), (query == null ? options : options.filter((o) => {
50
+ return `string` == typeof o ?
51
+ o.toLowerCase().includes(query.toLowerCase())
52
+ : o.label.toLowerCase().includes(query.toLowerCase()) || o.value.toLowerCase().includes(query.toLowerCase());
53
+ }))
54
+ .map((o) => _jsx(With, { onClick: (e) => updateValue(o), className: value && (`string` == typeof o ? o : o.value) == (`string` == typeof value ? value : value.value) ? `selected` : ``, tag: `button`, children: `string` == typeof o ? o : o.label }, `option-${(`string` == typeof o ? o : o.label).replace(/\s+/g, `-`)}-${`string` == typeof o ? o : o.value}`))] })] });
30
55
  });
31
56
  export default Select;
@@ -11,6 +11,7 @@ let _sheetTimeout = null;
11
11
  let _sheetWobbleTimeout = null;
12
12
  const Sheet = forwardRef((props, ref) => {
13
13
  const { as, transition, curve, speed, editor, type, actionPosition, ...rest } = props;
14
+ // const _editor = useComponentEditor()
14
15
  const sheetID = useMemo(() => uuid(), []);
15
16
  const [visible, setVisible] = useState(false);
16
17
  const [title, setTitle] = useState(``);
@@ -22,6 +23,7 @@ const Sheet = forwardRef((props, ref) => {
22
23
  const _render = useRef(null);
23
24
  const divRef = useRef(null);
24
25
  const lastTransform = useRef(null);
26
+ // const dialogContent = useMemo(() => msg, [msg])
25
27
  useImperativeHandle(ref, () => ({
26
28
  setLoading(mode) {
27
29
  setLoading(mode);
@@ -68,6 +70,7 @@ const Sheet = forwardRef((props, ref) => {
68
70
  if (_sheetWobbleTimeout) {
69
71
  clearTimeout(_sheetWobbleTimeout);
70
72
  }
73
+ // if ( lastTransform ) divRef.current!.style.transform = _lastTransform
71
74
  lastTransform.current = divRef.current.style.transform;
72
75
  divRef.current.style.transform = ``;
73
76
  divRef.current.classList.remove(`wobble`);
@@ -1,6 +1,6 @@
1
1
  import { ComponentPropsWithoutRef } from "react";
2
- import { animationProps } from "./base";
3
2
  import { SPINNER } from "../types/enums";
3
+ import { animationProps } from "../types/interfaces";
4
4
  export interface SpinnerProps extends ComponentPropsWithoutRef<`div`> {
5
5
  as?: string;
6
6
  animate?: animationProps;
@@ -6,6 +6,7 @@ import { hexToRgba } from "../funs";
6
6
  const Spinner = forwardRef((props, ref) => {
7
7
  const { as, type, width, speed, size, color, background, foreground, ...rest } = props;
8
8
  const defaultColor = `#000000`;
9
+ // console.log(`sp`, props)
9
10
  const buildSimple = () => {
10
11
  const c = color && color.startsWith(`var`) ? color : hexToRgba(color || defaultColor);
11
12
  const bg = color && color.startsWith(`var`) ? color : hexToRgba(color || defaultColor, .3);
@@ -22,20 +22,27 @@ const TabView = forwardRef((props, ref) => {
22
22
  setActiveTab(index);
23
23
  };
24
24
  useEffect(() => {
25
+ // console.log(`TabRenderCount`)
25
26
  onChange && onChange(tabs[0], 0);
26
27
  }, []);
28
+ // useEffect(() => {
29
+ // console.log(tabs)
30
+ // }, [tabs])
27
31
  return _jsxs(_Fragment, { children: [_jsxs(With, { ref: tabview, className: `tabview flex cols`, ...rest, children: [_jsx(With, { className: `tab-head flex aic`, children: tabs.map((tab, index) => _jsx(With, { tag: `button`, className: `tab-label rel ${index === activeTab ? 'active' : ''}`.trim(), onClick: () => {
28
32
  handleTabClick(index);
29
33
  tab.onSelect && tab.onSelect(tab, index);
30
34
  onChange && onChange(tab, index);
31
35
  }, children: tab.label }, `tab-${tabViewID}-${tab.key}`)) }), _jsx(With, { className: `tab-content rel`, children: _jsx(With, { className: `tabs-track flex aic`, style: { transition: `all ${speed || 0.3}s ease-in-out 0s`, transform: `translate(-${activeTab * size.width}px, 0)` }, children: tabs.map((tab, index) => {
32
- return _jsx(With, { className: `tab-body rel`, style: {
36
+ return _jsx(With
37
+ // ref={tabBodyRef}
38
+ , { className: `tab-body rel`, style: {
33
39
  width: size.width,
34
40
  minWidth: size.width,
35
41
  maxWidth: size.width,
36
42
  opacity: index === activeTab ? 1 : 0,
37
43
  transition: 'opacity 0.5s ease',
38
44
  }, children: (render || activeTab == index) && tab.body }, `tab-body-${tabViewID}-${tab.key}`);
45
+ // onClick={() => tab.onSelect(index)}
39
46
  }) }) })] }), props.editor && _jsx(ComponentEditor, { element: `.tabview`, title: `TabView`, attrs: {
40
47
  "@group-Head": {
41
48
  label: "Head",
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { animationProps } from "./base";
2
+ import { animationProps } from '../types/interfaces';
3
3
  export interface WheelProps {
4
4
  as?: string;
5
5
  direction?: `up` | `down`;
@@ -8,6 +8,7 @@ const TextWheel = forwardRef((props, ref) => {
8
8
  const [_value, _setValue] = useState(value || 0);
9
9
  useImperativeHandle(ref, () => ({
10
10
  updateValue(v) {
11
+ // console.log(_value != v, _value.toString().length != v.toString().length)
11
12
  if (_value.toString().length != v.toString().length) {
12
13
  _setValue(v);
13
14
  }
@@ -30,6 +31,7 @@ const TextWheel = forwardRef((props, ref) => {
30
31
  }
31
32
  }));
32
33
  useEffect(() => {
34
+ // console.log(value)
33
35
  _setValue(value || 0);
34
36
  }, [value]);
35
37
  return _jsxs(With, { className: `text-wheel flex aic jcc rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
@@ -0,0 +1,64 @@
1
+ import { ElementType, HTMLAttributes } from "react";
2
+ import { dynamicObject } from "../../types";
3
+ import { SHIMMER, SKELETON, TRANSITION_CURVES, TRANSITIONS } from "../../types/enums";
4
+ /**
5
+ * `animationProps` defines the properties to control animation effects
6
+ * applied to elements. Supports transitions with timing configurations.
7
+ */
8
+ export interface animationProps {
9
+ /**
10
+ * Specifies the type of transition to apply, based on predefined
11
+ * {@link TRANSITIONS}
12
+ */
13
+ transition?: TRANSITIONS;
14
+ /** Starting style properties for the animation */
15
+ from?: dynamicObject;
16
+ /** Target style properties after the animation completes */
17
+ to?: dynamicObject;
18
+ /** Condition that determines when the animation should trigger */
19
+ when?: boolean;
20
+ /** Duration of the animation in milliseconds */
21
+ duration?: number;
22
+ /** Delay before the animation starts, in milliseconds */
23
+ delay?: number;
24
+ /** Easing curve applied to the animation, as a string or {@link TRANSITION_CURVES} */
25
+ curve?: string | TRANSITION_CURVES;
26
+ }
27
+ /**
28
+ * `Skeleton` defines properties for a skeleton loader, used to indicate
29
+ * loading states with placeholders.
30
+ */
31
+ export interface Skeleton {
32
+ /** Enables or disables the skeleton placeholder */
33
+ enabled: boolean;
34
+ /** Specifies the skeleton type, based on predefined {@link SKELETON} options */
35
+ type?: SKELETON;
36
+ /** General size of the skeleton, or can specify width/height separately */
37
+ size?: number | string;
38
+ /** Width of the skeleton placeholder */
39
+ width?: number | string;
40
+ /** Height of the skeleton placeholder */
41
+ height?: number | string;
42
+ /** Border radius for the skeleton, allowing rounded corners */
43
+ radius?: number | string;
44
+ }
45
+ /**
46
+ * `Props` defines the primary properties for components, extending standard
47
+ * HTML attributes with additional options for animations, skeletons, and tags.
48
+ */
49
+ export interface Props<T extends ElementType> extends HTMLAttributes<T> {
50
+ /** Defines the React element or HTML tag to render */
51
+ tag?: T;
52
+ /** CSS Styles, such as "w:100" for "width: 100px"; */
53
+ as?: string | string[];
54
+ /** Animation configuration using {@link animationProps} */
55
+ animate?: animationProps;
56
+ /** Skeleton placeholder configuration using {@link Skeleton} */
57
+ skeleton?: Skeleton;
58
+ /** Additional class names for styling the component */
59
+ className?: string;
60
+ /** Shimmer effect for loading state, using predefined {@link SHIMMER} options */
61
+ shimmer?: SHIMMER;
62
+ /** Props to remove after processing so it won't appear in DOM */
63
+ propsToRemove?: string[];
64
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ElementType } from "react";
2
+ import { Props } from "./base.types";
3
+ export declare const useBase: <T extends ElementType>(props?: Props<T>) => {
4
+ style: {
5
+ [x: string]: any;
6
+ };
7
+ className: string;
8
+ rest: Omit<Props<T>, keyof Props<T>>;
9
+ };
10
+ export default useBase;
@@ -0,0 +1,62 @@
1
+ import { cleanProps, css } from "../../funs";
2
+ import { buildWithStyles, getAnimationCurve, getAnimationTransition } from "../../funs/css";
3
+ const buildSkeletonStyle = (s) => {
4
+ const makeValue = (v, unit = `px`) => {
5
+ return v ?
6
+ `string` == typeof v ? v : `${v}${unit}`
7
+ : `inherit`;
8
+ };
9
+ const style = {};
10
+ if (s.radius) {
11
+ style.borderRadius = makeValue(s.radius);
12
+ }
13
+ if (s.size) {
14
+ style.width = style.minWidth = style.maxWidth = style.height = style.minHeight = style.maxHeight = makeValue(s.size);
15
+ }
16
+ else if (s.width || s.height) {
17
+ if (s.width) {
18
+ style.width = style.minWidth = style.maxWidth = makeValue(s.width);
19
+ }
20
+ if (s.height) {
21
+ style.height = style.minHeight = style.maxHeight = makeValue(s.height);
22
+ }
23
+ }
24
+ else {
25
+ style.minWidth = style.minHeight = `100%`;
26
+ }
27
+ return style;
28
+ };
29
+ export const useBase = (props) => {
30
+ const { as, animate, skeleton, className, shimmer, propsToRemove, ...rest } = props || {};
31
+ let cx = [];
32
+ if (as) {
33
+ cx = css().Build(`string` == typeof as ? as : as.join(` `)).cx;
34
+ }
35
+ const { transition, from, to, when, duration, delay, curve } = animate || {};
36
+ let _style = {};
37
+ const _transition = transition || (from && to) ? { transition: `all ${duration || `0.2`}s ${getAnimationCurve(curve)} ${delay || 0}s` } : {};
38
+ if (undefined === when) {
39
+ _style = transition ? getAnimationTransition(transition, true) : { ...from, ...to };
40
+ }
41
+ else if (true === when) {
42
+ _style = transition ? getAnimationTransition(transition, false) : { ...(to || {}) };
43
+ }
44
+ else {
45
+ _style = transition ? getAnimationTransition(transition, false, true) : from || {};
46
+ }
47
+ return {
48
+ style: {
49
+ ...buildWithStyles(_style),
50
+ ..._transition,
51
+ ...(skeleton?.enabled ? buildSkeletonStyle(skeleton) : {})
52
+ },
53
+ className: [
54
+ className,
55
+ ...cx,
56
+ skeleton?.enabled ? `--skeleton` : ``,
57
+ shimmer ? `--shimmer --${shimmer.toLowerCase()}` : ``,
58
+ ].join(' ').trim(),
59
+ rest: cleanProps(rest, propsToRemove ? [...propsToRemove, `skeleton`] : [`skeleton`])
60
+ };
61
+ };
62
+ export default useBase;
@@ -1 +1,7 @@
1
+ /**
2
+ * An array of color names.
3
+ *
4
+ * @remarks
5
+ * This array contains a list of color names that can be used in CSS or other color-related operations.
6
+ */
1
7
  export declare const colorNames: string[];
@@ -1,3 +1,9 @@
1
+ /**
2
+ * An array of color names.
3
+ *
4
+ * @remarks
5
+ * This array contains a list of color names that can be used in CSS or other color-related operations.
6
+ */
1
7
  export const colorNames = [
2
8
  'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen'
3
9
  ];
@@ -24,6 +24,7 @@ declare class CSS {
24
24
  _cli: boolean;
25
25
  DIRECT_VALUES: string[];
26
26
  PROPS_VALUES: string[];
27
+ _currentFile: string;
27
28
  constructor(options?: dynamicObject | undefined);
28
29
  buildMediaQueries(queries: dynamicObject): string;
29
30
  styleSheet(cache: dynamicObject, pseudo?: string): string;
@@ -31,12 +32,13 @@ declare class CSS {
31
32
  cleanKey(key: string): string;
32
33
  deepClean(cache: dynamicObject, level?: number): dynamicObject;
33
34
  makeUnit(k: string, v: any): any;
35
+ makeColor(v: string): string;
34
36
  makeValue(k: string, v: any): string;
35
37
  calcIndexes(str: string): string;
36
38
  makeID(k: string, v: string, _out: string): string;
37
39
  lexer(line: string): dynamicObject;
38
40
  processLine(line: string): void;
39
- Build(css: string | string[][], cli?: boolean): {
41
+ Build(css: string | string[][], cli?: boolean, ff?: string): {
40
42
  cx: string[];
41
43
  sheet: string;
42
44
  mediaQuery: dynamicObject;