@zuzjs/ui 0.4.0 → 0.4.2

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 (46) hide show
  1. package/dist/bin.js +34 -23
  2. package/dist/comps/base.d.ts +11 -1
  3. package/dist/comps/base.js +23 -3
  4. package/dist/comps/box.d.ts +2 -0
  5. package/dist/comps/box.js +0 -7
  6. package/dist/comps/button.d.ts +2 -0
  7. package/dist/comps/button.js +0 -11
  8. package/dist/comps/checkbox.d.ts +2 -0
  9. package/dist/comps/checkbox.js +0 -18
  10. package/dist/comps/contextmenu.d.ts +6 -1
  11. package/dist/comps/contextmenu.js +3 -2
  12. package/dist/comps/cover.d.ts +2 -0
  13. package/dist/comps/cover.js +1 -25
  14. package/dist/comps/dialog.d.ts +0 -0
  15. package/dist/comps/dialog.js +1 -0
  16. package/dist/comps/form.d.ts +6 -1
  17. package/dist/comps/form.js +10 -149
  18. package/dist/comps/heading.d.ts +2 -0
  19. package/dist/comps/heading.js +0 -13
  20. package/dist/comps/icon.d.ts +2 -0
  21. package/dist/comps/icon.js +0 -10
  22. package/dist/comps/image.d.ts +13 -0
  23. package/dist/comps/image.js +8 -0
  24. package/dist/comps/input.d.ts +2 -0
  25. package/dist/comps/input.js +0 -15
  26. package/dist/comps/select.d.ts +18 -0
  27. package/dist/comps/select.js +32 -0
  28. package/dist/comps/sheet.d.ts +4 -1
  29. package/dist/comps/sheet.js +39 -59
  30. package/dist/comps/spinner.d.ts +2 -0
  31. package/dist/comps/spinner.js +0 -1
  32. package/dist/funs/colors.d.ts +0 -6
  33. package/dist/funs/colors.js +0 -6
  34. package/dist/funs/css.d.ts +25 -251
  35. package/dist/funs/css.js +355 -325
  36. package/dist/funs/index.d.ts +10 -1
  37. package/dist/funs/index.js +35 -10
  38. package/dist/funs/stylesheet.d.ts +7 -242
  39. package/dist/funs/stylesheet.js +97 -7
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +2 -0
  42. package/dist/styles.css +1 -1
  43. package/dist/types/enums.d.ts +1 -0
  44. package/dist/types/enums.js +1 -0
  45. package/dist/types/index.d.ts +1 -0
  46. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -5,6 +5,7 @@ import chokidar from 'chokidar';
5
5
  import path from "path";
6
6
  import CSS from "./funs/css.js";
7
7
  import pc from "picocolors";
8
+ import { FIELNAME_KEY } from "./funs/index.js";
8
9
  program
9
10
  .option(`-d, --debug`)
10
11
  .option(`-v, --version`)
@@ -36,61 +37,71 @@ const getAllFiles = (dir, extn, files, result, regex) => {
36
37
  };
37
38
  const rebuild = (f) => {
38
39
  const raw = fs.readFileSync(f, `utf8`);
39
- const list = [];
40
+ let _filePath = path.relative(process.cwd(), f);
41
+ if (!_filePath.startsWith(`/`))
42
+ _filePath = `/${_filePath}`;
43
+ const list = [`${FIELNAME_KEY}:${_filePath}`];
40
44
  const processMatch = (matches, type) => {
45
+ const makeV2 = (v1) => {
46
+ let v2 = v1
47
+ .trim()
48
+ .slice(1, -1);
49
+ if (v2.includes(`\n`)) {
50
+ v2 = v2.split(`\n`).reduce((arr, v) => {
51
+ if (v.trim() != ``) {
52
+ v = v.trim().endsWith(`,`) ? v.slice(0, -1) : v;
53
+ arr.push(v.trim());
54
+ }
55
+ return arr;
56
+ }, []).join(` `);
57
+ }
58
+ if (v2.startsWith(`[`) && v2.endsWith(`]`))
59
+ v2 = v2.slice(1, -1);
60
+ return v2.trim();
61
+ };
41
62
  if (matches && matches.length > 0) {
42
63
  matches.map((m) => {
43
64
  let v2;
44
65
  if (type == `as`) {
45
66
  const [x, v1] = m.split(/as\s*=/);
46
- v2 = v1.trim().slice(1, -1);
67
+ v2 = makeV2(v1);
47
68
  }
48
69
  else if (type == `css`) {
49
70
  const v1 = m.split(/css\s*\(/)[1].slice(0, -1);
50
- v2 = v1.trim().slice(1, -1);
71
+ v2 = makeV2(v1.trim());
51
72
  }
52
73
  list.push(v2);
53
- // console.log(type, v2)
54
- // const _ = v2!.match(/\w+:\$?\w+|\$?\w+/g)
55
- // if(_){
56
- // _.map((n:string) => !list.includes(n) && list.push(n))
57
- // }
58
74
  });
59
75
  }
60
76
  };
61
- /**
62
- * match as={?}
63
- */
64
- processMatch(raw.match(/as\s*=\s*\{([^{}]|{([^{}]|{[^{}]*})*})*\}/g), `as`);
65
- /**
66
- * match css()
67
- */
68
- processMatch(raw.match(/css\(\s*`([^`]*?([$&]{[^}]*})?[^`]*)*`\s*\)/g), `css`);
77
+ processMatch(raw.match(/as\s*=\s*(?:\{([^{}]|{([^{}]|{[^{}]*})*})*\}|'([^']*)'|"([^"]*)")/g), `as`);
78
+ processMatch(raw.match(/css\(\s*(?:\[\s*([\s\S]*?)\s*\]|\s*`([\s\S]*?)`)\s*\)/g), `css`);
69
79
  return list;
70
80
  };
71
81
  const rebuildAll = () => {
72
82
  console.log(pc.gray(`○ Building Zuz CSS`));
83
+ const cssBuilder = new CSS();
73
84
  const files = getAllFiles(process.cwd(), `.jsx`);
74
85
  if (files.length > 0) {
75
86
  const as = [];
76
87
  if (options.file) {
77
88
  const r = rebuild(files.filter(f => f.endsWith(options.file))[0]);
78
- if (r && r.length > 0)
79
- as.push(r);
89
+ if (r && r.length > 0) {
90
+ as.push(cssBuilder.Build([r], true).sheet);
91
+ }
80
92
  }
81
93
  else {
82
94
  files.map(f => {
83
95
  const r = rebuild(f);
84
- if (r && r.length > 0)
85
- as.push(r);
96
+ if (r && r.length > 0) {
97
+ as.push(cssBuilder.Build([r], true).sheet);
98
+ }
86
99
  });
87
100
  }
88
- const { sheet } = new CSS().Build(as);
89
- // console.log(cache)
101
+ const sheet = as.join(`\n`);
90
102
  if (!fs.existsSync(path.join(process.cwd(), `src`, `app`, `css`))) {
91
103
  fs.mkdirSync(path.join(process.cwd(), `src`, `app`, `css`));
92
104
  }
93
- // console.log(sheet)
94
105
  fs.writeFileSync(path.join(process.cwd(), `src`, `app`, `css`, `zuz.scss`), sheet, {
95
106
  encoding: `utf8`,
96
107
  flag: `w+`
@@ -1,9 +1,19 @@
1
1
  import { ComponentPropsWithoutRef, ElementType } from "react";
2
+ import { dynamicObject } from "../types";
3
+ export interface animationProps {
4
+ from?: dynamicObject;
5
+ to?: dynamicObject;
6
+ when?: boolean;
7
+ duration?: number;
8
+ delay?: number;
9
+ curve?: string;
10
+ }
2
11
  interface BaseProps<T extends ElementType> {
3
12
  tag?: T;
4
- as?: string;
13
+ as?: string | string[];
5
14
  className?: string;
6
15
  propsToRemove?: string[];
16
+ animate?: animationProps;
7
17
  }
8
18
  export type Props<T extends ElementType> = BaseProps<T> & ComponentPropsWithoutRef<T>;
9
19
  declare const With: import("react").ForwardRefExoticComponent<Omit<Props<ElementType>, "ref"> & import("react").RefAttributes<Element>>;
@@ -1,10 +1,30 @@
1
1
  import { createElement, forwardRef } from "react";
2
2
  import { css, cleanProps } from "../funs";
3
- const With = forwardRef(({ tag, as, className, propsToRemove, ...rest }, ref) => {
3
+ import { buildWithStyles, getAnimationCurve } from "../funs/css";
4
+ const With = forwardRef(({ tag, as, animate, className, propsToRemove, style, ...rest }, ref) => {
4
5
  const Comp = tag || 'div';
5
- const { cx } = css().Build(as || []);
6
- // console.log(cx)
6
+ let cx = [];
7
+ if (as) {
8
+ cx = css().Build(`string` == typeof as ? as : as.join(` `)).cx;
9
+ }
10
+ const { from, to, when, duration, delay, curve } = animate || {};
11
+ let _style = {};
12
+ const _transition = from && to ? { transition: `all ${duration || `0.2`}s ${getAnimationCurve(curve)} ${delay || 0}s` } : {};
13
+ if (undefined === when) {
14
+ _style = { ...from, ...to };
15
+ }
16
+ else if (true === when) {
17
+ _style = { ...(to || {}) };
18
+ }
19
+ else {
20
+ _style = from || {};
21
+ }
7
22
  return createElement(Comp, {
23
+ style: {
24
+ ...buildWithStyles(_style),
25
+ ..._transition,
26
+ ...style
27
+ },
8
28
  className: [className, ...cx].join(' ').trim(),
9
29
  ...cleanProps(rest, propsToRemove || []),
10
30
  ref
@@ -1,4 +1,6 @@
1
+ import { animationProps } from "./base";
1
2
  declare const Box: import("react").ForwardRefExoticComponent<{
2
3
  as?: string;
4
+ animate?: animationProps;
3
5
  } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
4
6
  export default Box;
package/dist/comps/box.js CHANGED
@@ -5,11 +5,4 @@ const Box = forwardRef((props, ref) => {
5
5
  const { as, ...rest } = props;
6
6
  return _jsx(With, { as: as, ...rest, ref: ref });
7
7
  });
8
- // const Box = ( props : UIProps<HTMLDivElement> ) => {
9
- // const { cx } = css.Build(props.as)
10
- // return <div
11
- // ref={props.ref}
12
- // className={cx.join(` `)}
13
- // {...(cleanProps(props) as UIProps<HTMLDivElement>)}>{props.children}</div>
14
- // }
15
8
  export default Box;
@@ -1,4 +1,6 @@
1
+ import { animationProps } from "./base";
1
2
  declare const Button: import("react").ForwardRefExoticComponent<{
2
3
  as?: string;
4
+ animate?: animationProps;
3
5
  } & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
4
6
  export default Button;
@@ -5,15 +5,4 @@ const Button = forwardRef((props, ref) => {
5
5
  const { as, ...rest } = props;
6
6
  return _jsx(With, { tag: `button`, as: as, ...rest, ref: ref });
7
7
  });
8
- // import { Ref } from "react";
9
- // import { css, cleanProps } from "../funs";
10
- // import { UIProps } from "../types/interfaces";
11
- // const Button = ( props: UIProps<HTMLButtonElement> ) => {
12
- // const { as, ref, children } = props
13
- // const { cx } = css.Build(as)
14
- // return <button
15
- // ref={ref}
16
- // className={cx.join(` `)}
17
- // {...(cleanProps(props) as UIProps<HTMLButtonElement>)}>{children}</button>
18
- // }
19
8
  export default Button;
@@ -1,4 +1,6 @@
1
+ import { animationProps } from "./base";
1
2
  declare const CheckBox: import("react").ForwardRefExoticComponent<{
2
3
  as?: string;
4
+ animate?: animationProps;
3
5
  } & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
4
6
  export default CheckBox;
@@ -7,22 +7,4 @@ const CheckBox = forwardRef((props, ref) => {
7
7
  const [checked, setChecked] = useState(props.checked || false);
8
8
  return _jsx(With, { tag: `label`, className: `zuz-checkbox${checked ? ` is-checked` : ``} rel`, as: as, ...rest, children: _jsx(With, { tag: `input`, ref: ref, type: `checkbox`, className: `abs`, name: name, required: required || false, onChange: (e) => setChecked(e.target.checked) }) });
9
9
  });
10
- // import { DetailedHTMLProps, HTMLAttributes, ReactNode, Ref, useState } from "react";
11
- // import { cleanProps, css } from "../funs";
12
- // import { UIProps } from "../types/interfaces";
13
- // const CheckBox = ( props : UIProps<HTMLInputElement> ) => {
14
- // const { cx } = css.Build(props.as)
15
- // const [ checked, setChecked ] = useState(props.checked || false)
16
- // return <label { ...({
17
- // className: `zuz-checkbox${checked ? ` is-checked` : ``} rel${cx.length > 0 ? ` ` + cx.join(` `) : ``}`
18
- // }) as UIProps<HTMLLabelElement>}>
19
- // <input type='checkbox'
20
- // ref={props.ref}
21
- // onChange={e => {
22
- // setChecked(e.target.checked)
23
- // }}
24
- // className={`abs`}
25
- // {...(cleanProps(props) as UIProps<HTMLInputElement>)} />
26
- // </label>
27
- // }
28
10
  export default CheckBox;
@@ -1,10 +1,15 @@
1
+ import { animationProps } from "./base";
1
2
  export interface ContextMenuItem {
2
3
  label: string;
4
+ labelColor?: string;
3
5
  icon?: string;
4
- action: () => void;
6
+ iconColor?: string;
7
+ className?: string;
8
+ onSelect: () => void;
5
9
  }
6
10
  declare const ContextMenu: import("react").ForwardRefExoticComponent<{
7
11
  as?: string;
8
12
  items: ContextMenuItem[];
13
+ animate?: animationProps;
9
14
  } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
10
15
  export default ContextMenu;
@@ -1,8 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import With from "./base";
4
4
  const ContextMenu = forwardRef((props, ref) => {
5
5
  const { as, items, ...rest } = props;
6
- return _jsx(With, { as: as, ...rest, ref: ref });
6
+ return _jsx(With, { as: as, className: `zuz-context-menu abs flex cols`, ...rest, ref: ref, children: items.map((item, index) => item.label == `-` ? _jsx(With, { as: `context-line` }, `${index}-line`) :
7
+ _jsxs(With, { onClick: item.onSelect, as: `button`, className: `context-menu-item flex aic ${item.className || ``}`.trim(), children: [_jsx(With, { as: `div`, className: `ico icon-${item.icon}`.trim(), style: item.iconColor ? { color: item.iconColor } : {} }), _jsx(With, { as: `h1`, className: `flex aic`, style: item.labelColor ? { color: item.labelColor } : {}, children: item.label })] }, `item-${item.label.replace(/\s/g, `-`)}-${index}`)) });
7
8
  });
8
9
  export default ContextMenu;
@@ -1,4 +1,5 @@
1
1
  import { ComponentPropsWithoutRef } from "react";
2
+ import { animationProps } from "./base";
2
3
  import { SpinnerProps } from "./spinner";
3
4
  export interface CoverProps extends ComponentPropsWithoutRef<`div`> {
4
5
  tag?: string;
@@ -6,6 +7,7 @@ export interface CoverProps extends ComponentPropsWithoutRef<`div`> {
6
7
  spinner?: SpinnerProps;
7
8
  color?: string;
8
9
  as?: string;
10
+ animate?: animationProps;
9
11
  }
10
12
  declare const Cover: import("react").ForwardRefExoticComponent<CoverProps & import("react").RefAttributes<HTMLDivElement>>;
11
13
  export default Cover;
@@ -6,31 +6,7 @@ import { hexToRgba } from "../funs";
6
6
  const Cover = forwardRef((props, ref) => {
7
7
  const { spinner, message, color, as, ...rest } = props;
8
8
  return (_jsxs(With, { className: `zuz-cover flex aic jcc cols abs fill`, ref: ref, style: {
9
- backgroundColor: hexToRgba(color || `#ffffff`, .9)
9
+ backgroundColor: color ? !color.startsWith(`#`) ? hexToRgba(color, .9) : color : hexToRgba(color || `#ffffff`, .9)
10
10
  }, as: as, ...rest, children: [_jsx(Spinner, { ...spinner }), _jsx(With, { tag: `h1`, className: `label`, children: message || `loading` })] }));
11
11
  });
12
- // import { ReactNode } from "react";
13
- // import { css, cleanProps, hexToRgba } from "../funs";
14
- // import { UIProps } from "../types/interfaces";
15
- // import Spinner, { SpinnerProps } from "./spinner";
16
- // import Heading from "./heading";
17
- // export interface CoverProps extends UIProps<HTMLDivElement> {
18
- // spinner?: SpinnerProps
19
- // }
20
- // const Cover = ( props : CoverProps ) => {
21
- // const { cx } = css.Build(props.as)
22
- // return <div
23
- // ref={props.ref}
24
- // style={{
25
- // backgroundColor: hexToRgba(props.color || `#ffffff`, .9)
26
- // }}
27
- // className={`zuz-cover flex aic jcc abs fill ${cx.join(` `)}`.trim()}
28
- // {...(cleanProps(props) as UIProps<HTMLDivElement>)}>
29
- // {<Spinner {...( props.spinner || {} as SpinnerProps) } />}
30
- // {/* <span></span> */}
31
- // {/* {<Heading>{props.message}</Heading>} */}
32
- // {/* {props.message ? <Heading>{props.message}</Heading> : null} */}
33
- // {/* { ...({} as HTMLHeadingElement) } */}
34
- // </div>
35
- // }
36
12
  export default Cover;
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,7 +1,9 @@
1
+ import { animationProps } from "./base";
1
2
  import { SpinnerProps } from "./spinner";
2
3
  import { dynamicObject } from "../types";
3
4
  export interface FormProps {
4
5
  as?: string;
6
+ animate?: animationProps;
5
7
  action?: string;
6
8
  errors?: string[];
7
9
  spinner?: SpinnerProps;
@@ -14,5 +16,8 @@ export interface FormProps {
14
16
  message?: string;
15
17
  };
16
18
  }
17
- declare const Form: import("react").ForwardRefExoticComponent<FormProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
19
+ export interface FormHandler {
20
+ setLoading: (mode: boolean) => void;
21
+ }
22
+ declare const Form: import("react").ForwardRefExoticComponent<FormProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<FormHandler>>;
18
23
  export default Form;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useEffect, useRef, useState, useTransition } from "react";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState, useTransition } from "react";
4
4
  import With from "./base";
5
5
  import { isEmail, withPost } from "../funs";
6
6
  import Sheet from "./sheet";
@@ -16,7 +16,6 @@ const Form = forwardRef((props, ref) => {
16
16
  const _nodes = (query) => _ref.current.querySelectorAll(query);
17
17
  const _validate = (el) => {
18
18
  if (el.required) {
19
- // console.log(el.type, el.checked)
20
19
  if (el.type == `checkbox` && el.checked == false) {
21
20
  return false;
22
21
  }
@@ -98,10 +97,6 @@ const Form = forwardRef((props, ref) => {
98
97
  sheet.current.show(errorMsg, 4, SHEET.Error);
99
98
  }
100
99
  else if (action) {
101
- /**
102
- * We have action so
103
- * submit to rest api manually
104
- */
105
100
  startTransition(async () => {
106
101
  setLoading(true);
107
102
  sheet.current.hide();
@@ -139,149 +134,15 @@ const Form = forwardRef((props, ref) => {
139
134
  });
140
135
  }
141
136
  };
137
+ useImperativeHandle(ref, () => ({
138
+ setLoading(mod) {
139
+ setLoading(mod);
140
+ },
141
+ showError(errorMsg) {
142
+ sheet.current.show(errorMsg, 4, SHEET.Error);
143
+ }
144
+ }));
142
145
  useEffect(_init, []);
143
- return _jsxs(With, { as: as, className: `rel`, ref: _ref, propsToRemove: [`withData`, `action`, `onSubmit`, `onSuccess`, `onError`], ...rest, children: [_jsx(Sheet, { ref: sheet }), loading && _jsx(Cover, { message: cover.message || `working`, ...{ spinner, color: cover.color || `#ffffff` } }), children] });
146
+ return _jsxs(With, { as: as, className: `rel`, ref: _ref, propsToRemove: [`withData`, `action`, `onSubmit`, `onSuccess`, `onError`], ...rest, children: [_jsx(Sheet, { ref: sheet }), loading && _jsx(Cover, { message: cover ? cover.message || undefined : `working`, ...{ spinner, color: cover ? `color` in cover ? cover.color : `#ffffff` : `#ffffff` } }), children] });
144
147
  });
145
- // import { RefObject, useEffect, useRef, useState } from "react";
146
- // import { css, cleanProps, isEmail } from "../funs";
147
- // import { dynamicObject, FormInputs } from "../types";
148
- // import { UIProps } from "../types/interfaces";
149
- // import Cover, { CoverProps } from "./cover";
150
- // import { SpinnerProps } from "./spinner";
151
- // import { FORMVALIDATION, SHEET } from "../types/enums";
152
- // import Sheet, { SheetHandler, SheetProps } from "./sheet";
153
- // const Form = ( props : UIProps<HTMLDivElement> ) => {
154
- // const { as, ref, errors, at, cover, spinner, onSubmit, onSuccess, onError, children } = props
155
- // const { cx } = css.Build(as)
156
- // const [ loading, setLoading ] = useState(false)
157
- // const [ sheetType, setSheetType ] = useState(SHEET.Default)
158
- // const sheet = useRef<SheetHandler>(null)
159
- // const _ref = useRef(ref || null)
160
- // const _nodes = ( query: string ) => (_ref as unknown as RefObject<HTMLDivElement>).current.querySelectorAll(query)
161
- // const _init = () => {
162
- // const _submit = _nodes(`[type=submit]`)
163
- // if ( !_submit || _submit.length == 0 ) {
164
- // console.error(`You should add at least 1 button with type=\`SUBMIT\``)
165
- // }
166
- // else {
167
- // _submit.forEach(el => {
168
- // (el as HTMLButtonElement).addEventListener(`click`, _onSubmit)
169
- // })
170
- // }
171
- // }
172
- // const _validate = ( el: any ) : boolean => {
173
- // if ( el.required ){
174
- // if ( el.type == `checkbox` && el.checked == false ){
175
- // return false
176
- // }
177
- // else if ( el.value == `` )
178
- // return false
179
- // }
180
- // if ( el.getAttribute(`with`) ){
181
- // let _with = el.getAttribute(`with`)
182
- // if ( _with.includes(`@`) ){
183
- // _with = _with.split(`@`)[0]
184
- // if ( _with == `match` ){
185
- // _with = FORMVALIDATION.MatchField
186
- // }
187
- // }
188
- // switch ( _with.toUpperCase() ){
189
- // case FORMVALIDATION.Email:
190
- // return isEmail(el.value)
191
- // break;
192
- // case FORMVALIDATION.Uri:
193
- // console.log(`Add FORMVALIDATION.Uri`)
194
- // return false
195
- // break;
196
- // case FORMVALIDATION.Password:
197
- // console.log(`Add FORMVALIDATION.Password`)
198
- // return false
199
- // break;
200
- // case FORMVALIDATION.MatchField:
201
- // const [ __, field ] = el.getAttribute(`with`).split(`@`)
202
- // const _el = document.querySelector<FormInputs>(`[name=${field.trim()}]`)
203
- // if ( !_el ) return false
204
- // console.log(`matching`, _el.name, _el.value, el.name, el.value)
205
- // if ( _el && _el.value != el.value ){
206
- // return false
207
- // }
208
- // break;
209
- // default:
210
- // return true
211
- // }
212
- // }
213
- // return true;
214
- // }
215
- // const _buildFormData = ( ) : {
216
- // error: boolean,
217
- // errorMsg: string,
218
- // data: FormData | dynamicObject
219
- // } => {
220
- // const data : dynamicObject = {}
221
- // let _error: HTMLElement | null = null
222
- // let _errorMsg: HTMLElement | string | null = null
223
- // Array.from(_nodes(`[name]`))
224
- // .forEach((el : any) => {
225
- // let valid = true
226
- // if ( el.required || el.with )
227
- // valid = _validate(el)
228
- // data[el.name] = {
229
- // valid: valid,
230
- // value: el.value
231
- // }
232
- // if ( !valid ){
233
- // if ( _error == null ){
234
- // _error = el
235
- // _errorMsg = errors[el.name]
236
- // }
237
- // el.classList.add(`input-with-error`)
238
- // }else
239
- // el.classList.remove(`input-with-error`)
240
- // })
241
- // if ( _error )
242
- // (_error as HTMLElement).focus()
243
- // return {
244
- // error: _error != null,
245
- // errorMsg: _errorMsg || `Fix errors to continue...`,
246
- // data
247
- // }
248
- // }
249
- // const _onSubmit = ( ) => {
250
- // const data = _buildFormData()
251
- // if ( data.error ){
252
- // sheet.current!.show(data.errorMsg, 4, SHEET.Error)
253
- // }
254
- // else{
255
- // setLoading(true)
256
- // }
257
- // // if ( props.onSubmit ) {
258
- // // // if ( data ){
259
- // // // if ( props.onPost )
260
- // // // props.onPost( data )
261
- // // // else
262
- // // // props.onGet! ( data )
263
- // // // }
264
- // // }
265
- // // else {
266
- // // console.warn(`onSubmit missing for this form.`)
267
- // // }
268
- // }
269
- // useEffect(() => {
270
- // _init()
271
- // }, [])
272
- // return <div
273
- // ref={_ref as unknown as RefObject<HTMLDivElement>}
274
- // className={`rel ${cx.join(` `)}`.trim()}
275
- // {...(cleanProps(props, [`withData`, `at`, `onSubmit`, `onSuccess`, `onError`]) as UIProps<HTMLDivElement>)}>
276
- // {/**
277
- // * Sheet
278
- // */}
279
- // <Sheet ref={sheet} />
280
- // {/**
281
- // * Cover Loader
282
- // */}
283
- // { loading && <Cover {...{ spinner, color: cover || `#ffffff` } as CoverProps} /> }
284
- // {children}
285
- // </div>
286
- // }
287
148
  export default Form;
@@ -1,7 +1,9 @@
1
1
  import { ReactNode } from "react";
2
+ import { animationProps } from "./base";
2
3
  declare const Heading: import("react").ForwardRefExoticComponent<{
3
4
  as?: string;
4
5
  h?: number | string;
5
6
  html?: ReactNode | string;
7
+ animate?: animationProps;
6
8
  } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
7
9
  export default Heading;
@@ -5,17 +5,4 @@ const Heading = forwardRef((props, ref) => {
5
5
  const { as, h, html, children, ...rest } = props;
6
6
  return _jsx(With, { tag: `h${h || 1}`, as: as, ref: ref, ...rest, children: props.html ? _jsx("span", { ...({ dangerouslySetInnerHTML: { __html: html } }) }) : children });
7
7
  });
8
- // import { Ref } from "react"
9
- // import { css, cleanProps } from "../funs";
10
- // import { UIProps } from "../types/interfaces";
11
- // const Heading = ( props: UIProps<HTMLHeadingElement> ) => {
12
- // const { children, ref, h, html } = props
13
- // let Tag : string = `h${h || 1}`;
14
- // const HeadingTag = Tag as `h1` | `h2` | `h3` | `h4` | `h5` | `h6`
15
- // const { cx } = css.Build(props.as)
16
- // return <HeadingTag
17
- // ref={ref}
18
- // className={cx.join(` `)}
19
- // {...(cleanProps(props) as UIProps<HTMLHeadingElement>)}>{props.html ? <span { ...({dangerouslySetInnerHTML:{ __html: html }}) as UIProps<HTMLSpanElement>} /> : children}</HeadingTag>
20
- // }
21
8
  export default Heading;
@@ -1,5 +1,7 @@
1
+ import { animationProps } from "./base";
1
2
  declare const Icon: import("react").ForwardRefExoticComponent<{
2
3
  name: string;
3
4
  as?: string;
5
+ animate?: animationProps;
4
6
  } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
7
  export default Icon;
@@ -5,14 +5,4 @@ const Icon = forwardRef((props, ref) => {
5
5
  const { as, name, ...rest } = props;
6
6
  return _jsx(With, { className: `icon-${name}`, as: as, ...rest, ref: ref });
7
7
  });
8
- // import { DetailedHTMLProps, HTMLAttributes, ReactNode, Ref } from "react";
9
- // import { css, cleanProps } from "../funs";
10
- // import { UIProps } from "../types/interfaces";
11
- // const Icon = ( props : UIProps<HTMLDivElement> ) => {
12
- // const { cx } = css.Build(props.as)
13
- // return <div
14
- // ref={props.ref}
15
- // className={`icon-${props.name}${cx.length > 0 ? ` ` + cx.join(` `) : ``}`}
16
- // {...(cleanProps(props) as UIProps<HTMLDivElement>)}>{props.children}</div>
17
- // }
18
8
  export default Icon;
@@ -0,0 +1,13 @@
1
+ import { animationProps } from "./base";
2
+ import React from "react";
3
+ interface ImageProps {
4
+ width: string | number;
5
+ height: string | number;
6
+ as?: string;
7
+ animate?: animationProps;
8
+ src: string;
9
+ alt: string;
10
+ crossover?: boolean;
11
+ }
12
+ declare const Image: React.ForwardRefExoticComponent<ImageProps & Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
13
+ export default Image;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ const Image = forwardRef((props, ref) => {
5
+ const { as, width, height, ...rest } = props;
6
+ return _jsx(With, { tag: `img`, as: as, ...rest, ref: ref });
7
+ });
8
+ export default Image;
@@ -1,6 +1,8 @@
1
+ import { animationProps } from "./base";
1
2
  import { FORMVALIDATION } from "../types/enums";
2
3
  declare const Input: import("react").ForwardRefExoticComponent<{
3
4
  required?: FORMVALIDATION;
4
5
  as?: string;
6
+ animate?: animationProps;
5
7
  } & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
6
8
  export default Input;
@@ -5,19 +5,4 @@ const Input = forwardRef((props, ref) => {
5
5
  const { as, ...rest } = props;
6
6
  return _jsx(With, { tag: `input`, as: as, ...rest, ref: ref });
7
7
  });
8
- // import { DetailedHTMLProps, HTMLAttributes, InputHTMLAttributes, ReactNode, Ref } from "react";
9
- // import { css, cleanProps } from "../funs";
10
- // import { UIProps } from "../types/interfaces";
11
- // import { FORMVALIDATION } from "../types/enums";
12
- // export interface InputProps extends UIProps<HTMLInputElement> {
13
- // required?: FORMVALIDATION
14
- // }
15
- // const Input = ( props : InputProps ) => {
16
- // const { cx } = css.Build(props.as)
17
- // // console.log(`inputing...`)
18
- // return <input
19
- // ref={props.ref}
20
- // className={cx.join(` `)}
21
- // {...(cleanProps(props) as UIProps<HTMLInputElement>)} />
22
- // }
23
8
  export default Input;