@onepercentio/one-ui 0.20.5 → 0.21.0
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/dist/assets/styles/variables.scss +1 -0
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js +4 -2
- package/dist/components/AdaptiveContainer/AdaptiveContainer.module.scss +3 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.d.ts +1 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js +8 -6
- package/dist/components/EmailInput/EmailInput.d.ts +1 -1
- package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/Select/Select.module.scss +8 -5
- package/dist/components/Tabs/Tabs.d.ts +6 -1
- package/dist/components/Tabs/Tabs.js +25 -6
- package/dist/components/Tabs/Tabs.module.scss +20 -2
- package/dist/hooks/useHero.d.ts +1 -0
- package/dist/hooks/useHero.js +52 -3
- package/dist/hooks/useHero.module.scss +7 -0
- package/dist/types.d.ts +11 -4
- package/package.json +2 -1
- package/src/types.ts +155 -41
|
@@ -10,6 +10,7 @@ $success: var(--success, lightgreen);
|
|
|
10
10
|
$successDark: var(--success-dark, green);
|
|
11
11
|
$mainBackgroundColor: var(--bg-color, white);
|
|
12
12
|
$primaryColor: var(--primary-color, var(--digital-blue));
|
|
13
|
+
$elevation: var(--card-elevation, 0px 4px 10px rgba(0, 0, 0, 0.1));
|
|
13
14
|
|
|
14
15
|
//FONTS
|
|
15
16
|
$mainFontFamily: var(--main-font, Roboto);
|
|
@@ -58,17 +58,19 @@ function AdaptiveContainer(_ref) {
|
|
|
58
58
|
if (direction === "h") {
|
|
59
59
|
const contentWidth = lastChild.clientWidth;
|
|
60
60
|
const targetWidth = "".concat(contentWidth, "px");
|
|
61
|
+
const prevWidth = sectionDiv.style.width;
|
|
61
62
|
sectionDiv.style.width = targetWidth;
|
|
62
63
|
const func = resetFactory("width", contentWidth);
|
|
63
|
-
if (targetWidth ===
|
|
64
|
+
if (targetWidth === prevWidth) func({
|
|
64
65
|
propertyName: "width"
|
|
65
66
|
});else sectionDiv.addEventListener("transitionend", func);
|
|
66
67
|
} else {
|
|
67
68
|
const contentHeight = lastChild.scrollHeight;
|
|
68
69
|
const targetHeight = "".concat(contentHeight, "px");
|
|
70
|
+
const prevHeight = sectionDiv.style.height;
|
|
69
71
|
sectionDiv.style.height = targetHeight;
|
|
70
72
|
const func = resetFactory("height", contentHeight);
|
|
71
|
-
if (targetHeight ===
|
|
73
|
+
if (targetHeight === prevHeight) func({
|
|
72
74
|
propertyName: "height"
|
|
73
75
|
});else sectionDiv.addEventListener("transitionend", func);
|
|
74
76
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
.resetSection {
|
|
2
2
|
min-height: 0px;
|
|
3
|
-
transition: width var(--adaptive-container-transition-time, 400ms)
|
|
3
|
+
transition: width var(--adaptive-container-transition-time, 400ms) linear,
|
|
4
|
+
height var(--adaptive-container-transition-time, 400ms) linear;
|
|
4
5
|
transition-timing-function: linear;
|
|
5
6
|
overflow: hidden;
|
|
7
|
+
align-items: flex-start;
|
|
6
8
|
&.h {
|
|
7
9
|
> * {
|
|
8
10
|
min-width: auto !important;
|
|
@@ -8,7 +8,7 @@ export declare function AnimatedEntranceItem({ children, noEntranceAnimation, on
|
|
|
8
8
|
noEntranceAnimation: boolean;
|
|
9
9
|
onRemoveChildren: (key: Key) => void;
|
|
10
10
|
entranceType: EntranceType;
|
|
11
|
-
}): JSX.Element
|
|
11
|
+
}): JSX.Element;
|
|
12
12
|
/**
|
|
13
13
|
* Animates the entrance and exit of a component
|
|
14
14
|
**/
|
|
@@ -100,13 +100,13 @@ function AnimatedEntranceItem(_ref) {
|
|
|
100
100
|
clearTimeout(x);
|
|
101
101
|
};
|
|
102
102
|
}, [_typeof(screen) === "object" ? screen === null || screen === void 0 ? void 0 : screen.key : screen]);
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
}, [
|
|
106
|
-
return
|
|
103
|
+
const firstRenderClass = (0, _react.useMemo)(function () {
|
|
104
|
+
return noEntranceAnimation ? "" : _AnimatedEntranceModule.default.maxHeight;
|
|
105
|
+
}, [screen === null]);
|
|
106
|
+
return /*#__PURE__*/_react.default.createElement(_UncontrolledTransition.default, {
|
|
107
107
|
ref: uncontRef,
|
|
108
108
|
transitionType: _Transition.TransitionAnimationTypes.CUSTOM,
|
|
109
|
-
className: "".concat(_AnimatedEntranceModule.default.resetHeight, " ").concat(
|
|
109
|
+
className: "".concat(_AnimatedEntranceModule.default.resetHeight, " ").concat(firstRenderClass),
|
|
110
110
|
lockTransitionWidth: true,
|
|
111
111
|
key: String(children.key).replace("-nullated", ""),
|
|
112
112
|
onDiscardStep: function onDiscardStep(k) {
|
|
@@ -116,7 +116,9 @@ function AnimatedEntranceItem(_ref) {
|
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
config: CONFIGS_BY_ENTRANCE_TYPE[entranceType]
|
|
119
|
-
},
|
|
119
|
+
}, screen === null ? /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
120
|
+
key: "null"
|
|
121
|
+
}) : typeof screen === "string" ? children : screen);
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/**
|
|
@@ -14,7 +14,7 @@ declare const _default: React.ForwardRefExoticComponent<Omit<Omit<{
|
|
|
14
14
|
Icon?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
15
15
|
onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement> | undefined;
|
|
16
16
|
containerProps?: Omit<React.HTMLProps<HTMLDivElement>, "ref"> | undefined;
|
|
17
|
-
} & Omit<React.HTMLProps<HTMLInputElement | HTMLTextAreaElement>, "ref" | "onChange"> & React.RefAttributes<any>, "
|
|
17
|
+
} & Omit<React.HTMLProps<HTMLInputElement | HTMLTextAreaElement>, "ref" | "onChange"> & React.RefAttributes<any>, "onChange" | "value"> & {
|
|
18
18
|
onChange: (email: string, isValid: boolean) => void;
|
|
19
19
|
value: string;
|
|
20
20
|
messages: {
|
|
@@ -37,7 +37,7 @@ declare const _default: React.ForwardRefExoticComponent<(({
|
|
|
37
37
|
Icon?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
38
38
|
onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement> | undefined;
|
|
39
39
|
containerProps?: Omit<React.HTMLProps<HTMLDivElement>, "ref"> | undefined;
|
|
40
|
-
} & Omit<React.HTMLProps<HTMLInputElement | HTMLTextAreaElement>, "ref" | "onChange"> & React.RefAttributes<any>, "
|
|
40
|
+
} & Omit<React.HTMLProps<HTMLInputElement | HTMLTextAreaElement>, "ref" | "onChange"> & React.RefAttributes<any>, "ref" | "onChange" | "value">) & React.RefAttributes<{
|
|
41
41
|
validatePassword: (pass: string) => boolean;
|
|
42
42
|
}>>;
|
|
43
43
|
export default _default;
|
|
@@ -19,12 +19,15 @@
|
|
|
19
19
|
.empty {
|
|
20
20
|
opacity: 0.3;
|
|
21
21
|
}
|
|
22
|
-
.input
|
|
23
|
-
transition: opacity $fast;
|
|
22
|
+
.input {
|
|
24
23
|
cursor: pointer;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
input {
|
|
25
|
+
transition: opacity $fast;
|
|
26
|
+
padding-right: 30px;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
text-overflow: ellipsis;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
.indicator {
|
|
30
33
|
display: flex;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
+
export declare enum TabType {
|
|
3
|
+
FULL = 0,
|
|
4
|
+
UNDERLINE = 1
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Show tabs for toggling between options
|
|
4
8
|
**/
|
|
5
|
-
export default function Tabs<O extends string>({ options, selected, onSelect, itemClassName, className, }: {
|
|
9
|
+
export default function Tabs<O extends string | number>({ options, selected, onSelect, itemClassName, className, type, }: {
|
|
6
10
|
options: Readonly<{
|
|
7
11
|
id: O;
|
|
8
12
|
label: string | ReactElement;
|
|
@@ -11,4 +15,5 @@ export default function Tabs<O extends string>({ options, selected, onSelect, it
|
|
|
11
15
|
onSelect: (option: O) => void;
|
|
12
16
|
itemClassName?: string;
|
|
13
17
|
className?: string;
|
|
18
|
+
type?: TabType;
|
|
14
19
|
}): JSX.Element;
|
|
@@ -4,15 +4,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.TabType = void 0;
|
|
7
8
|
exports.default = Tabs;
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _TabsModule = _interopRequireDefault(require("./Tabs.module.scss"));
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
let TabType = /*#__PURE__*/function (TabType) {
|
|
15
|
+
TabType[TabType["FULL"] = 0] = "FULL";
|
|
16
|
+
TabType[TabType["UNDERLINE"] = 1] = "UNDERLINE";
|
|
17
|
+
return TabType;
|
|
18
|
+
}({});
|
|
13
19
|
/**
|
|
14
20
|
* Show tabs for toggling between options
|
|
15
21
|
**/
|
|
22
|
+
exports.TabType = TabType;
|
|
16
23
|
function Tabs(_ref) {
|
|
17
24
|
let options = _ref.options,
|
|
18
25
|
selected = _ref.selected,
|
|
@@ -20,17 +27,29 @@ function Tabs(_ref) {
|
|
|
20
27
|
_ref$itemClassName = _ref.itemClassName,
|
|
21
28
|
itemClassName = _ref$itemClassName === void 0 ? "" : _ref$itemClassName,
|
|
22
29
|
_ref$className = _ref.className,
|
|
23
|
-
className = _ref$className === void 0 ? "" : _ref$className
|
|
30
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
31
|
+
_ref$type = _ref.type,
|
|
32
|
+
type = _ref$type === void 0 ? TabType.UNDERLINE : _ref$type;
|
|
24
33
|
const selectedRef = (0, _react.useRef)(null);
|
|
25
34
|
const guideRef = (0, _react.useRef)(null);
|
|
26
35
|
(0, _react.useEffect)(function () {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
const guideStyle = guideRef.current.style;
|
|
37
|
+
const currEl = selectedRef.current;
|
|
38
|
+
guideStyle["opacity"] = currEl ? "1" : guideStyle["opacity"];
|
|
39
|
+
guideStyle["width"] = currEl ? currEl.clientWidth + "px" : "0px";
|
|
40
|
+
guideStyle["left"] = currEl ? currEl.offsetLeft + "px" : guideStyle["left"] || "initial";
|
|
41
|
+
if (type === TabType.FULL) {
|
|
42
|
+
guideStyle["height"] = currEl ? currEl.clientHeight + "px" : "";
|
|
43
|
+
guideStyle["top"] = currEl ? currEl.offsetTop + "px" : guideStyle["top"] || "initial";
|
|
44
|
+
} else {
|
|
45
|
+
guideStyle["top"] = currEl ? currEl.offsetTop + currEl.clientHeight + "px" : guideStyle["top"] || "initial";
|
|
46
|
+
}
|
|
31
47
|
}, [selected]);
|
|
48
|
+
(0, _react.useEffect)(function () {
|
|
49
|
+
guideRef.current.classList.add(_TabsModule.default.enableTransition);
|
|
50
|
+
}, []);
|
|
32
51
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
-
className: "".concat(_TabsModule.default.container, " ").concat(className)
|
|
52
|
+
className: "".concat(_TabsModule.default.container, " ").concat(className, " ").concat(_TabsModule.default[TabType[type]])
|
|
34
53
|
}, options.map(function (o) {
|
|
35
54
|
return /*#__PURE__*/_react.default.createElement("p", {
|
|
36
55
|
ref: selected === o.id ? selectedRef : undefined,
|
|
@@ -11,11 +11,29 @@
|
|
|
11
11
|
font-weight: bold;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
&.FULL {
|
|
15
|
+
p {
|
|
16
|
+
transition: color 250ms linear;
|
|
17
|
+
padding: 16px 40px;
|
|
18
|
+
z-index: 1;
|
|
19
|
+
margin: 0px;
|
|
20
|
+
|
|
21
|
+
&.selected {
|
|
22
|
+
color: var(--tab-selected-color);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
.guide {
|
|
26
|
+
box-shadow: $elevation;
|
|
27
|
+
border-radius: 24px / 50%;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
}
|
|
15
31
|
|
|
16
32
|
.guide {
|
|
17
33
|
height: 0.1em;
|
|
18
|
-
background-color: $digitalBlue;
|
|
34
|
+
background-color: var(--tab-guide-color, $digitalBlue);
|
|
19
35
|
position: absolute;
|
|
20
|
-
|
|
36
|
+
&.enableTransition {
|
|
37
|
+
transition: left $fast, width $fast, top $fast, height $fast;
|
|
38
|
+
}
|
|
21
39
|
}
|
package/dist/hooks/useHero.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export default function useHero(id: string, options?: Partial<{
|
|
|
56
56
|
heroRef: React.RefObject<HTMLDivElement>;
|
|
57
57
|
getHerosOnScreen: () => HTMLDivElement[];
|
|
58
58
|
trigger: () => void;
|
|
59
|
+
heroComponentRef: (componentId: string) => (elRef: HTMLDivElement | null) => void;
|
|
59
60
|
};
|
|
60
61
|
declare type EVENTS_INTERFACE = Parameters<typeof useHero>[2];
|
|
61
62
|
declare type TRANSITION_TYPES = "ACCELERATION";
|
package/dist/hooks/useHero.js
CHANGED
|
@@ -29,6 +29,42 @@ const ID = function ID(id) {
|
|
|
29
29
|
return "".concat(id, "-hero");
|
|
30
30
|
};
|
|
31
31
|
const viewport = window.visualViewport;
|
|
32
|
+
const DATA_TAG_HERO_COMPONENT = "data-hero-component";
|
|
33
|
+
function triggerDynamicComponents(clone, componentsThatWillAppear) {
|
|
34
|
+
const idsThatWillAppear = componentsThatWillAppear.map(function (a) {
|
|
35
|
+
return a.getAttribute(DATA_TAG_HERO_COMPONENT);
|
|
36
|
+
});
|
|
37
|
+
const preexistingComponents = Array.from(clone.querySelectorAll("[".concat(DATA_TAG_HERO_COMPONENT, "]")));
|
|
38
|
+
const removedElements = preexistingComponents.filter(function (el) {
|
|
39
|
+
return !idsThatWillAppear.includes(el.getAttribute(DATA_TAG_HERO_COMPONENT));
|
|
40
|
+
});
|
|
41
|
+
for (let elementThatIsBeingRemoved of removedElements) {
|
|
42
|
+
elementThatIsBeingRemoved.style.height = "".concat(elementThatIsBeingRemoved.clientHeight, "px");
|
|
43
|
+
}
|
|
44
|
+
setTimeout(function () {
|
|
45
|
+
for (let elementThatIsBeingRemoved of removedElements) {
|
|
46
|
+
elementThatIsBeingRemoved.style.height = "0px";
|
|
47
|
+
elementThatIsBeingRemoved.style.opacity = "0";
|
|
48
|
+
}
|
|
49
|
+
}, 0);
|
|
50
|
+
for (let componentThatWillAppear of componentsThatWillAppear) {
|
|
51
|
+
const alreadyInjectedElement = !!clone.querySelector("[".concat(DATA_TAG_HERO_COMPONENT, "=\"").concat(componentThatWillAppear.getAttribute(DATA_TAG_HERO_COMPONENT), "\"]"));
|
|
52
|
+
if (!alreadyInjectedElement) {
|
|
53
|
+
const targetElementClone = componentThatWillAppear.cloneNode(true);
|
|
54
|
+
targetElementClone.style.height = "0px";
|
|
55
|
+
const shouldBeInsrtedAtIndex = Array.from(componentThatWillAppear.parentElement.children).indexOf(componentThatWillAppear);
|
|
56
|
+
const remainingIndexes = Array.from(clone.children).map(function (el, i) {
|
|
57
|
+
return removedElements.includes(el) ? undefined : i;
|
|
58
|
+
}).filter(function (e) {
|
|
59
|
+
return e !== undefined;
|
|
60
|
+
});
|
|
61
|
+
if (shouldBeInsrtedAtIndex === remainingIndexes.length) clone.append(targetElementClone);else clone.insertBefore(targetElementClone, clone.childNodes.item(remainingIndexes[shouldBeInsrtedAtIndex]));
|
|
62
|
+
setTimeout(function () {
|
|
63
|
+
targetElementClone.style.height = "".concat(componentThatWillAppear.clientHeight, "px");
|
|
64
|
+
}, 0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
32
68
|
|
|
33
69
|
/**
|
|
34
70
|
* This hook implements the logic for a hero animation between 2 elements
|
|
@@ -132,13 +168,18 @@ function useHero(id) {
|
|
|
132
168
|
const el = heroRef.current;
|
|
133
169
|
const cleanup = function cleanup() {
|
|
134
170
|
if (events.onHeroEnd) events.onHeroEnd();
|
|
135
|
-
clone.remove();
|
|
136
171
|
if (el) {
|
|
137
172
|
if (repeatable) el.setAttribute(dataProperty, id);
|
|
138
173
|
el.style.visibility = "";
|
|
139
174
|
}
|
|
175
|
+
setTimeout(function () {
|
|
176
|
+
clone.remove();
|
|
177
|
+
}, 0);
|
|
140
178
|
};
|
|
141
|
-
if (events.onHeroStart)
|
|
179
|
+
if (events.onHeroStart) {
|
|
180
|
+
events.onHeroStart(clone, otherElement, heroRef.current);
|
|
181
|
+
}
|
|
182
|
+
triggerDynamicComponents(clone, Array.from(heroRef.current.querySelectorAll("[".concat(DATA_TAG_HERO_COMPONENT, "]"))));
|
|
142
183
|
if (!el) {
|
|
143
184
|
cleanup();
|
|
144
185
|
return;
|
|
@@ -180,7 +221,15 @@ function useHero(id) {
|
|
|
180
221
|
return {
|
|
181
222
|
heroRef: heroRef,
|
|
182
223
|
getHerosOnScreen: getHerosOnScreen,
|
|
183
|
-
trigger: triggerHeroAnimation
|
|
224
|
+
trigger: triggerHeroAnimation,
|
|
225
|
+
heroComponentRef: function heroComponentRef(componentId) {
|
|
226
|
+
return function (elRef) {
|
|
227
|
+
if (elRef) {
|
|
228
|
+
elRef.setAttribute(DATA_TAG_HERO_COMPONENT, componentId);
|
|
229
|
+
elRef.classList.add(_useHeroModule.default.component);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
184
233
|
};
|
|
185
234
|
}
|
|
186
235
|
function isElementOutsideViewport(coordinates) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import "../assets/styles/index.scss";
|
|
2
|
+
|
|
1
3
|
$timing: cubic-bezier(0.5, -0.45, 0.44, 1.37);
|
|
2
4
|
// $timing: cubic-bezier(0.73, -0.49, 0.16, 1.4);
|
|
3
5
|
|
|
@@ -31,3 +33,8 @@ $timing: cubic-bezier(0.5, -0.45, 0.44, 1.37);
|
|
|
31
33
|
transform: rotateY(0deg);
|
|
32
34
|
}
|
|
33
35
|
}
|
|
36
|
+
|
|
37
|
+
.component {
|
|
38
|
+
transition: height $fast linear, opacity $fast linear;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
declare type PrependNextNum<A extends Array<unknown>> = A[
|
|
1
|
+
declare type PrependNextNum<A extends Array<unknown>> = A["length"] extends infer T ? ((t: T, ...a: A) => void) extends (...x: infer X) => void ? X : never : never;
|
|
2
2
|
declare type EnumerateInternal<A extends Array<unknown>, N extends number> = {
|
|
3
3
|
0: A;
|
|
4
4
|
1: EnumerateInternal<PrependNextNum<A>, N>;
|
|
5
|
-
}[N extends A[
|
|
6
|
-
export declare type Enumerate<N extends number> = EnumerateInternal<[
|
|
5
|
+
}[N extends A["length"] ? 0 : 1];
|
|
6
|
+
export declare type Enumerate<N extends number> = EnumerateInternal<[
|
|
7
|
+
], N> extends (infer E)[] ? E : never;
|
|
7
8
|
export declare type Range<FROM extends number, TO extends number> = Exclude<Enumerate<TO>, Enumerate<FROM>>;
|
|
8
9
|
export declare type CommonErrorCodes = "UNEXPECTED_ERROR";
|
|
9
10
|
export declare type BasicContext<T extends object> = {
|
|
@@ -46,7 +47,7 @@ export declare type DeepMap<T, TValue> = {
|
|
|
46
47
|
[K in keyof T]?: IsAny<T[K]> extends true ? any : NonNullable<T[K]> extends NestedValue | Date | FileList | File ? TValue : NonUndefined<T[K]> extends object | null ? DeepMap<T[K], TValue> : NonUndefined<T[K]> extends Array<infer U> ? IsAny<U> extends true ? Array<any> : U extends NestedValue | Date | FileList ? Array<TValue> : U extends object ? Array<DeepMap<U, TValue>> : Array<TValue> : TValue;
|
|
47
48
|
};
|
|
48
49
|
export declare type IsFlatObject<T extends object> = Extract<Exclude<T[keyof T], NestedValue | Date | FileList>, any[] | object> extends never ? true : false;
|
|
49
|
-
declare type IsTuple<T extends ReadonlyArray<any>> = number extends T[
|
|
50
|
+
declare type IsTuple<T extends ReadonlyArray<any>> = number extends T["length"] ? false : true;
|
|
50
51
|
declare type TupleKey<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
|
|
51
52
|
declare type ArrayKey = number;
|
|
52
53
|
declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}.${Path<V>}`;
|
|
@@ -69,4 +70,10 @@ export declare type FieldArrayPathValue<TFieldValues extends FieldValues, TField
|
|
|
69
70
|
export declare type FieldPathValues<TFieldValues extends FieldValues, TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]> = {} & {
|
|
70
71
|
[K in keyof TPath]: FieldPathValue<TFieldValues, TPath[K] & FieldPath<TFieldValues>>;
|
|
71
72
|
};
|
|
73
|
+
export declare type ToFirebaseType<B> = {
|
|
74
|
+
[k in keyof B]: B[k] extends Date ? import("firebase/firestore").Timestamp : B[k] extends Object ? ToFirebaseType<B[k]> : B[k];
|
|
75
|
+
};
|
|
76
|
+
export declare type FromFirebaseType<B> = {
|
|
77
|
+
[k in keyof B]: B[k] extends import("firebase/firestore").Timestamp ? Date : B[k] extends Object ? FromFirebaseType<B[k]> : B[k];
|
|
78
|
+
};
|
|
72
79
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onepercentio/one-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "A set of reusable components created through the development of Onepercent projects",
|
|
5
5
|
"repository": "git@github.com:onepercentio/one-ui.git",
|
|
6
6
|
"author": "Murilo Oliveira de Araujo <murilo.araujo@onepercent.io>",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"babel-plugin-remove-unused-vars": "2.2.0",
|
|
41
41
|
"buffer": "^6.0.3",
|
|
42
42
|
"chroma-js": "^2.4.2",
|
|
43
|
+
"color-seed": "^1.1.3",
|
|
43
44
|
"cpy-cli": "^3.1.1",
|
|
44
45
|
"crypto-browserify": "^3.12.0",
|
|
45
46
|
"css-loader": "^5",
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
type PrependNextNum<A extends Array<unknown>> = A[
|
|
1
|
+
type PrependNextNum<A extends Array<unknown>> = A["length"] extends infer T
|
|
2
|
+
? ((t: T, ...a: A) => void) extends (...x: infer X) => void
|
|
3
|
+
? X
|
|
4
|
+
: never
|
|
5
|
+
: never;
|
|
2
6
|
|
|
3
|
-
type EnumerateInternal<A extends Array<unknown>, N extends number> = {
|
|
7
|
+
type EnumerateInternal<A extends Array<unknown>, N extends number> = {
|
|
8
|
+
0: A;
|
|
9
|
+
1: EnumerateInternal<PrependNextNum<A>, N>;
|
|
10
|
+
}[N extends A["length"] ? 0 : 1];
|
|
4
11
|
|
|
5
|
-
export type Enumerate<N extends number> = EnumerateInternal<
|
|
12
|
+
export type Enumerate<N extends number> = EnumerateInternal<
|
|
13
|
+
[],
|
|
14
|
+
N
|
|
15
|
+
> extends (infer E)[]
|
|
16
|
+
? E
|
|
17
|
+
: never;
|
|
6
18
|
|
|
7
|
-
export type Range<FROM extends number, TO extends number> = Exclude<
|
|
19
|
+
export type Range<FROM extends number, TO extends number> = Exclude<
|
|
20
|
+
Enumerate<TO>,
|
|
21
|
+
Enumerate<FROM>
|
|
22
|
+
>;
|
|
8
23
|
|
|
9
24
|
export type CommonErrorCodes = "UNEXPECTED_ERROR";
|
|
10
25
|
|
|
@@ -37,49 +52,148 @@ declare global {
|
|
|
37
52
|
type NestedValue = unknown;
|
|
38
53
|
type FieldValues = unknown;
|
|
39
54
|
|
|
40
|
-
export declare type Primitive =
|
|
55
|
+
export declare type Primitive =
|
|
56
|
+
| null
|
|
57
|
+
| undefined
|
|
58
|
+
| string
|
|
59
|
+
| number
|
|
60
|
+
| boolean
|
|
61
|
+
| symbol
|
|
62
|
+
| bigint;
|
|
41
63
|
export declare type EmptyObject = {
|
|
42
64
|
[K in string | number]: never;
|
|
43
65
|
};
|
|
44
66
|
export declare type NonUndefined<T> = T extends undefined ? never : T;
|
|
45
|
-
export declare type LiteralUnion<T extends U, U extends Primitive> =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
export declare type LiteralUnion<T extends U, U extends Primitive> =
|
|
68
|
+
| T
|
|
69
|
+
| (U & {
|
|
70
|
+
_?: never;
|
|
71
|
+
});
|
|
72
|
+
export declare type DeepPartial<T> = T extends Array<infer U>
|
|
73
|
+
? Array<DeepPartial<U>>
|
|
74
|
+
: T extends ReadonlyArray<infer U>
|
|
75
|
+
? ReadonlyArray<DeepPartial<U>>
|
|
76
|
+
: T extends {
|
|
77
|
+
[key in keyof T]: T[key];
|
|
78
|
+
}
|
|
79
|
+
? {
|
|
80
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
81
|
+
}
|
|
82
|
+
: T;
|
|
83
|
+
export declare type IsAny<T> = boolean extends (T extends never ? true : false)
|
|
84
|
+
? true
|
|
85
|
+
: false;
|
|
54
86
|
export declare type DeepMap<T, TValue> = {
|
|
55
|
-
[K in keyof T]?: IsAny<T[K]> extends true
|
|
87
|
+
[K in keyof T]?: IsAny<T[K]> extends true
|
|
88
|
+
? any
|
|
89
|
+
: NonNullable<T[K]> extends NestedValue | Date | FileList | File
|
|
90
|
+
? TValue
|
|
91
|
+
: NonUndefined<T[K]> extends object | null
|
|
92
|
+
? DeepMap<T[K], TValue>
|
|
93
|
+
: NonUndefined<T[K]> extends Array<infer U>
|
|
94
|
+
? IsAny<U> extends true
|
|
95
|
+
? Array<any>
|
|
96
|
+
: U extends NestedValue | Date | FileList
|
|
97
|
+
? Array<TValue>
|
|
98
|
+
: U extends object
|
|
99
|
+
? Array<DeepMap<U, TValue>>
|
|
100
|
+
: Array<TValue>
|
|
101
|
+
: TValue;
|
|
56
102
|
};
|
|
57
|
-
export declare type IsFlatObject<T extends object> = Extract<
|
|
58
|
-
|
|
59
|
-
|
|
103
|
+
export declare type IsFlatObject<T extends object> = Extract<
|
|
104
|
+
Exclude<T[keyof T], NestedValue | Date | FileList>,
|
|
105
|
+
any[] | object
|
|
106
|
+
> extends never
|
|
107
|
+
? true
|
|
108
|
+
: false;
|
|
109
|
+
declare type IsTuple<T extends ReadonlyArray<any>> = number extends T["length"]
|
|
110
|
+
? false
|
|
111
|
+
: true;
|
|
112
|
+
declare type TupleKey<T extends ReadonlyArray<any>> = Exclude<
|
|
113
|
+
keyof T,
|
|
114
|
+
keyof any[]
|
|
115
|
+
>;
|
|
60
116
|
declare type ArrayKey = number;
|
|
61
|
-
declare type PathImpl<K extends string | number, V> = V extends Primitive
|
|
117
|
+
declare type PathImpl<K extends string | number, V> = V extends Primitive
|
|
118
|
+
? `${K}`
|
|
119
|
+
: `${K}.${Path<V>}`;
|
|
62
120
|
export declare type Path<T> = T extends ReadonlyArray<infer V>
|
|
63
|
-
?
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
:
|
|
121
|
+
? IsTuple<T> extends true
|
|
122
|
+
? {
|
|
123
|
+
[K in TupleKey<T>]-?: PathImpl<K & string, T[K]>;
|
|
124
|
+
}[TupleKey<T>]
|
|
125
|
+
: PathImpl<ArrayKey, V>
|
|
126
|
+
: {
|
|
127
|
+
[K in keyof T]-?: PathImpl<K & string, T[K]>;
|
|
128
|
+
}[keyof T];
|
|
129
|
+
export declare type FieldPath<TFieldValues extends FieldValues> =
|
|
130
|
+
Path<TFieldValues>;
|
|
131
|
+
declare type ArrayPathImpl<K extends string | number, V> = V extends Primitive
|
|
132
|
+
? never
|
|
133
|
+
: V extends ReadonlyArray<infer U>
|
|
134
|
+
? U extends Primitive
|
|
135
|
+
? never
|
|
136
|
+
: `${K}` | `${K}.${ArrayPath<V>}`
|
|
137
|
+
: `${K}.${ArrayPath<V>}`;
|
|
138
|
+
export declare type ArrayPath<T> = T extends ReadonlyArray<infer V>
|
|
139
|
+
? IsTuple<T> extends true
|
|
140
|
+
? {
|
|
141
|
+
[K in TupleKey<T>]-?: ArrayPathImpl<K & string, T[K]>;
|
|
142
|
+
}[TupleKey<T>]
|
|
143
|
+
: ArrayPathImpl<ArrayKey, V>
|
|
69
144
|
: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export declare type
|
|
73
|
-
|
|
74
|
-
export declare type
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
145
|
+
[K in keyof T]-?: ArrayPathImpl<K & string, T[K]>;
|
|
146
|
+
}[keyof T];
|
|
147
|
+
export declare type FieldArrayPath<TFieldValues extends FieldValues> =
|
|
148
|
+
ArrayPath<TFieldValues>;
|
|
149
|
+
export declare type PathValue<T, P extends Path<T> | ArrayPath<T>> =
|
|
150
|
+
P extends `${infer K}.${infer R}`
|
|
151
|
+
? K extends keyof T
|
|
152
|
+
? R extends Path<T[K]>
|
|
153
|
+
? PathValue<T[K], R>
|
|
154
|
+
: never
|
|
155
|
+
: K extends `${ArrayKey}`
|
|
156
|
+
? T extends ReadonlyArray<infer V>
|
|
157
|
+
? PathValue<V, R & Path<V>>
|
|
158
|
+
: never
|
|
159
|
+
: never
|
|
160
|
+
: P extends keyof T
|
|
161
|
+
? T[P]
|
|
162
|
+
: P extends `${ArrayKey}`
|
|
163
|
+
? T extends ReadonlyArray<infer V>
|
|
164
|
+
? V
|
|
165
|
+
: never
|
|
166
|
+
: never;
|
|
167
|
+
export declare type FieldPathValue<
|
|
168
|
+
TFieldValues extends FieldValues,
|
|
169
|
+
TFieldPath extends FieldPath<TFieldValues>
|
|
170
|
+
> = PathValue<TFieldValues, TFieldPath>;
|
|
171
|
+
export declare type FieldArrayPathValue<
|
|
172
|
+
TFieldValues extends FieldValues,
|
|
173
|
+
TFieldArrayPath extends FieldArrayPath<TFieldValues>
|
|
174
|
+
> = PathValue<TFieldValues, TFieldArrayPath>;
|
|
175
|
+
export declare type FieldPathValues<
|
|
176
|
+
TFieldValues extends FieldValues,
|
|
177
|
+
TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]
|
|
178
|
+
> = {} & {
|
|
179
|
+
[K in keyof TPath]: FieldPathValue<
|
|
180
|
+
TFieldValues,
|
|
181
|
+
TPath[K] & FieldPath<TFieldValues>
|
|
182
|
+
>;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export type ToFirebaseType<B> = {
|
|
186
|
+
[k in keyof B]: B[k] extends Date
|
|
187
|
+
? import("firebase/firestore").Timestamp
|
|
188
|
+
: B[k] extends Object
|
|
189
|
+
? ToFirebaseType<B[k]>
|
|
190
|
+
: B[k];
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type FromFirebaseType<B> = {
|
|
194
|
+
[k in keyof B]: B[k] extends import("firebase/firestore").Timestamp
|
|
195
|
+
? Date
|
|
196
|
+
: B[k] extends Object
|
|
197
|
+
? FromFirebaseType<B[k]>
|
|
198
|
+
: B[k];
|
|
199
|
+
};
|