@qoretechnologies/reqore 0.29.0 → 0.29.2
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/__tests__/checkbox.test.tsx +7 -12
- package/__tests__/multiselect.test.tsx +46 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +4 -2
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts +9 -2
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +61 -31
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Effect/index.d.ts +18 -4
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +67 -26
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +2 -9
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +4 -28
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +16 -2
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/divider.d.ts +1 -1
- package/dist/components/Menu/divider.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +4 -2
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.js +15 -14
- package/dist/components/MultiSelect/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/RadioGroup/index.d.ts +4 -1
- package/dist/components/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/RadioGroup/index.js +2 -2
- package/dist/components/RadioGroup/index.js.map +1 -1
- package/dist/components/Tag/index.d.ts +1 -1
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +17 -14
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Textarea/index.js +3 -3
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/constants/sizes.d.ts +7 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +8 -1
- package/dist/constants/sizes.js.map +1 -1
- package/dist/constants/theme.d.ts +4 -1
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/constants/theme.js.map +1 -1
- package/dist/helpers/colors.d.ts +5 -4
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +35 -8
- package/dist/helpers/colors.js.map +1 -1
- package/dist/hooks/useReqoreEffect.d.ts +4 -0
- package/dist/hooks/useReqoreEffect.d.ts.map +1 -0
- package/dist/hooks/useReqoreEffect.js +42 -0
- package/dist/hooks/useReqoreEffect.js.map +1 -0
- package/dist/hooks/useTheme.d.ts +1 -0
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useTheme.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +5 -3
- package/src/components/Checkbox/index.tsx +217 -38
- package/src/components/Effect/index.tsx +125 -17
- package/src/components/Icon/index.tsx +4 -52
- package/src/components/InternalPopover/index.tsx +3 -0
- package/src/components/Menu/divider.tsx +1 -1
- package/src/components/MultiSelect/index.tsx +20 -11
- package/src/components/Panel/index.tsx +3 -3
- package/src/components/RadioGroup/index.tsx +10 -2
- package/src/components/Tag/index.tsx +19 -13
- package/src/components/Textarea/index.tsx +3 -3
- package/src/constants/sizes.ts +8 -0
- package/src/constants/theme.ts +8 -1
- package/src/helpers/colors.ts +54 -11
- package/src/hooks/useReqoreEffect.ts +49 -0
- package/src/hooks/useTheme.ts +2 -1
- package/src/index.tsx +2 -0
- package/src/mock/collectionData.tsx +6 -6
- package/src/mock/multiSelect.ts +8 -0
- package/src/stories/Button/Button.stories.tsx +14 -0
- package/src/stories/Checkbox/Checkbox.stories.tsx +42 -7
- package/src/stories/Icon/Icon.stories.tsx +42 -12
- package/src/stories/Menu/Menu.stories.tsx +2 -1
- package/src/stories/MultiSelect/MultiSelect.stories.tsx +9 -2
- package/src/stories/Panel/Panel.stories.tsx +1 -1
- package/src/stories/Popover/Popover.stories.tsx +19 -2
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +98 -1
- package/src/stories/Tag/Tag.stories.tsx +2 -2
- package/src/stories/utils/args.ts +1 -1
- package/tests.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReqoreEffect.d.ts","sourceRoot":"","sources":["../../src/hooks/useReqoreEffect.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAGd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,eAAO,MAAM,eAAe,cACf,SAAS,SACb,YAAY,WACV,aAAa,KACrB,aAmCF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
exports.__esModule = true;
|
|
17
|
+
exports.useReqoreEffect = void 0;
|
|
18
|
+
var react_1 = require("react");
|
|
19
|
+
var ThemeContext_1 = __importDefault(require("../context/ThemeContext"));
|
|
20
|
+
var useReqoreEffect = function (component, theme, effect) {
|
|
21
|
+
var _theme = (0, react_1.useContext)(ThemeContext_1["default"]);
|
|
22
|
+
// Return the effect if the component is not defined in the theme
|
|
23
|
+
if (!theme[component]) {
|
|
24
|
+
return effect;
|
|
25
|
+
}
|
|
26
|
+
if (theme) {
|
|
27
|
+
// No other way to conditionally use a hook
|
|
28
|
+
_theme = theme;
|
|
29
|
+
}
|
|
30
|
+
var colors = (0, react_1.useMemo)(function () {
|
|
31
|
+
return _theme[component].gradient ? _theme.main : undefined;
|
|
32
|
+
}, [_theme, effect]);
|
|
33
|
+
var animate = (0, react_1.useMemo)(function () {
|
|
34
|
+
return _theme[component].animate;
|
|
35
|
+
}, [_theme, effect]);
|
|
36
|
+
var _effect = (0, react_1.useMemo)(function () {
|
|
37
|
+
return __assign(__assign({}, effect), { gradient: __assign({ colors: colors, animate: animate }, effect === null || effect === void 0 ? void 0 : effect.gradient) });
|
|
38
|
+
}, [colors, animate, effect]);
|
|
39
|
+
return _effect;
|
|
40
|
+
};
|
|
41
|
+
exports.useReqoreEffect = useReqoreEffect;
|
|
42
|
+
//# sourceMappingURL=useReqoreEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReqoreEffect.js","sourceRoot":"","sources":["../../src/hooks/useReqoreEffect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAA4C;AAO5C,yEAAmD;AAE5C,IAAM,eAAe,GAAG,UAC7B,SAAoB,EACpB,KAAmB,EACnB,MAAsB;IAEtB,IAAI,MAAM,GAAiB,IAAA,kBAAU,EAAe,yBAAY,CAAC,CAAC;IAElE,iEAAiE;IACjE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;QACrB,OAAO,MAAM,CAAC;KACf;IAED,IAAI,KAAK,EAAE;QACT,2CAA2C;QAC3C,MAAM,GAAG,KAAK,CAAC;KAChB;IAED,IAAM,MAAM,GAAoB,IAAA,eAAO,EAAC;QACtC,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9D,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAErB,IAAM,OAAO,GAA0C,IAAA,eAAO,EAAC;QAC7D,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;IACnC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAErB,IAAM,OAAO,GAAG,IAAA,eAAO,EAAC;QACtB,6BACK,MAAM,KACT,QAAQ,aACN,MAAM,QAAA,EACN,OAAO,SAAA,IAGJ,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,KAErB;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAE9B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAvCW,QAAA,eAAe,mBAuC1B"}
|
package/dist/hooks/useTheme.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface IReqoreCustomTheme extends Partial<Omit<IReqoreTheme, 'main' |
|
|
|
6
6
|
color?: TReqoreEffectColor;
|
|
7
7
|
dim?: boolean;
|
|
8
8
|
};
|
|
9
|
+
gradient?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const useReqoreTheme: (element?: string, customTheme?: IReqoreCustomTheme, intent?: TReqoreIntent) => IReqoreTheme;
|
|
11
12
|
//# sourceMappingURL=useTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIjE,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACtF,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,kBAAkB,CAAC;QAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CAAC;
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIjE,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACtF,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,kBAAkB,CAAC;QAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,cAAc,aACf,MAAM,gBACH,kBAAkB,WACtB,aAAa,KACrB,YAsBF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAmC;AACnC,+BAAmC;AAGnC,yEAAmD;AACnD,4CAAyE;
|
|
1
|
+
{"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAmC;AACnC,+BAAmC;AAGnC,yEAAmD;AACnD,4CAAyE;AAWlE,IAAM,cAAc,GAAG,UAC5B,OAAgB,EAChB,WAAoC,EACpC,MAAsB;;IADtB,4BAAA,EAAA,gBAAoC;IAGpC,IAAM,KAAK,GAAiB,IAAA,kBAAU,EAAe,yBAAY,CAAC,CAAC;IAEnE,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,KAAK,CAAC;KACd;IAED,IAAI,YAAY,GAAuB,IAAA,kBAAS,EAAC,WAAW,CAAC,CAAC;IAE9D,IAAI,YAAY,CAAC,IAAI,EAAE;QACrB,YAAY,CAAC,IAAI,GAAG,IAAA,gCAAuB,EAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;KACtE;IAED,IAAI,MAAA,YAAY,CAAC,IAAI,0CAAE,KAAK,EAAE;QAC5B,YAAY,CAAC,IAAI,CAAC,KAAK,GAAG,IAAA,gCAAuB,EAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAClF;IAED,IAAI,OAAO,KAAK,MAAM,IAAI,MAAM,EAAE;QAChC,YAAY,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;KAC3C;IAED,OAAO,IAAA,oBAAW,EAAC,OAAO,EAAE,KAAK,EAAE,YAAY,CAAiB,CAAC;AACnE,CAAC,CAAC;AA1BW,QAAA,cAAc,kBA0BzB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export { default as ReqoreTextarea } from './components/Textarea';
|
|
|
46
46
|
export { TimeAgo as ReqoreTimeAgo } from './components/TimeAgo';
|
|
47
47
|
export { ReqoreTree } from './components/Tree';
|
|
48
48
|
export { Colors as ReqoreColors } from './constants/colors';
|
|
49
|
+
export { ReqoreSizes } from './constants/sizes';
|
|
50
|
+
export { ReqoreIntents } from './constants/theme';
|
|
49
51
|
export { default as ReqoreNotifications } from './containers/ReqoreProvider';
|
|
50
52
|
export { default as ReqoreUIProvider } from './containers/UIProvider';
|
|
51
53
|
export { default as ReqoreContext } from './context/ReqoreContext';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAA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AAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
12
12
|
}));
|
|
13
13
|
exports.__esModule = true;
|
|
14
14
|
exports.ReqoreTabsContent = exports.ReqoreTabs = exports.ReqoreTable = exports.ReqoreSpacer = exports.ReqoreSidebar = exports.ReqoreRadioGroup = exports.ReqorePopover = exports.ReqoreParagraph = exports.ReqoreP = exports.ReqorePanel = exports.ReqoreNotification = exports.ReqoreNotificationsWrapper = exports.ReqoreNavbarItem = exports.ReqoreNavbarGroup = exports.ReqoreNavbarDivider = exports.ReqoreHeader = exports.ReqoreFooter = exports.ReqoreMultiSelect = exports.ReqoreModal = exports.ReqoreMessage = exports.ReqoreMenuItem = exports.ReqoreMenuDivider = exports.ReqoreMenu = exports.ReqoreLayoutContent = exports.ReqoreInput = exports.ReqoreIcon = exports.ReqoreHeading = exports.ReqoreH6 = exports.ReqoreH5 = exports.ReqoreH4 = exports.ReqoreH3 = exports.ReqoreH2 = exports.ReqoreH1 = exports.ReqoreTextEffect = exports.ReqoreEffect = exports.ReqoreDropdownItem = exports.ReqoreDropdownDivider = exports.ReqoreDropdown = exports.ReqoreDrawer = exports.ReqoreControlGroup = exports.ReqoreContent = exports.ReqoreCommentFeed = exports.ReqoreComment = exports.ReqoreColumn = exports.ReqoreColumns = exports.ReqoreCollection = exports.ReqoreCheckbox = exports.ReqoreButton = exports.ReqoreBreadcrumbsItem = exports.ReqoreBreadcrumbs = void 0;
|
|
15
|
-
exports.useReqoreTheme = exports.useReqore = exports.useLatestZIndex = exports.ReqoreThemeContext = exports.ReqoreContext = exports.ReqoreUIProvider = exports.ReqoreNotifications = exports.ReqoreColors = exports.ReqoreTree = exports.ReqoreTimeAgo = exports.ReqoreTextarea = exports.ReqoreTagGroup = exports.ReqoreTag = exports.ReqoreTabsList = exports.ReqoreTabsListItem = void 0;
|
|
15
|
+
exports.useReqoreTheme = exports.useReqore = exports.useLatestZIndex = exports.ReqoreThemeContext = exports.ReqoreContext = exports.ReqoreUIProvider = exports.ReqoreNotifications = exports.ReqoreIntents = exports.ReqoreSizes = exports.ReqoreColors = exports.ReqoreTree = exports.ReqoreTimeAgo = exports.ReqoreTextarea = exports.ReqoreTagGroup = exports.ReqoreTag = exports.ReqoreTabsList = exports.ReqoreTabsListItem = void 0;
|
|
16
16
|
var Breadcrumbs_1 = require("./components/Breadcrumbs");
|
|
17
17
|
__createBinding(exports, Breadcrumbs_1, "default", "ReqoreBreadcrumbs");
|
|
18
18
|
var item_1 = require("./components/Breadcrumbs/item");
|
|
@@ -119,6 +119,10 @@ var Tree_1 = require("./components/Tree");
|
|
|
119
119
|
__createBinding(exports, Tree_1, "ReqoreTree");
|
|
120
120
|
var colors_1 = require("./constants/colors");
|
|
121
121
|
__createBinding(exports, colors_1, "Colors", "ReqoreColors");
|
|
122
|
+
var sizes_1 = require("./constants/sizes");
|
|
123
|
+
__createBinding(exports, sizes_1, "ReqoreSizes");
|
|
124
|
+
var theme_1 = require("./constants/theme");
|
|
125
|
+
__createBinding(exports, theme_1, "ReqoreIntents");
|
|
122
126
|
var ReqoreProvider_1 = require("./containers/ReqoreProvider");
|
|
123
127
|
__createBinding(exports, ReqoreProvider_1, "default", "ReqoreNotifications");
|
|
124
128
|
var UIProvider_1 = require("./containers/UIProvider");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAwE;AAA/D,wEAA4B;AACrC,sDAAiF;AAAxE,qEAAgC;AACzC,8CAA8D;AAArD,8DAAuB;AAChC,kDAAkE;AAAzD,kEAAyB;AAClC,sDAA2D;AAAlD,2DAAgB;AACzB,gDAAqD;AAA5C,qDAAa;AACtB,sDAA2D;AAAlD,mDAAY;AACrB,gDAAqD;AAA5C,qDAAa;AACtB,wDAA6D;AAApD,6DAAiB;AAC1B,gDAAgE;AAAvD,gEAAwB;AACjC,0DAA0E;AAAjE,0EAA6B;AACtC,8CAAmD;AAA1C,mDAAY;AACrB,kDAAkE;AAAzD,kEAAyB;AAClC,mDAAuF;AAA9E,0DAAqB;AAAE,uDAAkB;AAClD,8CAAqE;AAA5D,mDAAY;AAAE,uDAAgB;AACvC,8CAQ6B;AAP3B,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,oDAAa;AAEf,0CAA0D;AAAjD,0DAAqB;AAC9B,4CAA4D;AAAnD,4DAAsB;AAC/B,uDAA6E;AAApE,sEAA8B;AACvC,0CAA0D;AAAjD,0DA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qB;AAC9B,qDAAyE;AAAhE,oEAA4B;AACrC,+CAAuE;AAA9D,kEAA6B;AACtC,+CAAmE;AAA1D,8DAAyB;AAClC,wCAAwD;AAA/C,wDAAoB;AAC7B,gDAAmE;AAA1D,+DAAyB;AAClC,kDAAkE;AAAzD,kEAAyB;AAClC,gDAAgE;AAAvD,gEAAwB;AACjC,0CAA+C;AAAtC,+CAAU;AACnB,6CAA4D;AAAnD,6DAAsB;AAC/B,2CAAgD;AAAvC,iDAAW;AACpB,2CAAkD;AAAzC,mDAAa;AACtB,8DAA6E;AAApE,6EAA8B;AACvC,sDAAsE;AAA7D,sEAA2B;AACpC,yDAAmE;AAA1D,sEAAwB;AACjC,uDAAuE;AAA9D,0EAA6B;AACtC,2DAAqE;AAA5D,0EAA0B;AACnC,+CAA8C;AAArC,mDAAS;AAClB,6CAAkD;AAAzC,uDAAc"}
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import ReqoreContext from '../../context/ReqoreContext';
|
|
|
13
13
|
import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
|
|
14
14
|
import { getOneLessSize } from '../../helpers/utils';
|
|
15
15
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
16
|
+
import { useReqoreEffect } from '../../hooks/useReqoreEffect';
|
|
16
17
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
17
18
|
import { useTooltip } from '../../hooks/useTooltip';
|
|
18
19
|
import {
|
|
@@ -304,7 +305,7 @@ export const ButtonBadge = memo((props: IReqoreButtonBadgeProps) => {
|
|
|
304
305
|
<ReqoreTag
|
|
305
306
|
key={key}
|
|
306
307
|
size={getOneLessSize(size)}
|
|
307
|
-
|
|
308
|
+
asBadge
|
|
308
309
|
color={color}
|
|
309
310
|
className='reqore-button-badge'
|
|
310
311
|
minimal={!(content as IReqoreTagProps)?.effect?.gradient}
|
|
@@ -372,7 +373,8 @@ const ReqoreButton = memo(
|
|
|
372
373
|
) => {
|
|
373
374
|
const { targetRef } = useCombinedRefs(ref);
|
|
374
375
|
const { animations } = useContext(ReqoreContext);
|
|
375
|
-
const theme
|
|
376
|
+
const theme = useReqoreTheme('main', customTheme, intent);
|
|
377
|
+
const fixedEffect = useReqoreEffect('buttons', theme, effect);
|
|
376
378
|
|
|
377
379
|
/* A custom hook that is used to add a tooltip to the button. */
|
|
378
380
|
useTooltip(targetRef.current, tooltip);
|
|
@@ -391,7 +393,7 @@ const ReqoreButton = memo(
|
|
|
391
393
|
{...rest}
|
|
392
394
|
effect={{
|
|
393
395
|
interactive: !readOnly && !rest.disabled,
|
|
394
|
-
...
|
|
396
|
+
...fixedEffect,
|
|
395
397
|
}}
|
|
396
398
|
as='button'
|
|
397
399
|
theme={theme}
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
import { rgba } from 'polished';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
3
|
+
import { useMeasure } from 'react-use';
|
|
3
4
|
import styled, { css } from 'styled-components';
|
|
4
5
|
import { PADDING_FROM_SIZE, SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
5
6
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
changeLightness,
|
|
9
|
+
getNthGradientColor,
|
|
10
|
+
getReadableColor,
|
|
11
|
+
getReadableColorFrom,
|
|
12
|
+
} from '../../helpers/colors';
|
|
13
|
+
import { getOneLessSize } from '../../helpers/utils';
|
|
7
14
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
15
|
+
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
8
16
|
import { useTooltip } from '../../hooks/useTooltip';
|
|
9
17
|
import { DisabledElement, ReadOnlyElement } from '../../styles';
|
|
10
18
|
import {
|
|
11
19
|
IReqoreDisabled,
|
|
20
|
+
IReqoreIntent,
|
|
12
21
|
IReqoreReadOnly,
|
|
22
|
+
IWithReqoreCustomTheme,
|
|
13
23
|
IWithReqoreEffect,
|
|
14
24
|
TReqoreTooltipProp,
|
|
15
25
|
} from '../../types/global';
|
|
16
26
|
import { IReqoreIconName } from '../../types/icons';
|
|
17
|
-
import { ReqoreTextEffect } from '../Effect';
|
|
18
|
-
import ReqoreIcon from '../Icon';
|
|
27
|
+
import { IReqoreEffect, ReqoreTextEffect, StyledEffect, StyledTextEffect } from '../Effect';
|
|
28
|
+
import ReqoreIcon, { StyledIconWrapper } from '../Icon';
|
|
29
|
+
import { ReqoreSpacer } from '../Spacer';
|
|
19
30
|
|
|
20
31
|
export interface IReqoreCheckboxProps
|
|
21
32
|
extends React.HTMLAttributes<HTMLDivElement>,
|
|
22
33
|
IReqoreDisabled,
|
|
23
34
|
IReqoreReadOnly,
|
|
24
|
-
IWithReqoreEffect
|
|
35
|
+
IWithReqoreEffect,
|
|
36
|
+
IReqoreIntent,
|
|
37
|
+
IWithReqoreCustomTheme {
|
|
25
38
|
label?: string;
|
|
26
39
|
labelDetail?: any;
|
|
27
40
|
labelDetailPosition?: 'left' | 'right';
|
|
@@ -35,6 +48,12 @@ export interface IReqoreCheckboxProps
|
|
|
35
48
|
uncheckedIcon?: IReqoreIconName;
|
|
36
49
|
checkedIcon?: IReqoreIconName;
|
|
37
50
|
image?: string;
|
|
51
|
+
onText?: string | number;
|
|
52
|
+
offText?: string | number;
|
|
53
|
+
switchTextEffect?: IReqoreEffect;
|
|
54
|
+
labelEffect?: IReqoreEffect;
|
|
55
|
+
margin?: 'left' | 'right' | 'both' | 'none';
|
|
56
|
+
wrapLabel?: boolean;
|
|
38
57
|
}
|
|
39
58
|
|
|
40
59
|
export interface IReqoreCheckboxStyle extends IReqoreCheckboxProps {
|
|
@@ -48,38 +67,64 @@ const StyledSwitchToggle = styled.div`
|
|
|
48
67
|
align-items: center;
|
|
49
68
|
justify-content: center;
|
|
50
69
|
position: absolute;
|
|
51
|
-
height: ${({ size }) => SIZE_TO_PX[size] -
|
|
52
|
-
width: ${({ size }) => SIZE_TO_PX[size] -
|
|
70
|
+
height: ${({ size }) => SIZE_TO_PX[size] - 4}px;
|
|
71
|
+
width: ${({ size, width }) => width || SIZE_TO_PX[size] - 4}px;
|
|
53
72
|
top: 50%;
|
|
54
73
|
transform: translateY(-50%);
|
|
55
|
-
left: ${({ checked, size }) =>
|
|
56
|
-
!checked ? '
|
|
57
|
-
border-radius:
|
|
58
|
-
background-color: ${({ theme, checked, transparent }) =>
|
|
74
|
+
left: ${({ checked, size, width }) =>
|
|
75
|
+
!checked ? '1px' : `calc(100% - ${width || SIZE_TO_PX[size] - 4}px - 1px)`};
|
|
76
|
+
border-radius: 50px;
|
|
77
|
+
background-color: ${({ theme, checked, transparent, parentEffect }) =>
|
|
59
78
|
transparent
|
|
60
79
|
? 'transparent'
|
|
61
80
|
: !checked
|
|
62
|
-
?
|
|
63
|
-
|
|
81
|
+
? parentEffect?.gradient
|
|
82
|
+
? changeLightness(getNthGradientColor(theme, parentEffect?.gradient?.colors, 1), 0.2)
|
|
83
|
+
: changeLightness(theme.main, 0.2)
|
|
84
|
+
: parentEffect?.gradient
|
|
85
|
+
? changeLightness(getNthGradientColor(theme, parentEffect?.gradient?.colors, 2), 0.2)
|
|
86
|
+
: changeLightness(theme.main, 0.25)};
|
|
64
87
|
`;
|
|
65
88
|
|
|
66
|
-
const StyledSwitch = styled
|
|
89
|
+
const StyledSwitch = styled(StyledEffect)<IReqoreCheckboxStyle>`
|
|
67
90
|
transition: all 0.2s ease-out;
|
|
68
91
|
position: relative;
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
flex-shrink: 0;
|
|
69
96
|
|
|
70
|
-
height: ${({ size }) => SIZE_TO_PX[size]
|
|
71
|
-
width: ${({ size }) => SIZE_TO_PX[size] * 1.8}px;
|
|
97
|
+
height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
98
|
+
min-width: ${({ size }) => SIZE_TO_PX[size] * 1.8}px;
|
|
72
99
|
|
|
73
|
-
border: 1px solid
|
|
74
|
-
${({ theme, checked }) =>
|
|
75
|
-
rgba(getReadableColor(theme, undefined, undefined), checked ? 0.8 : 0.2)};
|
|
100
|
+
border: 1px solid ${({ theme, checked }) => changeLightness(theme.main, checked ? 0.25 : 0.2)};
|
|
76
101
|
border-radius: 50px;
|
|
77
102
|
|
|
78
|
-
|
|
79
|
-
|
|
103
|
+
background-color: ${({ theme }) => rgba(changeLightness(theme.main, 0.3), 0.1)};
|
|
104
|
+
|
|
105
|
+
${StyledIconWrapper} {
|
|
106
|
+
z-index: 1;
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
const StyledSwitchTextWrapper = styled(StyledTextEffect)`
|
|
111
|
+
margin: 0 ${({ size }) => PADDING_FROM_SIZE[size]}px;
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
z-index: 1;
|
|
116
|
+
`;
|
|
117
|
+
|
|
118
|
+
const StyledOnSwitchText = styled(StyledSwitchTextWrapper)<IReqoreCheckboxStyle>`
|
|
119
|
+
color: ${({ theme, checked, parentHasGradient }) =>
|
|
120
|
+
!parentHasGradient &&
|
|
121
|
+
getReadableColorFrom(checked ? changeLightness(theme.main, 0.25) : theme.originalMain)};
|
|
122
|
+
`;
|
|
80
123
|
|
|
81
|
-
|
|
82
|
-
|
|
124
|
+
const StyledOffSwitchText = styled(StyledSwitchTextWrapper)<IReqoreCheckboxStyle>`
|
|
125
|
+
color: ${({ theme, checked, parentHasGradient }) =>
|
|
126
|
+
!parentHasGradient &&
|
|
127
|
+
getReadableColorFrom(checked ? theme.originalMain : changeLightness(theme.main, 0.2))};
|
|
83
128
|
`;
|
|
84
129
|
|
|
85
130
|
const StyledCheckbox = styled.div<IReqoreCheckboxStyle>`
|
|
@@ -106,14 +151,15 @@ const StyledCheckbox = styled.div<IReqoreCheckboxStyle>`
|
|
|
106
151
|
${ReadOnlyElement};
|
|
107
152
|
`}
|
|
108
153
|
|
|
109
|
-
color: ${({ theme, checked }) =>
|
|
154
|
+
color: ${({ theme, checked }) =>
|
|
155
|
+
getReadableColor(theme, undefined, undefined, !checked, theme.originalMain)};
|
|
110
156
|
|
|
111
157
|
&:hover {
|
|
112
|
-
color: ${({ theme }) =>
|
|
158
|
+
color: ${({ theme }) =>
|
|
159
|
+
getReadableColor(theme, undefined, undefined, false, theme.originalMain)};
|
|
113
160
|
|
|
114
161
|
> ${StyledSwitch} {
|
|
115
|
-
border-color: ${({ theme, checked }) =>
|
|
116
|
-
rgba(getReadableColor(theme, undefined, undefined, false), checked ? 0.8 : 0.5)};
|
|
162
|
+
border-color: ${({ theme, checked }) => changeLightness(theme.main, checked ? 0.3 : 0.25)};
|
|
117
163
|
}
|
|
118
164
|
}
|
|
119
165
|
`;
|
|
@@ -125,72 +171,205 @@ const Checkbox = forwardRef<HTMLDivElement, IReqoreCheckboxProps>(
|
|
|
125
171
|
labelDetail,
|
|
126
172
|
labelDetailPosition = 'right',
|
|
127
173
|
size = 'normal',
|
|
174
|
+
margin = 'left',
|
|
128
175
|
checked,
|
|
129
176
|
disabled,
|
|
130
177
|
className,
|
|
131
178
|
labelPosition = 'right',
|
|
132
179
|
tooltip,
|
|
133
180
|
asSwitch,
|
|
134
|
-
uncheckedIcon
|
|
135
|
-
checkedIcon
|
|
181
|
+
uncheckedIcon,
|
|
182
|
+
checkedIcon,
|
|
136
183
|
readOnly,
|
|
137
|
-
|
|
184
|
+
labelEffect,
|
|
185
|
+
switchTextEffect,
|
|
138
186
|
image,
|
|
187
|
+
onText,
|
|
188
|
+
offText,
|
|
189
|
+
intent,
|
|
190
|
+
effect,
|
|
191
|
+
customTheme,
|
|
192
|
+
wrapLabel,
|
|
139
193
|
...rest
|
|
140
194
|
}: IReqoreCheckboxProps,
|
|
141
195
|
ref
|
|
142
196
|
) => {
|
|
143
197
|
const { targetRef } = useCombinedRefs(ref);
|
|
198
|
+
const [offRef, { width: offWidth }] = useMeasure();
|
|
199
|
+
const [onRef, { width: onWidth }] = useMeasure();
|
|
200
|
+
const theme = useReqoreTheme('main', customTheme, intent);
|
|
144
201
|
|
|
145
202
|
useTooltip(targetRef.current, tooltip);
|
|
146
203
|
|
|
204
|
+
const width = useMemo(() => {
|
|
205
|
+
if ((!image && !onText) || !offText) return undefined;
|
|
206
|
+
|
|
207
|
+
const selectedWidth = checked ? onWidth : offWidth;
|
|
208
|
+
|
|
209
|
+
return selectedWidth + PADDING_FROM_SIZE[size] * 2;
|
|
210
|
+
}, [checked, offWidth, onWidth, size]);
|
|
211
|
+
|
|
212
|
+
const hasText = useMemo(() => {
|
|
213
|
+
return !!onText || !!offText;
|
|
214
|
+
}, [onText, offText]);
|
|
215
|
+
|
|
147
216
|
return (
|
|
148
217
|
<StyledCheckbox
|
|
149
218
|
{...rest}
|
|
150
219
|
ref={targetRef}
|
|
220
|
+
theme={theme}
|
|
151
221
|
size={size}
|
|
152
222
|
disabled={disabled}
|
|
153
223
|
checked={checked}
|
|
154
224
|
readOnly={readOnly}
|
|
155
225
|
className={`${className || ''} reqore-checkbox reqore-control`}
|
|
156
226
|
>
|
|
227
|
+
{margin === 'left' || margin === 'both' ? (
|
|
228
|
+
<ReqoreSpacer width={PADDING_FROM_SIZE[size]} />
|
|
229
|
+
) : null}
|
|
157
230
|
{label && labelPosition === 'left' ? (
|
|
158
231
|
<>
|
|
159
232
|
{labelDetailPosition === 'left' && labelDetail}
|
|
160
233
|
<ReqoreTextEffect
|
|
161
|
-
|
|
234
|
+
active={checked}
|
|
235
|
+
effect={{
|
|
236
|
+
...labelEffect,
|
|
237
|
+
interactive: !disabled && !readOnly && !checked,
|
|
238
|
+
noWrap: !wrapLabel,
|
|
239
|
+
}}
|
|
162
240
|
>
|
|
163
241
|
{label}
|
|
164
242
|
</ReqoreTextEffect>
|
|
165
243
|
{labelDetailPosition === 'right' && labelDetail}
|
|
244
|
+
<ReqoreSpacer width={PADDING_FROM_SIZE[size]} />
|
|
166
245
|
</>
|
|
167
246
|
) : null}
|
|
168
247
|
{asSwitch ? (
|
|
169
|
-
<StyledSwitch
|
|
170
|
-
|
|
171
|
-
|
|
248
|
+
<StyledSwitch
|
|
249
|
+
size={size}
|
|
250
|
+
labelPosition={labelPosition}
|
|
251
|
+
checked={checked}
|
|
252
|
+
theme={theme}
|
|
253
|
+
as='div'
|
|
254
|
+
effect={
|
|
255
|
+
{
|
|
256
|
+
interactive: !disabled && !readOnly,
|
|
257
|
+
...effect,
|
|
258
|
+
} as IReqoreEffect
|
|
259
|
+
}
|
|
260
|
+
>
|
|
261
|
+
<>
|
|
262
|
+
{offText || offText === 0 ? (
|
|
263
|
+
<StyledOffSwitchText
|
|
264
|
+
ref={offRef}
|
|
265
|
+
size={size}
|
|
266
|
+
theme={theme}
|
|
267
|
+
checked={checked}
|
|
268
|
+
parentHasGradient={!!effect?.gradient}
|
|
269
|
+
effect={
|
|
270
|
+
{
|
|
271
|
+
uppercase: true,
|
|
272
|
+
textSize: getOneLessSize(size),
|
|
273
|
+
weight: 'bold',
|
|
274
|
+
...switchTextEffect,
|
|
275
|
+
opacity: checked ? 0.8 : 1,
|
|
276
|
+
} as IReqoreEffect
|
|
277
|
+
}
|
|
278
|
+
>
|
|
279
|
+
{image || uncheckedIcon ? (
|
|
280
|
+
<ReqoreIcon
|
|
281
|
+
size={size}
|
|
282
|
+
image={image}
|
|
283
|
+
icon={uncheckedIcon}
|
|
284
|
+
effect={{ grayscale: true }}
|
|
285
|
+
margin={offText ? 'right' : undefined}
|
|
286
|
+
/>
|
|
287
|
+
) : null}
|
|
288
|
+
{offText}
|
|
289
|
+
</StyledOffSwitchText>
|
|
290
|
+
) : null}
|
|
291
|
+
{onText || onText === 0 ? (
|
|
292
|
+
<StyledOnSwitchText
|
|
293
|
+
ref={onRef}
|
|
294
|
+
size={size}
|
|
295
|
+
theme={theme}
|
|
296
|
+
checked={checked}
|
|
297
|
+
parentHasGradient={!!effect?.gradient}
|
|
298
|
+
effect={
|
|
299
|
+
{
|
|
300
|
+
uppercase: true,
|
|
301
|
+
textSize: getOneLessSize(size),
|
|
302
|
+
weight: 'thick',
|
|
303
|
+
...switchTextEffect,
|
|
304
|
+
opacity: checked ? 1 : 0.3,
|
|
305
|
+
} as IReqoreEffect
|
|
306
|
+
}
|
|
307
|
+
>
|
|
308
|
+
{image || checkedIcon ? (
|
|
309
|
+
<ReqoreIcon
|
|
310
|
+
size={size}
|
|
311
|
+
image={image}
|
|
312
|
+
margin={onText ? 'right' : undefined}
|
|
313
|
+
icon={checkedIcon}
|
|
314
|
+
/>
|
|
315
|
+
) : null}
|
|
316
|
+
{onText}
|
|
317
|
+
</StyledOnSwitchText>
|
|
318
|
+
) : null}
|
|
319
|
+
</>
|
|
320
|
+
<StyledSwitchToggle
|
|
321
|
+
size={size}
|
|
322
|
+
checked={checked}
|
|
323
|
+
width={width}
|
|
324
|
+
theme={theme}
|
|
325
|
+
parentEffect={effect}
|
|
326
|
+
transparent={(image || checkedIcon) && !hasText}
|
|
327
|
+
>
|
|
328
|
+
{!onText && !offText ? (
|
|
329
|
+
<ReqoreIcon
|
|
330
|
+
size={size}
|
|
331
|
+
image={image}
|
|
332
|
+
icon={checked ? checkedIcon : uncheckedIcon}
|
|
333
|
+
effect={{ grayscale: !checked, opacity: checked ? 1 : 0.5 }}
|
|
334
|
+
/>
|
|
335
|
+
) : null}
|
|
172
336
|
</StyledSwitchToggle>
|
|
173
337
|
</StyledSwitch>
|
|
174
338
|
) : (
|
|
175
339
|
<ReqoreIcon
|
|
176
340
|
size={size}
|
|
177
|
-
icon={
|
|
341
|
+
icon={
|
|
342
|
+
!image
|
|
343
|
+
? checked
|
|
344
|
+
? checkedIcon || 'CheckboxCircleFill'
|
|
345
|
+
: uncheckedIcon || 'CheckboxBlankCircleLine'
|
|
346
|
+
: undefined
|
|
347
|
+
}
|
|
178
348
|
image={image}
|
|
179
|
-
|
|
180
|
-
|
|
349
|
+
effect={{ grayscale: image ? !checked : undefined, opacity: checked ? 1 : 0.5 }}
|
|
350
|
+
intent={intent}
|
|
181
351
|
/>
|
|
182
352
|
)}
|
|
183
353
|
{label && labelPosition === 'right' ? (
|
|
184
354
|
<>
|
|
355
|
+
<ReqoreSpacer width={PADDING_FROM_SIZE[size]} />
|
|
185
356
|
{labelDetailPosition === 'left' && labelDetail}
|
|
186
357
|
<ReqoreTextEffect
|
|
187
|
-
|
|
358
|
+
active={checked}
|
|
359
|
+
effect={{
|
|
360
|
+
...labelEffect,
|
|
361
|
+
interactive: !disabled && !readOnly && !checked,
|
|
362
|
+
noWrap: !wrapLabel,
|
|
363
|
+
}}
|
|
188
364
|
>
|
|
189
365
|
{label}
|
|
190
366
|
</ReqoreTextEffect>
|
|
191
367
|
{labelDetailPosition === 'right' && labelDetail}
|
|
192
368
|
</>
|
|
193
369
|
) : null}
|
|
370
|
+
{margin === 'right' || margin === 'both' ? (
|
|
371
|
+
<ReqoreSpacer width={PADDING_FROM_SIZE[size]} />
|
|
372
|
+
) : null}
|
|
194
373
|
</StyledCheckbox>
|
|
195
374
|
);
|
|
196
375
|
}
|