@zuzjs/ui 0.3.7 → 0.3.9

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 (45) hide show
  1. package/dist/bin.d.ts +2 -0
  2. package/dist/bin.js +107 -0
  3. package/dist/comps/base.d.ts +10 -0
  4. package/dist/comps/base.js +12 -0
  5. package/dist/comps/box.d.ts +4 -0
  6. package/dist/comps/box.js +15 -0
  7. package/dist/comps/button.d.ts +4 -0
  8. package/dist/comps/button.js +19 -0
  9. package/dist/comps/checkbox.d.ts +4 -0
  10. package/dist/comps/checkbox.js +28 -0
  11. package/dist/comps/cover.d.ts +11 -0
  12. package/dist/comps/cover.js +36 -0
  13. package/dist/comps/form.d.ts +18 -0
  14. package/dist/comps/form.js +287 -0
  15. package/dist/comps/heading.d.ts +7 -0
  16. package/dist/comps/heading.js +21 -0
  17. package/dist/comps/icon.d.ts +5 -0
  18. package/dist/comps/icon.js +18 -0
  19. package/dist/comps/input.d.ts +6 -0
  20. package/dist/comps/input.js +23 -0
  21. package/dist/comps/sheet.d.ts +13 -0
  22. package/dist/comps/sheet.js +102 -0
  23. package/dist/comps/spinner.d.ts +14 -0
  24. package/dist/comps/spinner.js +42 -0
  25. package/dist/funs/colors.d.ts +7 -0
  26. package/dist/funs/colors.js +9 -0
  27. package/dist/funs/css.d.ts +269 -0
  28. package/dist/funs/css.js +413 -0
  29. package/dist/funs/index.d.ts +20 -0
  30. package/dist/funs/index.js +125 -0
  31. package/dist/funs/stylesheet.d.ts +242 -0
  32. package/dist/funs/stylesheet.js +249 -0
  33. package/dist/index.d.ts +11 -0
  34. package/dist/index.js +11 -0
  35. package/dist/styles.css +1 -460
  36. package/dist/types/enums.d.ts +19 -0
  37. package/dist/types/enums.js +23 -0
  38. package/dist/types/index.d.ts +24 -0
  39. package/dist/types/index.js +1 -0
  40. package/dist/types/interfaces.d.ts +4 -0
  41. package/dist/types/interfaces.js +1 -0
  42. package/package.json +50 -44
  43. package/README.md +0 -1
  44. package/dist/hooks.js +0 -89
  45. package/dist/ui.js +0 -688
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+ import fs, { readdirSync, statSync } from "fs";
3
+ import { program } from "commander";
4
+ import chokidar from 'chokidar';
5
+ import path from "path";
6
+ import CSS from "./funs/css.js";
7
+ import pc from "picocolors";
8
+ program
9
+ .option(`-d, --debug`)
10
+ .option(`-v, --version`)
11
+ .option(`-root, --root <char>`);
12
+ program.parse();
13
+ const options = program.opts();
14
+ const getAllFiles = (dir, extn, files, result, regex) => {
15
+ files = files || readdirSync(dir);
16
+ result = result || [];
17
+ regex = regex || new RegExp(`\\${extn}$`);
18
+ for (let i = 0; i < files.length; i++) {
19
+ let file = path.join(dir, files[i]);
20
+ if (statSync(file).isDirectory()) {
21
+ try {
22
+ result = getAllFiles(file, extn, readdirSync(file), result, regex);
23
+ }
24
+ catch (error) {
25
+ continue;
26
+ }
27
+ }
28
+ else {
29
+ if (regex.test(file)) {
30
+ result.push(file);
31
+ }
32
+ }
33
+ }
34
+ return result;
35
+ };
36
+ const rebuild = (f) => {
37
+ const raw = fs.readFileSync(f, `utf8`);
38
+ const list = [];
39
+ const processMatch = (matches, type) => {
40
+ if (matches && matches.length > 0) {
41
+ matches.map((m) => {
42
+ let v2;
43
+ if (type == `as`) {
44
+ const [x, v1] = m.split(/as\s*=/);
45
+ v2 = v1.trim().slice(1, -1);
46
+ }
47
+ else if (type == `css`) {
48
+ const v1 = m.split(/css\s*\(/)[1].slice(0, -1);
49
+ v2 = v1.trim().slice(1, -1);
50
+ }
51
+ list.push(v2);
52
+ // console.log(type, v2)
53
+ // const _ = v2!.match(/\w+:\$?\w+|\$?\w+/g)
54
+ // if(_){
55
+ // _.map((n:string) => !list.includes(n) && list.push(n))
56
+ // }
57
+ });
58
+ }
59
+ };
60
+ /**
61
+ * match as={?}
62
+ */
63
+ processMatch(raw.match(/as\s*=\s*\{([^{}]|{([^{}]|{[^{}]*})*})*\}/g), `as`);
64
+ /**
65
+ * match css()
66
+ */
67
+ processMatch(raw.match(/css\(\s*`([^`]*?([$&]{[^}]*})?[^`]*)*`\s*\)/g), `css`);
68
+ return list;
69
+ };
70
+ const rebuildAll = () => {
71
+ console.log(pc.gray(`○ Building Zuz CSS`));
72
+ const files = getAllFiles(process.cwd(), `.jsx`);
73
+ if (files.length > 0) {
74
+ const as = [];
75
+ files.map(f => {
76
+ const filter = null;
77
+ if (filter && f.endsWith(filter)) {
78
+ const r = rebuild(f);
79
+ if (r && r.length > 0)
80
+ as.push(r);
81
+ }
82
+ else {
83
+ const r = rebuild(f);
84
+ if (r && r.length > 0)
85
+ as.push(r);
86
+ }
87
+ });
88
+ const { sheet } = new CSS().Build(as);
89
+ // console.log(cache)
90
+ if (!fs.existsSync(path.join(process.cwd(), `src`, `app`, `css`))) {
91
+ fs.mkdirSync(path.join(process.cwd(), `src`, `app`, `css`));
92
+ }
93
+ // console.log(sheet)
94
+ fs.writeFileSync(path.join(process.cwd(), `src`, `app`, `css`, `zuz.scss`), sheet, {
95
+ encoding: `utf8`,
96
+ flag: `w+`
97
+ });
98
+ console.log(pc.green(`✓ Zuz CSS Generated`));
99
+ }
100
+ };
101
+ const watcher = chokidar.watch([
102
+ `${path.resolve(`./`)}/**/*.jsx`
103
+ ], {
104
+ ignored: (p) => p.includes(`/dist`) || p.includes('node_modules'),
105
+ persistent: true
106
+ });
107
+ watcher.on(`change`, rebuildAll);
@@ -0,0 +1,10 @@
1
+ import { ComponentPropsWithoutRef, ElementType } from "react";
2
+ interface BaseProps<T extends ElementType> {
3
+ tag?: T;
4
+ as?: string;
5
+ className?: string;
6
+ propsToRemove?: string[];
7
+ }
8
+ export type Props<T extends ElementType> = BaseProps<T> & ComponentPropsWithoutRef<T>;
9
+ declare const With: import("react").ForwardRefExoticComponent<Omit<Props<ElementType>, "ref"> & import("react").RefAttributes<Element>>;
10
+ export default With;
@@ -0,0 +1,12 @@
1
+ import { createElement, forwardRef } from "react";
2
+ import { css, cleanProps } from "../funs";
3
+ const With = forwardRef(({ tag, as, className, propsToRemove, ...rest }, ref) => {
4
+ const Comp = tag || 'div';
5
+ const { cx } = new css().Build(as || []);
6
+ return createElement(Comp, {
7
+ className: [className, ...cx].join(' ').trim(),
8
+ ...cleanProps(rest, propsToRemove || []),
9
+ ref
10
+ });
11
+ });
12
+ export default With;
@@ -0,0 +1,4 @@
1
+ declare const Box: import("react").ForwardRefExoticComponent<{
2
+ as?: string;
3
+ } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default Box;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ const Box = forwardRef((props, ref) => {
5
+ const { as, ...rest } = props;
6
+ return _jsx(With, { as: as, ...rest, ref: ref });
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
+ export default Box;
@@ -0,0 +1,4 @@
1
+ declare const Button: import("react").ForwardRefExoticComponent<{
2
+ as?: string;
3
+ } & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
4
+ export default Button;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ const Button = forwardRef((props, ref) => {
5
+ const { as, ...rest } = props;
6
+ return _jsx(With, { tag: `button`, as: as, ...rest, ref: ref });
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
+ export default Button;
@@ -0,0 +1,4 @@
1
+ declare const CheckBox: import("react").ForwardRefExoticComponent<{
2
+ as?: string;
3
+ } & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
4
+ export default CheckBox;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useState } from "react";
4
+ import With from "./base";
5
+ const CheckBox = forwardRef((props, ref) => {
6
+ const { as, name, required, ...rest } = props;
7
+ const [checked, setChecked] = useState(props.checked || false);
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
+ });
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
+ export default CheckBox;
@@ -0,0 +1,11 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ import { SpinnerProps } from "./spinner";
3
+ export interface CoverProps extends ComponentPropsWithoutRef<`div`> {
4
+ tag?: string;
5
+ message?: string;
6
+ spinner?: SpinnerProps;
7
+ color?: string;
8
+ as?: string;
9
+ }
10
+ declare const Cover: import("react").ForwardRefExoticComponent<CoverProps & import("react").RefAttributes<HTMLDivElement>>;
11
+ export default Cover;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ import Spinner from "./spinner";
5
+ import { hexToRgba } from "../funs";
6
+ const Cover = forwardRef((props, ref) => {
7
+ const { spinner, message, color, as, ...rest } = props;
8
+ return (_jsxs(With, { className: `zuz-cover flex aic jcc cols abs fill`, ref: ref, style: {
9
+ backgroundColor: hexToRgba(color || `#ffffff`, .9)
10
+ }, as: as, ...rest, children: [_jsx(Spinner, { ...spinner }), _jsx(With, { tag: `h1`, className: `label`, children: message || `loading` })] }));
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
+ export default Cover;
@@ -0,0 +1,18 @@
1
+ import { SpinnerProps } from "./spinner";
2
+ import { dynamicObject } from "../types";
3
+ export interface FormProps {
4
+ as?: string;
5
+ action?: string;
6
+ errors?: string[];
7
+ spinner?: SpinnerProps;
8
+ withData?: dynamicObject;
9
+ onSubmit?: (data: FormData | dynamicObject) => void;
10
+ onSuccess?: (data: dynamicObject) => void;
11
+ onError?: (error: any) => void;
12
+ cover?: {
13
+ color?: string;
14
+ message?: string;
15
+ };
16
+ }
17
+ declare const Form: import("react").ForwardRefExoticComponent<FormProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
18
+ export default Form;
@@ -0,0 +1,287 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useEffect, useRef, useState, useTransition } from "react";
4
+ import With from "./base";
5
+ import { isEmail, withPost } from "../funs";
6
+ import Sheet from "./sheet";
7
+ import { FORMVALIDATION, SHEET } from "../types/enums";
8
+ import Cover from "./cover";
9
+ const Form = forwardRef((props, ref) => {
10
+ const { as, spinner, action, errors, cover, children, withData, onSuccess, onSubmit, onError, ...rest } = props;
11
+ const [loading, setLoading] = useState(false);
12
+ const [isLoading, startTransition] = useTransition();
13
+ const [sheetType, setSheetType] = useState(SHEET.Default);
14
+ const sheet = useRef(null);
15
+ const _ref = useRef(null);
16
+ const _nodes = (query) => _ref.current.querySelectorAll(query);
17
+ const _validate = (el) => {
18
+ if (el.required) {
19
+ // console.log(el.type, el.checked)
20
+ if (el.type == `checkbox` && el.checked == false) {
21
+ return false;
22
+ }
23
+ if (el.value == ``)
24
+ return false;
25
+ }
26
+ if (el.getAttribute(`with`)) {
27
+ let _with = el.getAttribute(`with`);
28
+ if (_with.includes(`@`)) {
29
+ _with = _with.split(`@`)[0];
30
+ if (_with == `match`) {
31
+ _with = FORMVALIDATION.MatchField;
32
+ }
33
+ }
34
+ switch (_with.toUpperCase()) {
35
+ case FORMVALIDATION.Email:
36
+ return isEmail(el.value);
37
+ break;
38
+ case FORMVALIDATION.Uri:
39
+ console.log(`Add FORMVALIDATION.Uri`);
40
+ return false;
41
+ break;
42
+ case FORMVALIDATION.Password:
43
+ console.log(`Add FORMVALIDATION.Password`);
44
+ return false;
45
+ break;
46
+ case FORMVALIDATION.MatchField:
47
+ const [__, field] = el.getAttribute(`with`).split(`@`);
48
+ const _el = document.querySelector(`[name=${field.trim()}]`);
49
+ if (!_el)
50
+ return false;
51
+ console.log(`matching`, _el.name, _el.value, el.name, el.value);
52
+ if (_el && _el.value != el.value) {
53
+ return false;
54
+ }
55
+ break;
56
+ default:
57
+ return true;
58
+ }
59
+ }
60
+ return true;
61
+ };
62
+ const _buildFormData = () => {
63
+ const data = {};
64
+ const payload = {};
65
+ let _error = null;
66
+ let _errorMsg = null;
67
+ Array.from(_nodes(`[name]`))
68
+ .forEach((el) => {
69
+ let valid = true;
70
+ if (el.required || el.with)
71
+ valid = _validate(el);
72
+ data[el.name] = {
73
+ valid: valid,
74
+ value: el.value
75
+ };
76
+ payload[el.name] = el.value;
77
+ if (!valid) {
78
+ if (_error == null && errors) {
79
+ _error = el;
80
+ _errorMsg = errors[el.name];
81
+ }
82
+ el.classList.add(`input-with-error`);
83
+ }
84
+ else
85
+ el.classList.remove(`input-with-error`);
86
+ });
87
+ if (_error)
88
+ _error.focus();
89
+ return {
90
+ error: _error != null,
91
+ errorMsg: _errorMsg || `Fix errors to continue...`,
92
+ data, payload
93
+ };
94
+ };
95
+ const _onSubmit = () => {
96
+ const { error, errorMsg, payload } = _buildFormData();
97
+ if (error) {
98
+ sheet.current.show(errorMsg, 4, SHEET.Error);
99
+ }
100
+ else if (action) {
101
+ /**
102
+ * We have action so
103
+ * submit to rest api manually
104
+ */
105
+ startTransition(async () => {
106
+ setLoading(true);
107
+ sheet.current.hide();
108
+ withPost(action, { ...payload, ...(withData || {}) })
109
+ .then(_resp => {
110
+ const resp = _resp;
111
+ setLoading(false);
112
+ if (onSuccess)
113
+ onSuccess(resp);
114
+ else
115
+ sheet.current.hide();
116
+ sheet.current.show(resp.message || `Redirecting..`, 4, SHEET.Success);
117
+ })
118
+ .catch(err => {
119
+ setLoading(false);
120
+ if (onError)
121
+ onError(err);
122
+ else
123
+ sheet.current.show(err.message || `We cannot process your request at this time.`, 4, SHEET.Error);
124
+ });
125
+ });
126
+ }
127
+ else {
128
+ onSubmit && onSubmit(payload);
129
+ }
130
+ };
131
+ const _init = () => {
132
+ const _submit = _nodes(`[type=submit]`);
133
+ if (!_submit || _submit.length == 0) {
134
+ console.error(`You should add at least 1 button with type=\`SUBMIT\``);
135
+ }
136
+ else {
137
+ _submit.forEach(el => {
138
+ el.addEventListener(`click`, _onSubmit);
139
+ });
140
+ }
141
+ };
142
+ 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] });
144
+ });
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
+ export default Form;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from "react";
2
+ declare const Heading: import("react").ForwardRefExoticComponent<{
3
+ as?: string;
4
+ h?: number | string;
5
+ html?: ReactNode | string;
6
+ } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
7
+ export default Heading;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ const Heading = forwardRef((props, ref) => {
5
+ const { as, h, html, children, ...rest } = props;
6
+ return _jsx(With, { tag: `h${h || 1}`, as: as, ref: ref, ...rest, children: props.html ? _jsx("span", { ...({ dangerouslySetInnerHTML: { __html: html } }) }) : children });
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
+ export default Heading;
@@ -0,0 +1,5 @@
1
+ declare const Icon: import("react").ForwardRefExoticComponent<{
2
+ name: string;
3
+ as?: string;
4
+ } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
+ export default Icon;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ const Icon = forwardRef((props, ref) => {
5
+ const { as, name, ...rest } = props;
6
+ return _jsx(With, { className: `icon-${name}`, as: as, ...rest, ref: ref });
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
+ export default Icon;
@@ -0,0 +1,6 @@
1
+ import { FORMVALIDATION } from "../types/enums";
2
+ declare const Input: import("react").ForwardRefExoticComponent<{
3
+ required?: FORMVALIDATION;
4
+ as?: string;
5
+ } & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
6
+ export default Input;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import With from "./base";
4
+ const Input = forwardRef((props, ref) => {
5
+ const { as, ...rest } = props;
6
+ return _jsx(With, { tag: `input`, as: as, ...rest, ref: ref });
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
+ export default Input;