@fibery/ui-kit 1.40.3 → 1.41.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/CHANGELOG.md +14 -0
- package/eslint.config.mjs +16 -0
- package/package.json +11 -13
- package/src/a11y-color.test.ts +162 -0
- package/src/a11y-color.ts +13 -20
- package/src/actions-menu/actions-menu-item.tsx +9 -12
- package/src/actions-menu/context-actions-menu.tsx +8 -3
- package/src/ai/model.tsx +0 -1
- package/src/ai/temperature.tsx +0 -1
- package/src/animated-height-container.tsx +3 -3
- package/src/antd/ant-modal.tsx +10 -5
- package/src/antd/index.tsx +3 -0
- package/src/antd/input.tsx +0 -1
- package/src/antd/styles.ts +15 -15
- package/src/app-icon-with-fallback.tsx +6 -6
- package/src/app-icon-wrapper.tsx +2 -3
- package/src/app-icon.tsx +4 -4
- package/src/avatar.tsx +3 -3
- package/src/button/base-button.tsx +0 -1
- package/src/button/button.tsx +1 -0
- package/src/button/make-button-colors.ts +5 -13
- package/src/checkbox.tsx +2 -2
- package/src/collapsible-section.tsx +11 -1
- package/src/color-picker/ColorPickerOrLoader.js +2 -2
- package/src/color-utils.test.ts +307 -0
- package/src/color-utils.ts +215 -0
- package/src/command-menu/index.tsx +1 -0
- package/src/comment.tsx +3 -2
- package/src/context-menu/index.tsx +12 -7
- package/src/date-picker/contexts.ts +2 -2
- package/src/date-picker/date-range-picker.tsx +3 -4
- package/src/date-picker/single-date-picker.tsx +147 -119
- package/src/date-picker/types.ts +4 -3
- package/src/day-select/iso-week-day-select.tsx +2 -2
- package/src/day-select/week-day-select.tsx +2 -2
- package/src/delayed.tsx +0 -1
- package/src/design-system/alpha.test.ts +59 -0
- package/src/design-system/alpha.ts +41 -0
- package/src/design-system/animation.ts +10 -0
- package/src/design-system/colors-css.test.ts +39 -0
- package/src/design-system/colors-css.ts +25 -0
- package/src/design-system/colors-js.test.ts +232 -0
- package/src/design-system/colors-js.ts +107 -0
- package/src/design-system/colors.test.ts +74 -0
- package/src/design-system/colors.ts +759 -0
- package/src/design-system/date.ts +3 -0
- package/src/design-system/layout.ts +106 -0
- package/src/design-system/theme.test.ts +94 -0
- package/src/design-system/theme.ts +93 -0
- package/src/design-system/typography.ts +179 -0
- package/src/design-system/vars.test.ts +1679 -0
- package/src/design-system/vars.ts +52 -0
- package/src/design-system.test.ts +45 -22
- package/src/design-system.ts +25 -1339
- package/src/dropdown-menu/index.tsx +21 -16
- package/src/emoji-picker/app-icon-picker.tsx +5 -5
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +4 -4
- package/src/emoji-picker/icon-emoji-picker.tsx +3 -3
- package/src/favorites-icon.tsx +1 -1
- package/src/fibermoji-placeholder.tsx +3 -3
- package/src/field-container.tsx +11 -2
- package/src/file-item/file-icon.tsx +169 -0
- package/src/file-item/file-menu-items.tsx +68 -0
- package/src/file-item/file-preview-actions.tsx +38 -0
- package/src/file-item/file-title.tsx +48 -0
- package/src/file-item/types.ts +27 -0
- package/src/file-item/use-register-in-image-gallery.tsx +70 -0
- package/src/file-item-2.tsx +32 -348
- package/src/file-item.tsx +6 -3
- package/src/hue-shift.test.ts +91 -0
- package/src/icons/ast/ChatBubble.ts +8 -0
- package/src/icons/ast/ChatFloat.ts +8 -0
- package/src/icons/ast/ChatSidebar.ts +8 -0
- package/src/icons/ast/FileCounter.ts +8 -0
- package/src/icons/ast/FileMultiple.ts +8 -0
- package/src/icons/ast/FileOther.ts +8 -0
- package/src/icons/ast/NoBorder.ts +8 -0
- package/src/icons/ast/NoFill.ts +8 -0
- package/src/icons/ast/ValueEdit.ts +8 -0
- package/src/icons/ast/index.tsx +9 -0
- package/src/icons/react/ChatBubble.tsx +13 -0
- package/src/icons/react/ChatFloat.tsx +13 -0
- package/src/icons/react/ChatSidebar.tsx +13 -0
- package/src/icons/react/FileCounter.tsx +13 -0
- package/src/icons/react/FileMultiple.tsx +13 -0
- package/src/icons/react/FileOther.tsx +13 -0
- package/src/icons/react/NoBorder.tsx +13 -0
- package/src/icons/react/NoFill.tsx +13 -0
- package/src/icons/react/ValueEdit.tsx +13 -0
- package/src/icons/react/index.tsx +9 -0
- package/src/icons/svg/chat-bubble.svg +4 -0
- package/src/icons/svg/chat-float.svg +4 -0
- package/src/icons/svg/chat-sidebar.svg +4 -0
- package/src/icons/svg/file-counter.svg +3 -0
- package/src/icons/svg/file-multiple.svg +3 -0
- package/src/icons/svg/file-other.svg +3 -0
- package/src/icons/svg/no-border.svg +17 -0
- package/src/icons/svg/no-fill.svg +4 -0
- package/src/icons/svg/value-edit.svg +3 -0
- package/src/images-gallery/images-gallery.tsx +8 -6
- package/src/images-gallery/slide-buttons.tsx +4 -11
- package/src/is-iOS.ts +0 -1
- package/src/is-in-popup.ts +2 -1
- package/src/lists/actions-menu-row-surface.tsx +7 -7
- package/src/loading-sausage.tsx +2 -2
- package/src/media-query-utils.ts +1 -2
- package/src/mobile-keyboard-aware-popup.tsx +6 -5
- package/src/modal-menu/modal-menu-content.tsx +2 -2
- package/src/number-input/decimal.js +9 -7
- package/src/number-input/{number-inline-input-with-autosize.tsx → number-input-inline-with-autosize.tsx} +20 -41
- package/src/number-input/number-input-inline.tsx +118 -0
- package/src/number-input/{index.test.js → number-input.test.tsx} +38 -43
- package/src/number-input/number-input.tsx +63 -121
- package/src/number-input/types.ts +19 -0
- package/src/number-input/utils.ts +61 -0
- package/src/online-users.tsx +2 -2
- package/src/palette-generator.test.ts +309 -0
- package/src/palette-generator.ts +160 -0
- package/src/palettes/_.ts +72 -0
- package/src/palettes/slate-arch.colors-snapshot.test.ts +1689 -0
- package/src/palettes/slate-arch.ts +188 -0
- package/src/palettes/slate-user.colors-snapshot.test.ts +1689 -0
- package/src/palettes/slate-user.ts +187 -0
- package/src/palettes/warm-arch.colors-snapshot.test.ts +1689 -0
- package/src/palettes/warm-arch.ts +222 -0
- package/src/palettes/warm-user.colors-snapshot.test.ts +1689 -0
- package/src/palettes/warm-user.ts +222 -0
- package/src/platform.ts +0 -3
- package/src/popover/get-element-ref.ts +28 -0
- package/src/popover/index.tsx +236 -339
- package/src/popover/{mobile-popup-context.tsx → mobile-popover-context.tsx} +7 -7
- package/src/popover/mobile-popover.tsx +169 -0
- package/src/popover/modifiers.tsx +2 -2
- package/src/popover/popup-stack-context.tsx +8 -9
- package/src/progress.tsx +2 -2
- package/src/reactions/reaction-button.tsx +12 -6
- package/src/root-theme-provider.test.tsx +411 -0
- package/src/scale-generator.ts +356 -0
- package/src/select/components/menu-list-virtualized.tsx +12 -25
- package/src/select/components/menu.tsx +12 -2
- package/src/select/index.tsx +6 -5
- package/src/select/select.tsx +38 -39
- package/src/select/styles.ts +0 -1
- package/src/select/util.ts +1 -1
- package/src/static-palettes.ts +356 -0
- package/src/thematic-color-picker.tsx +266 -0
- package/src/thematic-constants.tsx +27 -0
- package/src/thematic-controls.tsx +144 -0
- package/src/thematic-scales.tsx +122 -0
- package/src/thematic-state.ts +370 -0
- package/src/thematic.tsx +386 -0
- package/src/theme-provider.test.tsx +820 -0
- package/src/theme-provider.tsx +158 -92
- package/src/theme-settings.ts +67 -12
- package/src/theme-styles.ts +58 -6
- package/src/toast/toast-action.tsx +1 -1
- package/src/toast/toast.tsx +1 -2
- package/src/toggle-on-off.tsx +2 -2
- package/src/toggle.tsx +7 -8
- package/src/tooltip.tsx +14 -10
- package/src/type-badge.tsx +7 -14
- package/src/unit/styles.ts +2 -25
- package/src/unit/unit-with-tooltip.tsx +3 -2
- package/src/use-is-phone.tsx +7 -2
- package/src/use-long-press.tsx +2 -2
- package/src/use-on-screen-keyboard-data.tsx +2 -2
- package/src/with-data.tsx +4 -3
- package/src/workflow-progress-icon.tsx +2 -2
- package/.eslintignore +0 -3
- package/.eslintrc +0 -14
- package/src/__mocks__/createInlineTheme.js +0 -3
- package/src/create-inline-theme.ts +0 -66
- package/src/number-input/index.js +0 -191
- package/src/palette.ts +0 -237
package/src/unit/styles.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const textEllipsisClassName = css`
|
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
10
|
export const basicUnitClassName = css`
|
|
11
|
-
border-radius: ${space.
|
|
11
|
+
border-radius: ${space.s6}px;
|
|
12
12
|
border: none;
|
|
13
13
|
`;
|
|
14
14
|
|
|
@@ -62,7 +62,6 @@ export const unitWithTitleClassName = css`
|
|
|
62
62
|
`;
|
|
63
63
|
|
|
64
64
|
export const invalidUnitClassName = css``;
|
|
65
|
-
export const invalidUnitClassNameInForm = css``;
|
|
66
65
|
|
|
67
66
|
export const clickableClassName = css`
|
|
68
67
|
cursor: pointer;
|
|
@@ -84,7 +83,7 @@ export const borderClassName = css`
|
|
|
84
83
|
bottom: 0;
|
|
85
84
|
box-shadow: ${themeVars.inputBorderColor} inset;
|
|
86
85
|
mix-blend-mode: ${themeVars.inputBorderBlendMode};
|
|
87
|
-
border-radius: ${space.
|
|
86
|
+
border-radius: ${space.s6}px;
|
|
88
87
|
pointer-events: none;
|
|
89
88
|
}
|
|
90
89
|
|
|
@@ -97,14 +96,6 @@ export const borderClassName = css`
|
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
&.${invalidUnitClassName} {
|
|
100
|
-
padding-left: 20px;
|
|
101
|
-
&:has(button) {
|
|
102
|
-
padding-left: 0;
|
|
103
|
-
}
|
|
104
|
-
& button {
|
|
105
|
-
padding-left: 20px;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
99
|
&::before {
|
|
109
100
|
box-shadow: none;
|
|
110
101
|
border: 1px solid ${themeVars.colorBorderButtonOutlineAccentDefault};
|
|
@@ -119,20 +110,6 @@ export const borderClassName = css`
|
|
|
119
110
|
box-shadow: ${themeVars.inputBorderFocusColor} inset;
|
|
120
111
|
border: none;
|
|
121
112
|
}
|
|
122
|
-
&::after {
|
|
123
|
-
content: "";
|
|
124
|
-
position: absolute;
|
|
125
|
-
top: 0;
|
|
126
|
-
width: 20px;
|
|
127
|
-
left: 4px;
|
|
128
|
-
right: 0;
|
|
129
|
-
bottom: 0;
|
|
130
|
-
background-image: url("./required-indicator.svg");
|
|
131
|
-
background-repeat: no-repeat;
|
|
132
|
-
background-size: 16px 16px;
|
|
133
|
-
background-position: center;
|
|
134
|
-
pointer-events: none;
|
|
135
|
-
}
|
|
136
113
|
}
|
|
137
114
|
`;
|
|
138
115
|
|
|
@@ -13,9 +13,10 @@ type Props = {
|
|
|
13
13
|
children: React.ReactElement;
|
|
14
14
|
title: React.ReactNode;
|
|
15
15
|
description: React.ReactNode;
|
|
16
|
+
hidden?: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
export const UnitWithTooltip = ({children, title, description}: Props) => {
|
|
19
|
+
export const UnitWithTooltip = ({children, title, description, hidden}: Props) => {
|
|
19
20
|
const [shouldDisplayTooltip, setShouldDisplayTooltip] = useState(false);
|
|
20
21
|
const unitElementRef = useRef<HTMLDivElement>(null);
|
|
21
22
|
const isHoveredRef = useRef(false);
|
|
@@ -57,7 +58,7 @@ export const UnitWithTooltip = ({children, title, description}: Props) => {
|
|
|
57
58
|
|
|
58
59
|
return (
|
|
59
60
|
<Tooltip
|
|
60
|
-
visible={shouldDisplayTooltip}
|
|
61
|
+
visible={!hidden && shouldDisplayTooltip}
|
|
61
62
|
content={
|
|
62
63
|
<div className={contentCss}>
|
|
63
64
|
<TooltipTitle>{title}</TooltipTitle>
|
package/src/use-is-phone.tsx
CHANGED
|
@@ -20,8 +20,13 @@ function isVerticalMobileBreakpointDisabled() {
|
|
|
20
20
|
) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
if (globalThis.URLSearchParams) {
|
|
25
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
26
|
+
return urlParams.has("no-vertical-mobile-breakpoint");
|
|
27
|
+
} else {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export const isPhoneApp = () =>
|
package/src/use-long-press.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {$TSFixMe} from "./tsfixme";
|
|
|
3
3
|
|
|
4
4
|
function on<T extends Window | Document | HTMLElement | EventTarget>(
|
|
5
5
|
obj: T | null,
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-function-type -- DOM API compatibility
|
|
7
7
|
...args: Parameters<T["addEventListener"]> | [string, Function | null, ...any]
|
|
8
8
|
): void {
|
|
9
9
|
if (obj && obj.addEventListener) {
|
|
@@ -13,7 +13,7 @@ function on<T extends Window | Document | HTMLElement | EventTarget>(
|
|
|
13
13
|
|
|
14
14
|
export function off<T extends Window | Document | HTMLElement | EventTarget>(
|
|
15
15
|
obj: T | null,
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-function-type -- DOM API compatibility
|
|
17
17
|
...args: Parameters<T["removeEventListener"]> | [string, Function | null, ...any]
|
|
18
18
|
): void {
|
|
19
19
|
if (obj && obj.removeEventListener) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ReactNode, useEffect, useState} from "react";
|
|
2
2
|
import {createContext} from "@fibery/react/src/create-context";
|
|
3
|
-
import
|
|
3
|
+
import noop from "lodash/noop";
|
|
4
4
|
import {isPhoneApp} from "./use-is-phone";
|
|
5
5
|
import {keyboardHeightVar, mobileKeyboardOpenClassName} from "./mobile-styles";
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ export function OnScreenKeyboardContextProvider({children}: {children: ReactNode
|
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
const viewport = window.visualViewport;
|
|
25
25
|
if (!viewport || !isPhoneApp()) {
|
|
26
|
-
return
|
|
26
|
+
return noop;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function viewportHandler() {
|
package/src/with-data.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import mapValues from "lodash/mapValues";
|
|
2
|
+
import noop from "lodash/noop";
|
|
2
3
|
import {PureComponent, ComponentType} from "react";
|
|
3
4
|
import {asError} from "./errors";
|
|
4
5
|
import {$TSFixMe} from "./tsfixme";
|
|
@@ -25,7 +26,7 @@ type ProvidedState = Record<string, FetchState>;
|
|
|
25
26
|
export function provideData<T>({sources}: {sources: Record<string, () => Promise<$TSFixMe>>}) {
|
|
26
27
|
return (Component: ComponentType<T & ProvidedState>) =>
|
|
27
28
|
class DataProvider extends PureComponent<T, ProvidedState> {
|
|
28
|
-
state =
|
|
29
|
+
state = mapValues(
|
|
29
30
|
sources,
|
|
30
31
|
(): FetchState => ({
|
|
31
32
|
fetchState: ":fetch-state/start",
|
|
@@ -66,7 +67,7 @@ export function provideData<T>({sources}: {sources: Record<string, () => Promise
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
componentWillUnmount() {
|
|
69
|
-
this.setStateIfMounted =
|
|
70
|
+
this.setStateIfMounted = noop;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
render() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
2
|
import {arc} from "d3-shape";
|
|
3
|
-
import
|
|
3
|
+
import memoize from "lodash/memoize";
|
|
4
4
|
import {FC} from "react";
|
|
5
5
|
import {themeVars} from "./design-system";
|
|
6
6
|
|
|
@@ -52,7 +52,7 @@ export const WorkflowProgressIcon: FC<WorkflowProgressIcon> = ({
|
|
|
52
52
|
);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const getPath =
|
|
55
|
+
const getPath = memoize(
|
|
56
56
|
(index, total, size) => {
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
58
58
|
// @ts-ignore bad d3-shape typings
|
package/.eslintignore
DELETED
package/.eslintrc
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
export const varPrefix = process.env.VAR_THEME_PREFIX || "fibery";
|
|
4
|
-
|
|
5
|
-
export function createInlineTheme<T extends Record<string, unknown>>(
|
|
6
|
-
themes: T,
|
|
7
|
-
rejectKeys: Array<string>
|
|
8
|
-
): Record<string, string> {
|
|
9
|
-
return Object.entries(themes).reduce<Record<string, string>>((inlineTheme, [key, value]) => {
|
|
10
|
-
if (rejectKeys.includes(key)) {
|
|
11
|
-
return inlineTheme;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (key === "opacity") {
|
|
15
|
-
Object.entries(themes.opacity as Record<string, string>).forEach(([opacityKey, opacityValue]) => {
|
|
16
|
-
inlineTheme[`--${varPrefix}-opacity-${opacityKey}`] = opacityValue;
|
|
17
|
-
}, "");
|
|
18
|
-
|
|
19
|
-
return inlineTheme;
|
|
20
|
-
}
|
|
21
|
-
if (key === "stateColors") {
|
|
22
|
-
Object.entries(themes.stateColors as Record<string, string>).forEach(([stateColorKey, stateColorValue]) => {
|
|
23
|
-
inlineTheme[`--${varPrefix}-state-colors-${stateColorKey}`] = stateColorValue;
|
|
24
|
-
}, "");
|
|
25
|
-
|
|
26
|
-
return inlineTheme;
|
|
27
|
-
}
|
|
28
|
-
if (key === "brandColors") {
|
|
29
|
-
Object.entries(themes.brandColors as Record<string, string>).forEach(([brandColorKey, brandColorValue]) => {
|
|
30
|
-
inlineTheme[`--${varPrefix}-brand-colors-${brandColorKey}`] = brandColorValue;
|
|
31
|
-
}, "");
|
|
32
|
-
|
|
33
|
-
return inlineTheme;
|
|
34
|
-
}
|
|
35
|
-
if (key === "shades") {
|
|
36
|
-
Object.entries(themes.shades as Record<string, string>).forEach(([shadeKey, shadeValue]) => {
|
|
37
|
-
inlineTheme[`--${varPrefix}-shades-${shadeKey}`] = shadeValue;
|
|
38
|
-
}, "");
|
|
39
|
-
|
|
40
|
-
return inlineTheme;
|
|
41
|
-
}
|
|
42
|
-
if (key === "lights") {
|
|
43
|
-
Object.entries(themes.lights as Record<string, string>).forEach(([lightKey, lightValue]) => {
|
|
44
|
-
inlineTheme[`--${varPrefix}-lights-${lightKey}`] = lightValue;
|
|
45
|
-
}, "");
|
|
46
|
-
|
|
47
|
-
return inlineTheme;
|
|
48
|
-
}
|
|
49
|
-
if (key === "separators") {
|
|
50
|
-
Object.entries(themes.separators as Record<string, string>).forEach(([separatorKey, separatorValue]) => {
|
|
51
|
-
inlineTheme[`--${varPrefix}-separator-${separatorKey}`] = separatorValue;
|
|
52
|
-
}, "");
|
|
53
|
-
|
|
54
|
-
return inlineTheme;
|
|
55
|
-
}
|
|
56
|
-
if (key === "inversedSeparators") {
|
|
57
|
-
Object.entries(themes.inversedSeparators as Record<string, string>).forEach(([separatorKey, separatorValue]) => {
|
|
58
|
-
inlineTheme[`--${varPrefix}-inversed-separators-${separatorKey}`] = separatorValue;
|
|
59
|
-
}, "");
|
|
60
|
-
|
|
61
|
-
return inlineTheme;
|
|
62
|
-
}
|
|
63
|
-
inlineTheme[`--${varPrefix}-color-${key}`] = value as string;
|
|
64
|
-
return inlineTheme;
|
|
65
|
-
}, {});
|
|
66
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import _ from "lodash";
|
|
2
|
-
import {bool, func, number, object, oneOf, oneOfType, string} from "prop-types";
|
|
3
|
-
import {useCallback, useMemo, useState, useEffect} from "react";
|
|
4
|
-
import {AntInputNumber} from "../antd/input-number";
|
|
5
|
-
import {Tooltip} from "../tooltip";
|
|
6
|
-
import {add, divideByHundred, multiplyByHundred, sub} from "./decimal";
|
|
7
|
-
|
|
8
|
-
const isEmpty = (value) => _.isNil(value) || value === "";
|
|
9
|
-
|
|
10
|
-
export const getStep = (numberFormat) => {
|
|
11
|
-
if (numberFormat === "Percent") {
|
|
12
|
-
return 0.01;
|
|
13
|
-
}
|
|
14
|
-
return 1;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const formatValue = (value, isEditing, numberFormat, format) => {
|
|
18
|
-
const externalizeNumber = (numberFormat, value) => {
|
|
19
|
-
if (numberFormat === "Percent") {
|
|
20
|
-
return multiplyByHundred(value);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const externalizeValue = (value) => {
|
|
26
|
-
return isEditing ? externalizeNumber(numberFormat, value) : value;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const maybeFormat = (value) => {
|
|
30
|
-
return isEditing ? value : format(value);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
if (isEmpty(value)) {
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
return _.flow([externalizeValue, maybeFormat])(value);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const parseValue = (value, numberFormat, numberPrecision) => {
|
|
40
|
-
const parse = (value) => {
|
|
41
|
-
const parseInteger = (x) => {
|
|
42
|
-
const parsed = parseInt(x);
|
|
43
|
-
return isNaN(parsed) ? null : parsed;
|
|
44
|
-
};
|
|
45
|
-
const parseDecimal = (x) => {
|
|
46
|
-
const parsed = parseFloat(x);
|
|
47
|
-
return isNaN(parsed) ? null : parsed;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const parseStrategy = numberPrecision === 0 ? parseInteger : parseDecimal;
|
|
51
|
-
return parseStrategy(value);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const internalizeNumber = (value) => {
|
|
55
|
-
if (isEmpty(value)) {
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
if (numberFormat === "Percent") {
|
|
59
|
-
return divideByHundred(value);
|
|
60
|
-
}
|
|
61
|
-
return value;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const toString = (value) => {
|
|
65
|
-
return isEmpty(value) ? value : String(value);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
if (isEmpty(value)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
return _.flow([parse, internalizeNumber, toString])(value);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const propTypes = {
|
|
75
|
-
value: oneOfType([string, number]),
|
|
76
|
-
numberFormat: oneOf(["Number", "Money", "Percent"]),
|
|
77
|
-
numberPrecision: number,
|
|
78
|
-
decimalSeparator: string,
|
|
79
|
-
format: func,
|
|
80
|
-
onFocus: func,
|
|
81
|
-
onBlur: func,
|
|
82
|
-
onChange: func,
|
|
83
|
-
onKeyDown: func,
|
|
84
|
-
autoFocus: bool,
|
|
85
|
-
placeholder: string,
|
|
86
|
-
style: object,
|
|
87
|
-
disabled: bool,
|
|
88
|
-
showTooltip: bool,
|
|
89
|
-
controls: bool,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const defaultProps = {
|
|
93
|
-
format: _.identity,
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const InputNumber = (props) => {
|
|
97
|
-
const {value, numberFormat, numberPrecision, format, onFocus, onBlur, onChange, showTooltip = true, ...rest} = props;
|
|
98
|
-
|
|
99
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
100
|
-
const [tooltipVisible, setTooltipVisible] = useState(false);
|
|
101
|
-
const handleFocus = useCallback(
|
|
102
|
-
(e) => {
|
|
103
|
-
if (onFocus) {
|
|
104
|
-
onFocus(e);
|
|
105
|
-
}
|
|
106
|
-
setIsEditing(true);
|
|
107
|
-
},
|
|
108
|
-
[onFocus, setIsEditing]
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
const handleBlur = useCallback(
|
|
112
|
-
(e) => {
|
|
113
|
-
if (onBlur) {
|
|
114
|
-
onBlur(e);
|
|
115
|
-
}
|
|
116
|
-
setIsEditing(false);
|
|
117
|
-
},
|
|
118
|
-
[onBlur, setIsEditing]
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const handleChange = useCallback(
|
|
122
|
-
(value) => {
|
|
123
|
-
if (onChange) {
|
|
124
|
-
onChange(parseValue(value, numberFormat, numberPrecision));
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
[onChange, numberFormat, numberPrecision]
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const handleStep = useCallback(
|
|
131
|
-
(newValue, {type}) => {
|
|
132
|
-
const step = getStep(numberFormat);
|
|
133
|
-
|
|
134
|
-
if (type === "up") {
|
|
135
|
-
onChange(add(value, step));
|
|
136
|
-
} else {
|
|
137
|
-
onChange(sub(value, step));
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
[value, numberFormat, onChange]
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
let formattedValue = useMemo(() => {
|
|
144
|
-
return formatValue(value, isEditing, numberFormat, format);
|
|
145
|
-
}, [value, isEditing, numberFormat, format]);
|
|
146
|
-
|
|
147
|
-
const onTooltipVisibleChange = useCallback(
|
|
148
|
-
(visible) => {
|
|
149
|
-
if (!showTooltip || isEditing || !formattedValue) {
|
|
150
|
-
return setTooltipVisible(false);
|
|
151
|
-
}
|
|
152
|
-
return setTooltipVisible(visible);
|
|
153
|
-
},
|
|
154
|
-
[isEditing, showTooltip, formattedValue]
|
|
155
|
-
);
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
if (tooltipVisible && (!showTooltip || isEditing || !formattedValue)) {
|
|
158
|
-
setTooltipVisible(false);
|
|
159
|
-
}
|
|
160
|
-
}, [formattedValue, isEditing, showTooltip, tooltipVisible]);
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<Tooltip title={formattedValue} onVisibleChange={onTooltipVisibleChange} visible={tooltipVisible}>
|
|
164
|
-
<span>
|
|
165
|
-
<AntInputNumber
|
|
166
|
-
className={rest.className}
|
|
167
|
-
value={formattedValue}
|
|
168
|
-
onFocus={handleFocus}
|
|
169
|
-
onBlur={handleBlur}
|
|
170
|
-
onChange={handleChange}
|
|
171
|
-
onStep={handleStep}
|
|
172
|
-
{...rest}
|
|
173
|
-
/>
|
|
174
|
-
</span>
|
|
175
|
-
</Tooltip>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
InputNumber.propTypes = propTypes;
|
|
180
|
-
InputNumber.defaultProps = defaultProps;
|
|
181
|
-
|
|
182
|
-
export const InputNumberField = (props) => {
|
|
183
|
-
const {input, ...rest} = props;
|
|
184
|
-
const {value, onBlur, ...inputRest} = input;
|
|
185
|
-
|
|
186
|
-
const handleBlur = useCallback(() => {
|
|
187
|
-
onBlur(isEmpty(value) ? null : value);
|
|
188
|
-
}, [onBlur, value]);
|
|
189
|
-
|
|
190
|
-
return <InputNumber value={value} onBlur={handleBlur} {...inputRest} {...rest} />;
|
|
191
|
-
};
|
package/src/palette.ts
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
export const slate = {
|
|
2
|
-
slateBase: "hsl(0, 0%, 100%)",
|
|
3
|
-
slate1: "hsl(206, 0%, 99%)",
|
|
4
|
-
slate2: "hsl(210, 0%, 97%)",
|
|
5
|
-
slate3: "hsl(209, 0%, 96%)",
|
|
6
|
-
slate4: "hsl(209, 0%, 93%)",
|
|
7
|
-
slate5: "hsl(208, 0%, 91%)",
|
|
8
|
-
slate6: "hsl(208, 0%, 89%)",
|
|
9
|
-
slate7: "hsl(207, 0%, 86%)",
|
|
10
|
-
slate8: "hsl(205, 0%, 78%)",
|
|
11
|
-
slate9: "hsl(205, 0%, 62%)",
|
|
12
|
-
slate10: "hsl(205, 0%, 47%)",
|
|
13
|
-
slate11: "hsl(204, 0%, 37%)",
|
|
14
|
-
slate12: "hsl(200, 0%, 9%)",
|
|
15
|
-
} as const;
|
|
16
|
-
|
|
17
|
-
export const slateDark = {
|
|
18
|
-
slateBase: "hsl(0, 0%, 5%)",
|
|
19
|
-
slate1: "hsl(200, 0%, 9%)",
|
|
20
|
-
slate2: "hsl(195, 0%, 11%)",
|
|
21
|
-
slate3: "hsl(197, 0%, 14%)",
|
|
22
|
-
slate4: "hsl(198, 0%, 16%)",
|
|
23
|
-
slate5: "hsl(199, 0%, 18%)",
|
|
24
|
-
slate6: "hsl(201, 0%, 20%)",
|
|
25
|
-
slate7: "hsl(203, 0%, 24%)",
|
|
26
|
-
slate8: "hsl(207, 0%, 32%)",
|
|
27
|
-
slate9: "hsl(206, 0%, 44%)",
|
|
28
|
-
slate10: "hsl(206, 0%, 50%)",
|
|
29
|
-
slate11: "hsl(206, 0%, 63%)",
|
|
30
|
-
slate12: "hsl(210, 0%, 93%)",
|
|
31
|
-
} as const;
|
|
32
|
-
|
|
33
|
-
export const teal = {
|
|
34
|
-
teal1: "hsl(165, 60%, 99%)",
|
|
35
|
-
teal2: "hsl(169, 65%, 97%)",
|
|
36
|
-
teal3: "hsl(169, 60%, 94%)",
|
|
37
|
-
teal4: "hsl(169, 53%, 90%)",
|
|
38
|
-
teal5: "hsl(170, 47%, 85%)",
|
|
39
|
-
teal6: "hsl(170, 43%, 78%)",
|
|
40
|
-
teal7: "hsl(170, 40%, 68%)",
|
|
41
|
-
teal8: "hsl(172, 42%, 52%)",
|
|
42
|
-
teal9: "hsl(173, 80%, 36%)",
|
|
43
|
-
teal10: "hsl(173, 83%, 33%)",
|
|
44
|
-
teal11: "hsl(174, 90%, 25%)",
|
|
45
|
-
teal12: "hsl(170, 50%, 13%)",
|
|
46
|
-
} as const;
|
|
47
|
-
|
|
48
|
-
export const tealDark = {
|
|
49
|
-
teal1: "hsl(168, 48%, 6%)",
|
|
50
|
-
teal2: "hsl(169, 78%, 7%)",
|
|
51
|
-
teal3: "hsl(170, 76%, 9%)",
|
|
52
|
-
teal4: "hsl(171, 76%, 11%)",
|
|
53
|
-
teal5: "hsl(171, 76%, 13%)",
|
|
54
|
-
teal6: "hsl(172, 76%, 15%)",
|
|
55
|
-
teal7: "hsl(172, 77%, 19%)",
|
|
56
|
-
teal8: "hsl(173, 80%, 24%)",
|
|
57
|
-
teal9: "hsl(173, 80%, 36%)",
|
|
58
|
-
teal10: "hsl(174, 84%, 38%)",
|
|
59
|
-
teal11: "hsl(174, 90%, 41%)",
|
|
60
|
-
teal12: "hsl(166, 73%, 93%)",
|
|
61
|
-
} as const;
|
|
62
|
-
|
|
63
|
-
export const indigo = {
|
|
64
|
-
indigo1: "hsl(220, 60%, 99%)",
|
|
65
|
-
indigo2: "hsl(220, 90%, 99%)",
|
|
66
|
-
indigo3: "hsl(220, 88%, 97%)",
|
|
67
|
-
indigo4: "hsl(220, 83%, 95%)",
|
|
68
|
-
indigo5: "hsl(220, 77%, 92%)",
|
|
69
|
-
indigo6: "hsl(220, 72%, 88%)",
|
|
70
|
-
indigo7: "hsl(220, 67%, 82%)",
|
|
71
|
-
indigo8: "hsl(220, 65%, 75%)",
|
|
72
|
-
indigo9: "hsl(220, 62%, 56%)",
|
|
73
|
-
indigo10: "hsl(220, 59%, 51%)",
|
|
74
|
-
indigo11: "hsl(220, 55%, 45%)",
|
|
75
|
-
indigo12: "hsl(220, 62%, 17%)",
|
|
76
|
-
} as const;
|
|
77
|
-
|
|
78
|
-
export const indigoDark = {
|
|
79
|
-
indigo1: "hsl(222, 24%, 10%)",
|
|
80
|
-
indigo2: "hsl(222, 36%, 13%)",
|
|
81
|
-
indigo3: "hsl(222, 43%, 18%)",
|
|
82
|
-
indigo4: "hsl(222, 47%, 21%)",
|
|
83
|
-
indigo5: "hsl(222, 45%, 24%)",
|
|
84
|
-
indigo6: "hsl(222, 43%, 28%)",
|
|
85
|
-
indigo7: "hsl(222, 50%, 35%)",
|
|
86
|
-
indigo8: "hsl(222, 55%, 44%)",
|
|
87
|
-
indigo9: "hsl(222, 60%, 56%)",
|
|
88
|
-
indigo10: "hsl(222, 65%, 62%)",
|
|
89
|
-
indigo11: "hsl(222, 70%, 76%)",
|
|
90
|
-
indigo12: "hsl(222, 83%, 96%)",
|
|
91
|
-
} as const;
|
|
92
|
-
|
|
93
|
-
export const red = {
|
|
94
|
-
red1: "hsl(359, 100%, 99%)",
|
|
95
|
-
red2: "hsl(359, 100%, 99%)",
|
|
96
|
-
red3: "hsl(360, 100%, 97%)",
|
|
97
|
-
red4: "hsl(360, 98%, 95%)",
|
|
98
|
-
red5: "hsl(360, 90%, 92%)",
|
|
99
|
-
red6: "hsl(360, 82%, 88%)",
|
|
100
|
-
red7: "hsl(359, 74%, 82%)",
|
|
101
|
-
red8: "hsl(359, 69%, 74%)",
|
|
102
|
-
red9: "hsl(358, 75%, 59%)",
|
|
103
|
-
red10: "hsl(358, 69%, 55%)",
|
|
104
|
-
red11: "hsl(358, 65%, 49%)",
|
|
105
|
-
red12: "hsl(354, 50%, 15%)",
|
|
106
|
-
} as const;
|
|
107
|
-
|
|
108
|
-
export const redDark = {
|
|
109
|
-
red1: "hsl(353, 23%, 10%)",
|
|
110
|
-
red2: "hsl(357, 34%, 12%)",
|
|
111
|
-
red3: "hsl(356, 43%, 16%)",
|
|
112
|
-
red4: "hsl(356, 48%, 19%)",
|
|
113
|
-
red5: "hsl(356, 51%, 22%)",
|
|
114
|
-
red6: "hsl(356, 55%, 26%)",
|
|
115
|
-
red7: "hsl(357, 60%, 32%)",
|
|
116
|
-
red8: "hsl(358, 65%, 40%)",
|
|
117
|
-
red9: "hsl(358, 75%, 59%)",
|
|
118
|
-
red10: "hsl(358, 85%, 64%)",
|
|
119
|
-
red11: "hsl(358, 100%, 70%)",
|
|
120
|
-
red12: "hsl(351, 89%, 96%)",
|
|
121
|
-
} as const;
|
|
122
|
-
|
|
123
|
-
export const blue = {
|
|
124
|
-
blue1: "hsl(206, 100%, 99%)",
|
|
125
|
-
blue2: "hsl(210, 100%, 98%)",
|
|
126
|
-
blue3: "hsl(209, 100%, 96%)",
|
|
127
|
-
blue4: "hsl(210, 99%, 94%)",
|
|
128
|
-
blue5: "hsl(209, 95%, 90%)",
|
|
129
|
-
blue6: "hsl(209, 81%, 84%)",
|
|
130
|
-
blue7: "hsl(208, 77%, 77%)",
|
|
131
|
-
blue8: "hsl(206, 82%, 65%)",
|
|
132
|
-
blue9: "hsl(206, 100%, 50%)",
|
|
133
|
-
blue10: "hsl(208, 100%, 47%)",
|
|
134
|
-
blue11: "hsl(211, 100%, 43%)",
|
|
135
|
-
blue12: "hsl(211, 100%, 15%)",
|
|
136
|
-
} as const;
|
|
137
|
-
|
|
138
|
-
export const blueDark = {
|
|
139
|
-
blue1: "hsl(212, 35%, 9%)",
|
|
140
|
-
blue2: "hsl(216, 50%, 12%)",
|
|
141
|
-
blue3: "hsl(214, 59%, 15%)",
|
|
142
|
-
blue4: "hsl(214, 66%, 18%)",
|
|
143
|
-
blue5: "hsl(213, 71%, 20%)",
|
|
144
|
-
blue6: "hsl(212, 77%, 23%)",
|
|
145
|
-
blue7: "hsl(211, 85%, 27%)",
|
|
146
|
-
blue8: "hsl(211, 90%, 34%)",
|
|
147
|
-
blue9: "hsl(206, 100%, 50%)",
|
|
148
|
-
blue10: "hsl(209, 100%, 61%)",
|
|
149
|
-
blue11: "hsl(210, 100%, 66%)",
|
|
150
|
-
blue12: "hsl(206, 98%, 96%)",
|
|
151
|
-
} as const;
|
|
152
|
-
|
|
153
|
-
export const yellow = {
|
|
154
|
-
yellow1: "hsl(60, 54%, 98%)",
|
|
155
|
-
yellow2: "hsl(52, 100%, 95%)",
|
|
156
|
-
yellow3: "hsl(55, 100%, 91%)",
|
|
157
|
-
yellow4: "hsl(54, 100%, 87%)",
|
|
158
|
-
yellow5: "hsl(52, 98%, 82%)",
|
|
159
|
-
yellow6: "hsl(50, 89%, 76%)",
|
|
160
|
-
yellow7: "hsl(47, 80%, 68%)",
|
|
161
|
-
yellow8: "hsl(48, 100%, 46%)",
|
|
162
|
-
yellow9: "hsl(53, 92%, 50%)",
|
|
163
|
-
yellow10: "hsl(50, 100%, 48%)",
|
|
164
|
-
yellow11: "hsl(42, 100%, 29%)",
|
|
165
|
-
yellow12: "hsl(40, 55%, 13%)",
|
|
166
|
-
} as const;
|
|
167
|
-
|
|
168
|
-
export const yellowDark = {
|
|
169
|
-
yellow1: "hsl(45, 100%, 5%)",
|
|
170
|
-
yellow2: "hsl(46, 100%, 7%)",
|
|
171
|
-
yellow3: "hsl(45, 100%, 9%)",
|
|
172
|
-
yellow4: "hsl(45, 100%, 10%)",
|
|
173
|
-
yellow5: "hsl(47, 100%, 12%)",
|
|
174
|
-
yellow6: "hsl(49, 100%, 14%)",
|
|
175
|
-
yellow7: "hsl(49, 90%, 18%)",
|
|
176
|
-
yellow8: "hsl(50, 100%, 22%)",
|
|
177
|
-
yellow9: "hsl(53, 92%, 50%)",
|
|
178
|
-
yellow10: "hsl(54, 100%, 68%)",
|
|
179
|
-
yellow11: "hsl(48, 100%, 47%)",
|
|
180
|
-
yellow12: "hsl(53, 100%, 91%)",
|
|
181
|
-
} as const;
|
|
182
|
-
|
|
183
|
-
export const blackA = {
|
|
184
|
-
blackA0: "#000000",
|
|
185
|
-
blackA1: "hsla(0, 0%, 0%, 0.01)",
|
|
186
|
-
blackA2: "hsla(0, 0%, 0%, 0.03)",
|
|
187
|
-
blackA3: "hsla(0, 0%, 0%, 0.05)",
|
|
188
|
-
blackA4: "hsla(0, 0%, 0%, 0.07)",
|
|
189
|
-
blackA5: "hsla(0, 0%, 0%, 0.09)",
|
|
190
|
-
blackA6: "hsla(0, 0%, 0%, 0.11)",
|
|
191
|
-
blackA7: "hsla(0, 0%, 0%, 0.14)",
|
|
192
|
-
blackA8: "hsla(0, 0%, 0%, 0.22)",
|
|
193
|
-
blackA9: "hsla(0, 0%, 0%, 0.44)",
|
|
194
|
-
blackA10: "hsla(0, 0%, 0%, 0.48)",
|
|
195
|
-
blackA11: "hsla(0, 0%, 0%, 0.57)",
|
|
196
|
-
blackA12: "hsla(0, 0%, 0%, 0.91)",
|
|
197
|
-
} as const;
|
|
198
|
-
|
|
199
|
-
export const whiteA = {
|
|
200
|
-
whiteA0: "#FFFFFF",
|
|
201
|
-
whiteA1: "hsla(0, 0%, 100%, 0)",
|
|
202
|
-
whiteA2: "hsla(0, 0%, 100%, 0.01)",
|
|
203
|
-
whiteA3: "hsla(0, 0%, 100%, 0.03)",
|
|
204
|
-
whiteA4: "hsla(0, 0%, 100%, 0.06)",
|
|
205
|
-
whiteA5: "hsla(0, 0%, 100%, 0.09)",
|
|
206
|
-
whiteA6: "hsla(0, 0%, 100%, 0.12)",
|
|
207
|
-
whiteA7: "hsla(0, 0%, 100%, 0.18)",
|
|
208
|
-
whiteA8: "hsla(0, 0%, 100%, 0.25)",
|
|
209
|
-
whiteA9: "hsla(0, 0%, 100%, 0.39)",
|
|
210
|
-
whiteA10: "hsla(0, 0%, 100%, 0.45)",
|
|
211
|
-
whiteA11: "hsla(0, 0%, 100%, 0.59)",
|
|
212
|
-
whiteA12: "hsla(0, 0%, 100%, 0.92)",
|
|
213
|
-
} as const;
|
|
214
|
-
|
|
215
|
-
export const opacity = {
|
|
216
|
-
opacity100: 1,
|
|
217
|
-
opacity95: 0.95,
|
|
218
|
-
opacity90: 0.9,
|
|
219
|
-
opacity85: 0.85,
|
|
220
|
-
opacity80: 0.8,
|
|
221
|
-
opacity75: 0.75,
|
|
222
|
-
opacity70: 0.7,
|
|
223
|
-
opacity65: 0.65,
|
|
224
|
-
opacity60: 0.6,
|
|
225
|
-
opacity55: 0.55,
|
|
226
|
-
opacity50: 0.5,
|
|
227
|
-
opacity45: 0.45,
|
|
228
|
-
opacity40: 0.4,
|
|
229
|
-
opacity35: 0.35,
|
|
230
|
-
opacity30: 0.3,
|
|
231
|
-
opacity25: 0.25,
|
|
232
|
-
opacity20: 0.2,
|
|
233
|
-
opacity15: 0.15,
|
|
234
|
-
opacity10: 0.1,
|
|
235
|
-
opacity5: 0.05,
|
|
236
|
-
opacity0: 0,
|
|
237
|
-
} as const;
|