reaxify 0.0.13 → 0.0.15
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Color, ComponentPropsWithoutAs } from '../../types';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
type Placement = "top" | "end" | "bottom" | "start";
|
|
4
|
+
type Props = {
|
|
5
|
+
title: string;
|
|
6
|
+
color?: Color;
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
children?: ReactElement;
|
|
9
|
+
};
|
|
10
|
+
export default function Tooltip({ title, color, placement, className, children, ...props }: ComponentPropsWithoutAs<"span", Props>): ReactElement<any, string | import('react').JSXElementConstructor<any>> | null;
|
|
11
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const v=require("../components/Form/index.cjs.js"),o=require("../helpers/randomID.cjs.js"),s=require("react");function x({rules:
|
|
1
|
+
"use strict";const v=require("../components/Form/index.cjs.js"),o=require("../helpers/randomID.cjs.js"),s=require("react");function x({rules:n}){const{setFormControl:e,removeFormControl:u}=s.useContext(v.FormContext),[b,c]=s.useState(!1),[g,a]=s.useState(null),f=s.useCallback(t=>{const r=t.id,i=t.value;if(!n.length){e==null||e(r,()=>!0),a(null),c(!1);return}for(const p of n){const l=p(i);if(typeof l=="string"){e==null||e(r,()=>(c(!0),!1)),a(l);return}}e==null||e(r,()=>!0),a(null),c(!1)},[n,e]);return{ref:s.useCallback(t=>{if(!t)return;t.id||(t.id=o());const r=t.id;f(t);const i=new MutationObserver(()=>f(t));return i.observe(t,{attributes:!0,childList:!0,subtree:!0}),()=>{i.disconnect(),u==null||u(r)}},[f,u]),error:b,errorMessage:g}}module.exports=x;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { FormContext as v } from "../components/Form/index.es.js";
|
|
2
2
|
import x from "../helpers/randomID.es.js";
|
|
3
3
|
import { useContext as M, useState as l, useCallback as p } from "react";
|
|
4
|
-
function d({ rules:
|
|
5
|
-
const { setFormControl: r, removeFormControl: s } = M(v), [o,
|
|
4
|
+
function d({ rules: i }) {
|
|
5
|
+
const { setFormControl: r, removeFormControl: s } = M(v), [o, n] = l(!1), [b, a] = l(null), f = p(
|
|
6
6
|
(t) => {
|
|
7
|
-
const e = t.id,
|
|
8
|
-
if (!
|
|
9
|
-
r == null || r(e, () => !0), a(null),
|
|
7
|
+
const e = t.id, u = t.value;
|
|
8
|
+
if (!i.length) {
|
|
9
|
+
r == null || r(e, () => !0), a(null), n(!1);
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
for (const g of
|
|
13
|
-
const c = g(
|
|
12
|
+
for (const g of i) {
|
|
13
|
+
const c = g(u);
|
|
14
14
|
if (typeof c == "string") {
|
|
15
|
-
r == null || r(e, () => (
|
|
15
|
+
r == null || r(e, () => (n(!0), !1)), a(c);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
r == null || r(e, () => !0), a(null),
|
|
19
|
+
r == null || r(e, () => !0), a(null), n(!1);
|
|
20
20
|
},
|
|
21
|
-
[
|
|
21
|
+
[i, r]
|
|
22
22
|
);
|
|
23
23
|
return { ref: p(
|
|
24
24
|
(t) => {
|
|
@@ -26,13 +26,13 @@ function d({ rules: n }) {
|
|
|
26
26
|
t.id || (t.id = x());
|
|
27
27
|
const e = t.id;
|
|
28
28
|
f(t);
|
|
29
|
-
const
|
|
30
|
-
return
|
|
29
|
+
const u = new MutationObserver(() => f(t));
|
|
30
|
+
return u.observe(t, {
|
|
31
31
|
attributes: !0,
|
|
32
32
|
childList: !0,
|
|
33
33
|
subtree: !0
|
|
34
34
|
}), () => {
|
|
35
|
-
|
|
35
|
+
u.disconnect(), s == null || s(e);
|
|
36
36
|
};
|
|
37
37
|
},
|
|
38
38
|
[f, s]
|
|
@@ -292,6 +292,25 @@ export type ThemeProviderContextType = {
|
|
|
292
292
|
body2: string;
|
|
293
293
|
};
|
|
294
294
|
};
|
|
295
|
+
tooltip: {
|
|
296
|
+
base: string;
|
|
297
|
+
color: {
|
|
298
|
+
primary: string;
|
|
299
|
+
secondary: string;
|
|
300
|
+
success: string;
|
|
301
|
+
info: string;
|
|
302
|
+
warning: string;
|
|
303
|
+
danger: string;
|
|
304
|
+
dark: string;
|
|
305
|
+
light: string;
|
|
306
|
+
};
|
|
307
|
+
placement: {
|
|
308
|
+
top: string;
|
|
309
|
+
end: string;
|
|
310
|
+
bottom: string;
|
|
311
|
+
start: string;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
295
314
|
};
|
|
296
315
|
};
|
|
297
316
|
type Props = ChildrenProps & DeepPartial<ThemeProviderContextType>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, ElementType, ReactNode } from 'react';
|
|
2
2
|
import { TransitionStatus } from 'react-transition-group';
|
|
3
|
+
export type ComponentPropsWithoutAs<E extends ElementType, P extends Record<string, unknown> = {}> = P & Omit<ComponentProps<E>, keyof P>;
|
|
3
4
|
export type ComponentPropsWithAs<E extends ElementType, P extends Record<string, unknown> = {}> = P & {
|
|
4
5
|
as?: E;
|
|
5
6
|
} & Omit<ComponentProps<E>, "as" | keyof P>;
|