@public-ui/react 1.1.7-rc.10
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.
- package/LICENSE +287 -0
- package/README.md +7 -0
- package/cjs/index.d.ts +46 -0
- package/cjs/index.js +49 -0
- package/cjs/index.js.map +1 -0
- package/cjs/react-component-lib/createComponent.d.ts +10 -0
- package/cjs/react-component-lib/createComponent.js +92 -0
- package/cjs/react-component-lib/createComponent.js.map +1 -0
- package/cjs/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/cjs/react-component-lib/createOverlayComponent.js +105 -0
- package/cjs/react-component-lib/createOverlayComponent.js.map +1 -0
- package/cjs/react-component-lib/index.d.ts +2 -0
- package/cjs/react-component-lib/index.js +8 -0
- package/cjs/react-component-lib/index.js.map +1 -0
- package/cjs/react-component-lib/interfaces.d.ts +29 -0
- package/cjs/react-component-lib/interfaces.js +3 -0
- package/cjs/react-component-lib/interfaces.js.map +1 -0
- package/cjs/react-component-lib/utils/attachProps.d.ts +8 -0
- package/cjs/react-component-lib/utils/attachProps.js +92 -0
- package/cjs/react-component-lib/utils/attachProps.js.map +1 -0
- package/cjs/react-component-lib/utils/case.d.ts +2 -0
- package/cjs/react-component-lib/utils/case.js +12 -0
- package/cjs/react-component-lib/utils/case.js.map +1 -0
- package/cjs/react-component-lib/utils/dev.d.ts +2 -0
- package/cjs/react-component-lib/utils/dev.js +18 -0
- package/cjs/react-component-lib/utils/dev.js.map +1 -0
- package/cjs/react-component-lib/utils/index.d.ts +10 -0
- package/cjs/react-component-lib/utils/index.js +57 -0
- package/cjs/react-component-lib/utils/index.js.map +1 -0
- package/esm/index.d.ts +46 -0
- package/esm/index.js +46 -0
- package/esm/index.js.map +1 -0
- package/esm/react-component-lib/createComponent.d.ts +10 -0
- package/esm/react-component-lib/createComponent.js +65 -0
- package/esm/react-component-lib/createComponent.js.map +1 -0
- package/esm/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/esm/react-component-lib/createOverlayComponent.js +98 -0
- package/esm/react-component-lib/createOverlayComponent.js.map +1 -0
- package/esm/react-component-lib/index.d.ts +2 -0
- package/esm/react-component-lib/index.js +3 -0
- package/esm/react-component-lib/index.js.map +1 -0
- package/esm/react-component-lib/interfaces.d.ts +29 -0
- package/esm/react-component-lib/interfaces.js +2 -0
- package/esm/react-component-lib/interfaces.js.map +1 -0
- package/esm/react-component-lib/utils/attachProps.d.ts +8 -0
- package/esm/react-component-lib/utils/attachProps.js +85 -0
- package/esm/react-component-lib/utils/attachProps.js.map +1 -0
- package/esm/react-component-lib/utils/case.d.ts +2 -0
- package/esm/react-component-lib/utils/case.js +7 -0
- package/esm/react-component-lib/utils/case.js.map +1 -0
- package/esm/react-component-lib/utils/dev.d.ts +2 -0
- package/esm/react-component-lib/utils/dev.js +13 -0
- package/esm/react-component-lib/utils/dev.js.map +1 -0
- package/esm/react-component-lib/utils/index.d.ts +10 -0
- package/esm/react-component-lib/utils/index.js +33 -0
- package/esm/react-component-lib/utils/index.js.map +1 -0
- package/package.json +73 -0
- package/types/index.d.ts +46 -0
- package/types/react-component-lib/createComponent.d.ts +10 -0
- package/types/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/types/react-component-lib/index.d.ts +2 -0
- package/types/react-component-lib/interfaces.d.ts +29 -0
- package/types/react-component-lib/utils/attachProps.d.ts +8 -0
- package/types/react-component-lib/utils/attachProps.js +85 -0
- package/types/react-component-lib/utils/attachProps.js.map +1 -0
- package/types/react-component-lib/utils/case.d.ts +2 -0
- package/types/react-component-lib/utils/case.js +7 -0
- package/types/react-component-lib/utils/case.js.map +1 -0
- package/types/react-component-lib/utils/dev.d.ts +2 -0
- package/types/react-component-lib/utils/dev.js +13 -0
- package/types/react-component-lib/utils/dev.js.map +1 -0
- package/types/react-component-lib/utils/index.d.ts +10 -0
- package/types/react-component-lib/utils/index.js +33 -0
- package/types/react-component-lib/utils/index.js.map +1 -0
- package/umd/index.d.ts +46 -0
- package/umd/index.js +59 -0
- package/umd/index.js.map +1 -0
- package/umd/react-component-lib/createComponent.d.ts +10 -0
- package/umd/react-component-lib/createComponent.js +102 -0
- package/umd/react-component-lib/createComponent.js.map +1 -0
- package/umd/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/umd/react-component-lib/createOverlayComponent.js +115 -0
- package/umd/react-component-lib/createOverlayComponent.js.map +1 -0
- package/umd/react-component-lib/index.d.ts +2 -0
- package/umd/react-component-lib/index.js +18 -0
- package/umd/react-component-lib/index.js.map +1 -0
- package/umd/react-component-lib/interfaces.d.ts +29 -0
- package/umd/react-component-lib/interfaces.js +13 -0
- package/umd/react-component-lib/interfaces.js.map +1 -0
- package/umd/react-component-lib/utils/attachProps.d.ts +8 -0
- package/umd/react-component-lib/utils/attachProps.js +102 -0
- package/umd/react-component-lib/utils/attachProps.js.map +1 -0
- package/umd/react-component-lib/utils/case.d.ts +2 -0
- package/umd/react-component-lib/utils/case.js +22 -0
- package/umd/react-component-lib/utils/case.js.map +1 -0
- package/umd/react-component-lib/utils/dev.d.ts +2 -0
- package/umd/react-component-lib/utils/dev.js +28 -0
- package/umd/react-component-lib/utils/dev.js.map +1 -0
- package/umd/react-component-lib/utils/index.d.ts +10 -0
- package/umd/react-component-lib/utils/index.js +67 -0
- package/umd/react-component-lib/utils/index.js.map +1 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { camelToDashCase } from './case';
|
|
2
|
+
export const attachProps = (node, newProps, oldProps = {}) => {
|
|
3
|
+
if (node instanceof Element) {
|
|
4
|
+
const className = getClassName(node.classList, newProps, oldProps);
|
|
5
|
+
if (className !== '') {
|
|
6
|
+
node.className = className;
|
|
7
|
+
}
|
|
8
|
+
Object.keys(newProps).forEach((name) => {
|
|
9
|
+
if (name === 'children' ||
|
|
10
|
+
name === 'style' ||
|
|
11
|
+
name === 'ref' ||
|
|
12
|
+
name === 'class' ||
|
|
13
|
+
name === 'className' ||
|
|
14
|
+
name === 'forwardedRef') {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
18
|
+
const eventName = name.substring(2);
|
|
19
|
+
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
20
|
+
if (!isCoveredByReact(eventNameLc)) {
|
|
21
|
+
syncEvent(node, eventNameLc, newProps[name]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
node[name] = newProps[name];
|
|
26
|
+
const propType = typeof newProps[name];
|
|
27
|
+
if (propType === 'string') {
|
|
28
|
+
node.setAttribute(camelToDashCase(name), newProps[name]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export const getClassName = (classList, newProps, oldProps) => {
|
|
35
|
+
const newClassProp = newProps.className || newProps.class;
|
|
36
|
+
const oldClassProp = oldProps.className || oldProps.class;
|
|
37
|
+
const currentClasses = arrayToMap(classList);
|
|
38
|
+
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
|
|
39
|
+
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
|
|
40
|
+
const finalClassNames = [];
|
|
41
|
+
currentClasses.forEach((currentClass) => {
|
|
42
|
+
if (incomingPropClasses.has(currentClass)) {
|
|
43
|
+
finalClassNames.push(currentClass);
|
|
44
|
+
incomingPropClasses.delete(currentClass);
|
|
45
|
+
}
|
|
46
|
+
else if (!oldPropClasses.has(currentClass)) {
|
|
47
|
+
finalClassNames.push(currentClass);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
incomingPropClasses.forEach((s) => finalClassNames.push(s));
|
|
51
|
+
return finalClassNames.join(' ');
|
|
52
|
+
};
|
|
53
|
+
export const isCoveredByReact = (eventNameSuffix) => {
|
|
54
|
+
if (typeof document === 'undefined') {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const eventName = 'on' + eventNameSuffix;
|
|
59
|
+
let isSupported = eventName in document;
|
|
60
|
+
if (!isSupported) {
|
|
61
|
+
const element = document.createElement('div');
|
|
62
|
+
element.setAttribute(eventName, 'return;');
|
|
63
|
+
isSupported = typeof element[eventName] === 'function';
|
|
64
|
+
}
|
|
65
|
+
return isSupported;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export const syncEvent = (node, eventName, newEventHandler) => {
|
|
69
|
+
const eventStore = node.__events || (node.__events = {});
|
|
70
|
+
const oldEventHandler = eventStore[eventName];
|
|
71
|
+
if (oldEventHandler) {
|
|
72
|
+
node.removeEventListener(eventName, oldEventHandler);
|
|
73
|
+
}
|
|
74
|
+
node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
|
|
75
|
+
if (newEventHandler) {
|
|
76
|
+
newEventHandler.call(this, e);
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
const arrayToMap = (arr) => {
|
|
81
|
+
const map = new Map();
|
|
82
|
+
arr.forEach((s) => map.set(s, s));
|
|
83
|
+
return map;
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=attachProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachProps.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/attachProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,QAAa,EAAE,WAAgB,EAAE,EAAE,EAAE;IAElF,IAAI,IAAI,YAAY,OAAO,EAAE;QAE3B,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,SAAS,KAAK,EAAE,EAAE;YACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;SAC5B;QAED,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OA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a,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAC3C,WAAW,GAAG,OAAQ,OAAe,CAAC,SAAS,CAAC,KAAK,UAAU,CAAC;SACjE;QAED,OAAO,WAAW,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAiF,EACjF,SAAiB,EACjB,eAAmC,EACnC,EAAE;IACF,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;IACzD,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAG9C,IAAI,eAAe,EAAE;QACnB,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;KACtD;IAGD,IAAI,CAAC,gBAAgB,CACnB,SAAS,EACT,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,OAAO,CAAC,CAAQ;QAChD,IAAI,eAAe,EAAE;YACnB,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SAC/B;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAA4B,EAAE,EAAE;IAClD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACrC,GAAgB,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const dashToPascalCase = (str) => str
|
|
2
|
+
.toLowerCase()
|
|
3
|
+
.split('-')
|
|
4
|
+
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
5
|
+
.join('');
|
|
6
|
+
export const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
|
|
7
|
+
//# sourceMappingURL=case.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"case.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/case.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC9C,GAAG;KACA,WAAW,EAAE;KACb,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACpE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const isDevMode = () => {
|
|
2
|
+
return process && process.env && process.env.NODE_ENV === 'development';
|
|
3
|
+
};
|
|
4
|
+
const warnings = {};
|
|
5
|
+
export const deprecationWarning = (key, message) => {
|
|
6
|
+
if (isDevMode()) {
|
|
7
|
+
if (!warnings[key]) {
|
|
8
|
+
console.warn(message);
|
|
9
|
+
warnings[key] = true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/dev.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,OAAO,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,QAAQ,GAA+B,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,OAAe,EAAE,EAAE;IACjE,IAAI,SAAS,EAAE,EAAE;QACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;SACtB;KACF;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StyleReactProps } from '../interfaces';
|
|
3
|
+
export declare type StencilReactExternalProps<PropType, ElementType> = PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & StyleReactProps;
|
|
4
|
+
export declare type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
|
|
5
|
+
export declare const setRef: (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => void;
|
|
6
|
+
export declare const mergeRefs: (...refs: (StencilReactForwardedRef<any> | React.Ref<any> | undefined)[]) => React.RefCallback<any>;
|
|
7
|
+
export declare const createForwardRef: <PropType, ElementType>(ReactComponent: any, displayName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
8
|
+
export declare const defineCustomElement: (tagName: string, customElement: any) => void;
|
|
9
|
+
export * from './attachProps';
|
|
10
|
+
export * from './case';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const setRef = (ref, value) => {
|
|
3
|
+
if (typeof ref === 'function') {
|
|
4
|
+
ref(value);
|
|
5
|
+
}
|
|
6
|
+
else if (ref != null) {
|
|
7
|
+
ref.current = value;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export const mergeRefs = (...refs) => {
|
|
11
|
+
return (value) => {
|
|
12
|
+
refs.forEach(ref => {
|
|
13
|
+
setRef(ref, value);
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export const createForwardRef = (ReactComponent, displayName) => {
|
|
18
|
+
const forwardRef = (props, ref) => {
|
|
19
|
+
return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
|
|
20
|
+
};
|
|
21
|
+
forwardRef.displayName = displayName;
|
|
22
|
+
return React.forwardRef(forwardRef);
|
|
23
|
+
};
|
|
24
|
+
export const defineCustomElement = (tagName, customElement) => {
|
|
25
|
+
if (customElement !== undefined &&
|
|
26
|
+
typeof customElements !== 'undefined' &&
|
|
27
|
+
!customElements.get(tagName)) {
|
|
28
|
+
customElements.define(tagName, customElement);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export * from './attachProps';
|
|
32
|
+
export * from './case';
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAA+D,EAAE,KAAU,EAAE,EAAE;IACpG,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;QAC7B,GAAG,CAAC,KAAK,CAAC,CAAA;KACX;SAAM,IAAI,GAAG,IAAI,IAAI,EAAE;QAErB,GAAmC,CAAC,OAAO,GAAG,KAAK,CAAA;KACrD;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAAG,IAAoE,EAC/C,EAAE;IAC1B,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACjB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,cAAmB,EACnB,WAAmB,EACnB,EAAE;IACF,MAAM,UAAU,GAAG,CACjB,KAAuD,EACvD,GAA0C,EAC1C,EAAE;QACF,OAAO,oBAAC,cAAc,oBAAK,KAAK,IAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC1D,CAAC,CAAC;IACF,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC;IAErC,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,aAAkB,EAAE,EAAE;IACzE,IACE,aAAa,KAAK,SAAS;QAC3B,OAAO,cAAc,KAAK,WAAW;QACrC,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAC5B;QACA,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KAC/C;AACH,CAAC,CAAA;AAED,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC"}
|
package/umd/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { JSX } from '@public-ui/components';
|
|
3
|
+
export declare const KolAbbr: import("react").ForwardRefExoticComponent<JSX.KolAbbr & Omit<import("react").HTMLAttributes<HTMLKolAbbrElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolAbbrElement>>;
|
|
4
|
+
export declare const KolAccordion: import("react").ForwardRefExoticComponent<JSX.KolAccordion & Omit<import("react").HTMLAttributes<HTMLKolAccordionElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolAccordionElement>>;
|
|
5
|
+
export declare const KolAlert: import("react").ForwardRefExoticComponent<JSX.KolAlert & Omit<import("react").HTMLAttributes<HTMLKolAlertElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolAlertElement>>;
|
|
6
|
+
export declare const KolBadge: import("react").ForwardRefExoticComponent<JSX.KolBadge & Omit<import("react").HTMLAttributes<HTMLKolBadgeElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolBadgeElement>>;
|
|
7
|
+
export declare const KolBreadcrumb: import("react").ForwardRefExoticComponent<JSX.KolBreadcrumb & Omit<import("react").HTMLAttributes<HTMLKolBreadcrumbElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolBreadcrumbElement>>;
|
|
8
|
+
export declare const KolButton: import("react").ForwardRefExoticComponent<JSX.KolButton & Omit<import("react").HTMLAttributes<HTMLKolButtonElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolButtonElement>>;
|
|
9
|
+
export declare const KolButtonGroup: import("react").ForwardRefExoticComponent<JSX.KolButtonGroup & Omit<import("react").HTMLAttributes<HTMLKolButtonGroupElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolButtonGroupElement>>;
|
|
10
|
+
export declare const KolCard: import("react").ForwardRefExoticComponent<JSX.KolCard & Omit<import("react").HTMLAttributes<HTMLKolCardElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolCardElement>>;
|
|
11
|
+
export declare const KolDetails: import("react").ForwardRefExoticComponent<JSX.KolDetails & Omit<import("react").HTMLAttributes<HTMLKolDetailsElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolDetailsElement>>;
|
|
12
|
+
export declare const KolForm: import("react").ForwardRefExoticComponent<JSX.KolForm & Omit<import("react").HTMLAttributes<HTMLKolFormElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolFormElement>>;
|
|
13
|
+
export declare const KolHeading: import("react").ForwardRefExoticComponent<JSX.KolHeading & Omit<import("react").HTMLAttributes<HTMLKolHeadingElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolHeadingElement>>;
|
|
14
|
+
export declare const KolHeadingWc: import("react").ForwardRefExoticComponent<JSX.KolHeadingWc & Omit<import("react").HTMLAttributes<HTMLKolHeadingWcElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolHeadingWcElement>>;
|
|
15
|
+
export declare const KolIcon: import("react").ForwardRefExoticComponent<JSX.KolIcon & Omit<import("react").HTMLAttributes<HTMLKolIconElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolIconElement>>;
|
|
16
|
+
export declare const KolIconFontAwesome: import("react").ForwardRefExoticComponent<JSX.KolIconFontAwesome & Omit<import("react").HTMLAttributes<HTMLKolIconFontAwesomeElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolIconFontAwesomeElement>>;
|
|
17
|
+
export declare const KolIconIcofont: import("react").ForwardRefExoticComponent<JSX.KolIconIcofont & Omit<import("react").HTMLAttributes<HTMLKolIconIcofontElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolIconIcofontElement>>;
|
|
18
|
+
export declare const KolIndentedText: import("react").ForwardRefExoticComponent<JSX.KolIndentedText & Omit<import("react").HTMLAttributes<HTMLKolIndentedTextElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolIndentedTextElement>>;
|
|
19
|
+
export declare const KolInputAdapterLeanup: import("react").ForwardRefExoticComponent<JSX.KolInputAdapterLeanup & Omit<import("react").HTMLAttributes<HTMLKolInputAdapterLeanupElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputAdapterLeanupElement>>;
|
|
20
|
+
export declare const KolInputCheckbox: import("react").ForwardRefExoticComponent<JSX.KolInputCheckbox & Omit<import("react").HTMLAttributes<HTMLKolInputCheckboxElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputCheckboxElement>>;
|
|
21
|
+
export declare const KolInputColor: import("react").ForwardRefExoticComponent<JSX.KolInputColor & Omit<import("react").HTMLAttributes<HTMLKolInputColorElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputColorElement>>;
|
|
22
|
+
export declare const KolInputEmail: import("react").ForwardRefExoticComponent<JSX.KolInputEmail & Omit<import("react").HTMLAttributes<HTMLKolInputEmailElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputEmailElement>>;
|
|
23
|
+
export declare const KolInputFile: import("react").ForwardRefExoticComponent<JSX.KolInputFile & Omit<import("react").HTMLAttributes<HTMLKolInputFileElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputFileElement>>;
|
|
24
|
+
export declare const KolInputNumber: import("react").ForwardRefExoticComponent<JSX.KolInputNumber & Omit<import("react").HTMLAttributes<HTMLKolInputNumberElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputNumberElement>>;
|
|
25
|
+
export declare const KolInputPassword: import("react").ForwardRefExoticComponent<JSX.KolInputPassword & Omit<import("react").HTMLAttributes<HTMLKolInputPasswordElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputPasswordElement>>;
|
|
26
|
+
export declare const KolInputRadio: import("react").ForwardRefExoticComponent<JSX.KolInputRadio & Omit<import("react").HTMLAttributes<HTMLKolInputRadioElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputRadioElement>>;
|
|
27
|
+
export declare const KolInputRange: import("react").ForwardRefExoticComponent<JSX.KolInputRange & Omit<import("react").HTMLAttributes<HTMLKolInputRangeElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputRangeElement>>;
|
|
28
|
+
export declare const KolInputText: import("react").ForwardRefExoticComponent<JSX.KolInputText & Omit<import("react").HTMLAttributes<HTMLKolInputTextElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolInputTextElement>>;
|
|
29
|
+
export declare const KolKolibri: import("react").ForwardRefExoticComponent<JSX.KolKolibri & Omit<import("react").HTMLAttributes<HTMLKolKolibriElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolKolibriElement>>;
|
|
30
|
+
export declare const KolLink: import("react").ForwardRefExoticComponent<JSX.KolLink & Omit<import("react").HTMLAttributes<HTMLKolLinkElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolLinkElement>>;
|
|
31
|
+
export declare const KolLinkGroup: import("react").ForwardRefExoticComponent<JSX.KolLinkGroup & Omit<import("react").HTMLAttributes<HTMLKolLinkGroupElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolLinkGroupElement>>;
|
|
32
|
+
export declare const KolLogo: import("react").ForwardRefExoticComponent<JSX.KolLogo & Omit<import("react").HTMLAttributes<HTMLKolLogoElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolLogoElement>>;
|
|
33
|
+
export declare const KolModal: import("react").ForwardRefExoticComponent<JSX.KolModal & Omit<import("react").HTMLAttributes<HTMLKolModalElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolModalElement>>;
|
|
34
|
+
export declare const KolNav: import("react").ForwardRefExoticComponent<JSX.KolNav & Omit<import("react").HTMLAttributes<HTMLKolNavElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolNavElement>>;
|
|
35
|
+
export declare const KolPagination: import("react").ForwardRefExoticComponent<JSX.KolPagination & Omit<import("react").HTMLAttributes<HTMLKolPaginationElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolPaginationElement>>;
|
|
36
|
+
export declare const KolProgress: import("react").ForwardRefExoticComponent<JSX.KolProgress & Omit<import("react").HTMLAttributes<HTMLKolProgressElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolProgressElement>>;
|
|
37
|
+
export declare const KolSelect: import("react").ForwardRefExoticComponent<JSX.KolSelect & Omit<import("react").HTMLAttributes<HTMLKolSelectElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolSelectElement>>;
|
|
38
|
+
export declare const KolSkipNav: import("react").ForwardRefExoticComponent<JSX.KolSkipNav & Omit<import("react").HTMLAttributes<HTMLKolSkipNavElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolSkipNavElement>>;
|
|
39
|
+
export declare const KolSpin: import("react").ForwardRefExoticComponent<JSX.KolSpin & Omit<import("react").HTMLAttributes<HTMLKolSpinElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolSpinElement>>;
|
|
40
|
+
export declare const KolSymbol: import("react").ForwardRefExoticComponent<JSX.KolSymbol & Omit<import("react").HTMLAttributes<HTMLKolSymbolElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolSymbolElement>>;
|
|
41
|
+
export declare const KolTable: import("react").ForwardRefExoticComponent<JSX.KolTable & Omit<import("react").HTMLAttributes<HTMLKolTableElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolTableElement>>;
|
|
42
|
+
export declare const KolTabs: import("react").ForwardRefExoticComponent<JSX.KolTabs & Omit<import("react").HTMLAttributes<HTMLKolTabsElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolTabsElement>>;
|
|
43
|
+
export declare const KolTextarea: import("react").ForwardRefExoticComponent<JSX.KolTextarea & Omit<import("react").HTMLAttributes<HTMLKolTextareaElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolTextareaElement>>;
|
|
44
|
+
export declare const KolToast: import("react").ForwardRefExoticComponent<JSX.KolToast & Omit<import("react").HTMLAttributes<HTMLKolToastElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolToastElement>>;
|
|
45
|
+
export declare const KolTooltip: import("react").ForwardRefExoticComponent<JSX.KolTooltip & Omit<import("react").HTMLAttributes<HTMLKolTooltipElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolTooltipElement>>;
|
|
46
|
+
export declare const KolVersion: import("react").ForwardRefExoticComponent<JSX.KolVersion & Omit<import("react").HTMLAttributes<HTMLKolVersionElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLKolVersionElement>>;
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./react-component-lib"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.KolVersion = exports.KolTooltip = exports.KolToast = exports.KolTextarea = exports.KolTabs = exports.KolTable = exports.KolSymbol = exports.KolSpin = exports.KolSkipNav = exports.KolSelect = exports.KolProgress = exports.KolPagination = exports.KolNav = exports.KolModal = exports.KolLogo = exports.KolLinkGroup = exports.KolLink = exports.KolKolibri = exports.KolInputText = exports.KolInputRange = exports.KolInputRadio = exports.KolInputPassword = exports.KolInputNumber = exports.KolInputFile = exports.KolInputEmail = exports.KolInputColor = exports.KolInputCheckbox = exports.KolInputAdapterLeanup = exports.KolIndentedText = exports.KolIconIcofont = exports.KolIconFontAwesome = exports.KolIcon = exports.KolHeadingWc = exports.KolHeading = exports.KolForm = exports.KolDetails = exports.KolCard = exports.KolButtonGroup = exports.KolButton = exports.KolBreadcrumb = exports.KolBadge = exports.KolAlert = exports.KolAccordion = exports.KolAbbr = void 0;
|
|
13
|
+
const react_component_lib_1 = require("./react-component-lib");
|
|
14
|
+
exports.KolAbbr = (0, react_component_lib_1.createReactComponent)('kol-abbr');
|
|
15
|
+
exports.KolAccordion = (0, react_component_lib_1.createReactComponent)('kol-accordion');
|
|
16
|
+
exports.KolAlert = (0, react_component_lib_1.createReactComponent)('kol-alert');
|
|
17
|
+
exports.KolBadge = (0, react_component_lib_1.createReactComponent)('kol-badge');
|
|
18
|
+
exports.KolBreadcrumb = (0, react_component_lib_1.createReactComponent)('kol-breadcrumb');
|
|
19
|
+
exports.KolButton = (0, react_component_lib_1.createReactComponent)('kol-button');
|
|
20
|
+
exports.KolButtonGroup = (0, react_component_lib_1.createReactComponent)('kol-button-group');
|
|
21
|
+
exports.KolCard = (0, react_component_lib_1.createReactComponent)('kol-card');
|
|
22
|
+
exports.KolDetails = (0, react_component_lib_1.createReactComponent)('kol-details');
|
|
23
|
+
exports.KolForm = (0, react_component_lib_1.createReactComponent)('kol-form');
|
|
24
|
+
exports.KolHeading = (0, react_component_lib_1.createReactComponent)('kol-heading');
|
|
25
|
+
exports.KolHeadingWc = (0, react_component_lib_1.createReactComponent)('kol-heading-wc');
|
|
26
|
+
exports.KolIcon = (0, react_component_lib_1.createReactComponent)('kol-icon');
|
|
27
|
+
exports.KolIconFontAwesome = (0, react_component_lib_1.createReactComponent)('kol-icon-font-awesome');
|
|
28
|
+
exports.KolIconIcofont = (0, react_component_lib_1.createReactComponent)('kol-icon-icofont');
|
|
29
|
+
exports.KolIndentedText = (0, react_component_lib_1.createReactComponent)('kol-indented-text');
|
|
30
|
+
exports.KolInputAdapterLeanup = (0, react_component_lib_1.createReactComponent)('kol-input-adapter-leanup');
|
|
31
|
+
exports.KolInputCheckbox = (0, react_component_lib_1.createReactComponent)('kol-input-checkbox');
|
|
32
|
+
exports.KolInputColor = (0, react_component_lib_1.createReactComponent)('kol-input-color');
|
|
33
|
+
exports.KolInputEmail = (0, react_component_lib_1.createReactComponent)('kol-input-email');
|
|
34
|
+
exports.KolInputFile = (0, react_component_lib_1.createReactComponent)('kol-input-file');
|
|
35
|
+
exports.KolInputNumber = (0, react_component_lib_1.createReactComponent)('kol-input-number');
|
|
36
|
+
exports.KolInputPassword = (0, react_component_lib_1.createReactComponent)('kol-input-password');
|
|
37
|
+
exports.KolInputRadio = (0, react_component_lib_1.createReactComponent)('kol-input-radio');
|
|
38
|
+
exports.KolInputRange = (0, react_component_lib_1.createReactComponent)('kol-input-range');
|
|
39
|
+
exports.KolInputText = (0, react_component_lib_1.createReactComponent)('kol-input-text');
|
|
40
|
+
exports.KolKolibri = (0, react_component_lib_1.createReactComponent)('kol-kolibri');
|
|
41
|
+
exports.KolLink = (0, react_component_lib_1.createReactComponent)('kol-link');
|
|
42
|
+
exports.KolLinkGroup = (0, react_component_lib_1.createReactComponent)('kol-link-group');
|
|
43
|
+
exports.KolLogo = (0, react_component_lib_1.createReactComponent)('kol-logo');
|
|
44
|
+
exports.KolModal = (0, react_component_lib_1.createReactComponent)('kol-modal');
|
|
45
|
+
exports.KolNav = (0, react_component_lib_1.createReactComponent)('kol-nav');
|
|
46
|
+
exports.KolPagination = (0, react_component_lib_1.createReactComponent)('kol-pagination');
|
|
47
|
+
exports.KolProgress = (0, react_component_lib_1.createReactComponent)('kol-progress');
|
|
48
|
+
exports.KolSelect = (0, react_component_lib_1.createReactComponent)('kol-select');
|
|
49
|
+
exports.KolSkipNav = (0, react_component_lib_1.createReactComponent)('kol-skip-nav');
|
|
50
|
+
exports.KolSpin = (0, react_component_lib_1.createReactComponent)('kol-spin');
|
|
51
|
+
exports.KolSymbol = (0, react_component_lib_1.createReactComponent)('kol-symbol');
|
|
52
|
+
exports.KolTable = (0, react_component_lib_1.createReactComponent)('kol-table');
|
|
53
|
+
exports.KolTabs = (0, react_component_lib_1.createReactComponent)('kol-tabs');
|
|
54
|
+
exports.KolTextarea = (0, react_component_lib_1.createReactComponent)('kol-textarea');
|
|
55
|
+
exports.KolToast = (0, react_component_lib_1.createReactComponent)('kol-toast');
|
|
56
|
+
exports.KolTooltip = (0, react_component_lib_1.createReactComponent)('kol-tooltip');
|
|
57
|
+
exports.KolVersion = (0, react_component_lib_1.createReactComponent)('kol-version');
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
package/umd/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;IAGA,+DAA6D;IAMhD,QAAA,OAAO,GAAgB,IAAA,0CAAoB,EAAkC,UAAU,CAAC,CAAC;IACzF,QAAA,YAAY,GAAgB,IAAA,0CAAoB,EAA4C,eAAe,CAAC,CAAC;IAC7G,QAAA,QAAQ,GAAgB,IAAA,0CAAoB,EAAoC,WAAW,CAAC,CAAC;IAC7F,QAAA,QAAQ,GAAgB,IAAA,0CAAoB,EAAoC,WAAW,CAAC,CAAC;IAC7F,QAAA,aAAa,GAAgB,IAAA,0CAAoB,EAA8C,gBAAgB,CAAC,CAAC;IACjH,QAAA,SAAS,GAAgB,IAAA,0CAAoB,EAAsC,YAAY,CAAC,CAAC;IACjG,QAAA,cAAc,GAAgB,IAAA,0CAAoB,EAAgD,kBAAkB,CAAC,CAAC;IACtH,QAAA,OAAO,GAAgB,IAAA,0CAAoB,EAAkC,UAAU,CAAC,CAAC;IACzF,QAAA,UAAU,GAAgB,IAAA,0CAAoB,EAAwC,aAAa,CAAC,CAAC;IACrG,QAAA,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|
5
|
+
interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<ElementType> {
|
|
6
|
+
forwardedRef: React.RefObject<ElementType>;
|
|
7
|
+
ref?: React.Ref<any>;
|
|
8
|
+
}
|
|
9
|
+
export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType> | undefined, manipulatePropsFunction?: ((originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes) | undefined, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
25
|
+
var t = {};
|
|
26
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
27
|
+
t[p] = s[p];
|
|
28
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
29
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
30
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
31
|
+
t[p[i]] = s[p[i]];
|
|
32
|
+
}
|
|
33
|
+
return t;
|
|
34
|
+
};
|
|
35
|
+
(function (factory) {
|
|
36
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
37
|
+
var v = factory(require, exports);
|
|
38
|
+
if (v !== undefined) module.exports = v;
|
|
39
|
+
}
|
|
40
|
+
else if (typeof define === "function" && define.amd) {
|
|
41
|
+
define(["require", "exports", "react", "./utils"], factory);
|
|
42
|
+
}
|
|
43
|
+
})(function (require, exports) {
|
|
44
|
+
"use strict";
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.createReactComponent = void 0;
|
|
47
|
+
const react_1 = __importStar(require("react"));
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
|
+
const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
50
|
+
if (defineCustomElement !== undefined) {
|
|
51
|
+
defineCustomElement();
|
|
52
|
+
}
|
|
53
|
+
const displayName = (0, utils_1.dashToPascalCase)(tagName);
|
|
54
|
+
const ReactComponent = class extends react_1.default.Component {
|
|
55
|
+
constructor(props) {
|
|
56
|
+
super(props);
|
|
57
|
+
this.setComponentElRef = (element) => {
|
|
58
|
+
this.componentEl = element;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
componentDidMount() {
|
|
62
|
+
this.componentDidUpdate(this.props);
|
|
63
|
+
}
|
|
64
|
+
componentDidUpdate(prevProps) {
|
|
65
|
+
(0, utils_1.attachProps)(this.componentEl, this.props, prevProps);
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
|
|
69
|
+
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
70
|
+
const value = cProps[name];
|
|
71
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
72
|
+
const eventName = name.substring(2).toLowerCase();
|
|
73
|
+
if (typeof document !== 'undefined' && (0, utils_1.isCoveredByReact)(eventName)) {
|
|
74
|
+
acc[name] = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const type = typeof value;
|
|
79
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
80
|
+
acc[(0, utils_1.camelToDashCase)(name)] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return acc;
|
|
84
|
+
}, {});
|
|
85
|
+
if (manipulatePropsFunction) {
|
|
86
|
+
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
87
|
+
}
|
|
88
|
+
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: (0, utils_1.mergeRefs)(forwardedRef, this.setComponentElRef), style });
|
|
89
|
+
return (0, react_1.createElement)(tagName, newProps, children);
|
|
90
|
+
}
|
|
91
|
+
static get displayName() {
|
|
92
|
+
return displayName;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
if (ReactComponentContext) {
|
|
96
|
+
ReactComponent.contextType = ReactComponentContext;
|
|
97
|
+
}
|
|
98
|
+
return (0, utils_1.createForwardRef)(ReactComponent, displayName);
|
|
99
|
+
};
|
|
100
|
+
exports.createReactComponent = createReactComponent;
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=createComponent.js.map
|
|
@@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
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OverlayEventDetail } from './interfaces';
|
|
3
|
+
import { StencilReactForwardedRef } from './utils';
|
|
4
|
+
interface OverlayElement extends HTMLElement {
|
|
5
|
+
present: () => Promise<void>;
|
|
6
|
+
dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export interface ReactOverlayProps {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
onDidDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
12
|
+
onDidPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
13
|
+
onWillDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
14
|
+
onWillPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const createOverlayComponent: <OverlayComponent extends object, OverlayType extends OverlayElement>(tagName: string, controller: {
|
|
17
|
+
create: (options: any) => Promise<OverlayType>;
|
|
18
|
+
}, customElement?: any) => React.ForwardRefExoticComponent<React.PropsWithoutRef<OverlayComponent & ReactOverlayProps & {
|
|
19
|
+
forwardedRef?: StencilReactForwardedRef<OverlayType> | undefined;
|
|
20
|
+
}> & React.RefAttributes<OverlayType>>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
(function (factory) {
|
|
25
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
26
|
+
var v = factory(require, exports);
|
|
27
|
+
if (v !== undefined) module.exports = v;
|
|
28
|
+
}
|
|
29
|
+
else if (typeof define === "function" && define.amd) {
|
|
30
|
+
define(["require", "exports", "react", "react-dom", "./utils"], factory);
|
|
31
|
+
}
|
|
32
|
+
})(function (require, exports) {
|
|
33
|
+
"use strict";
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.createOverlayComponent = void 0;
|
|
36
|
+
const react_1 = __importDefault(require("react"));
|
|
37
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
38
|
+
const utils_1 = require("./utils");
|
|
39
|
+
const createOverlayComponent = (tagName, controller, customElement) => {
|
|
40
|
+
(0, utils_1.defineCustomElement)(tagName, customElement);
|
|
41
|
+
const displayName = (0, utils_1.dashToPascalCase)(tagName);
|
|
42
|
+
const didDismissEventName = `on${displayName}DidDismiss`;
|
|
43
|
+
const didPresentEventName = `on${displayName}DidPresent`;
|
|
44
|
+
const willDismissEventName = `on${displayName}WillDismiss`;
|
|
45
|
+
const willPresentEventName = `on${displayName}WillPresent`;
|
|
46
|
+
let isDismissing = false;
|
|
47
|
+
class Overlay extends react_1.default.Component {
|
|
48
|
+
constructor(props) {
|
|
49
|
+
super(props);
|
|
50
|
+
if (typeof document !== 'undefined') {
|
|
51
|
+
this.el = document.createElement('div');
|
|
52
|
+
}
|
|
53
|
+
this.handleDismiss = this.handleDismiss.bind(this);
|
|
54
|
+
}
|
|
55
|
+
static get displayName() {
|
|
56
|
+
return displayName;
|
|
57
|
+
}
|
|
58
|
+
componentDidMount() {
|
|
59
|
+
if (this.props.isOpen) {
|
|
60
|
+
this.present();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
componentWillUnmount() {
|
|
64
|
+
if (this.overlay) {
|
|
65
|
+
this.overlay.dismiss();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
handleDismiss(event) {
|
|
69
|
+
if (this.props.onDidDismiss) {
|
|
70
|
+
this.props.onDidDismiss(event);
|
|
71
|
+
}
|
|
72
|
+
(0, utils_1.setRef)(this.props.forwardedRef, null);
|
|
73
|
+
}
|
|
74
|
+
shouldComponentUpdate(nextProps) {
|
|
75
|
+
if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
|
|
76
|
+
isDismissing = true;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
componentDidUpdate(prevProps) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
if (this.overlay) {
|
|
83
|
+
(0, utils_1.attachProps)(this.overlay, this.props, prevProps);
|
|
84
|
+
}
|
|
85
|
+
if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
|
|
86
|
+
this.present(prevProps);
|
|
87
|
+
}
|
|
88
|
+
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
|
|
89
|
+
yield this.overlay.dismiss();
|
|
90
|
+
isDismissing = false;
|
|
91
|
+
this.forceUpdate();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
present(prevProps) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const _a = this.props, { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent } = _a, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
|
|
98
|
+
const elementProps = Object.assign(Object.assign({}, cProps), { ref: this.props.forwardedRef, [didDismissEventName]: this.handleDismiss, [didPresentEventName]: (e) => this.props.onDidPresent && this.props.onDidPresent(e), [willDismissEventName]: (e) => this.props.onWillDismiss && this.props.onWillDismiss(e), [willPresentEventName]: (e) => this.props.onWillPresent && this.props.onWillPresent(e) });
|
|
99
|
+
this.overlay = yield controller.create(Object.assign(Object.assign({}, elementProps), { component: this.el, componentProps: {} }));
|
|
100
|
+
(0, utils_1.setRef)(this.props.forwardedRef, this.overlay);
|
|
101
|
+
(0, utils_1.attachProps)(this.overlay, elementProps, prevProps);
|
|
102
|
+
yield this.overlay.present();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
render() {
|
|
106
|
+
return react_dom_1.default.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return react_1.default.forwardRef((props, ref) => {
|
|
110
|
+
return react_1.default.createElement(Overlay, Object.assign({}, props, { forwardedRef: ref }));
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
exports.createOverlayComponent = createOverlayComponent;
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=createOverlayComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOverlayComponent.js","sourceRoot":"","sources":["../../src/react-component-lib/createOverlayComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,kDAA0B;IAC1B,0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,IAAI,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAvIW,QAAA,sBAAsB,0BAuIjC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./createComponent", "./createOverlayComponent"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createOverlayComponent = exports.createReactComponent = void 0;
|
|
13
|
+
var createComponent_1 = require("./createComponent");
|
|
14
|
+
Object.defineProperty(exports, "createReactComponent", { enumerable: true, get: function () { return createComponent_1.createReactComponent; } });
|
|
15
|
+
var createOverlayComponent_1 = require("./createOverlayComponent");
|
|
16
|
+
Object.defineProperty(exports, "createOverlayComponent", { enumerable: true, get: function () { return createOverlayComponent_1.createOverlayComponent; } });
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-component-lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,qDAAyD;IAAhD,uHAAA,oBAAoB,OAAA;IAC7B,mEAAkE;IAAzD,gIAAA,sBAAsB,OAAA"}
|