@veracity/vui 0.5.2 → 0.6.1
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/button/button.js +1 -1
- package/button/buttonIcon.js +15 -2
- package/button/buttonText.js +15 -2
- package/button/context.d.ts +2 -2
- package/button/context.js +3 -3
- package/buttonGroup/context.d.ts +2 -2
- package/buttonGroup/context.js +3 -3
- package/checkbox/checkbox.js +1 -1
- package/checkbox/context.d.ts +2 -2
- package/checkbox/context.js +3 -3
- package/core/links.d.ts +3 -2
- package/core/links.js +47 -41
- package/dialog/dialogBody.js +13 -1
- package/dialog/dialogCancelButton.js +14 -1
- package/dialog/dialogCloseButton.js +14 -1
- package/dialog/dialogFooter.js +2 -2
- package/dialog/dialogHeader.js +2 -2
- package/dialog/dialogIcon.js +14 -1
- package/dialog/dialogSubmitButton.js +14 -1
- package/dialog/dialogTitle.js +14 -1
- package/footer/footerColumn.js +3 -2
- package/footer/footerContent.js +14 -1
- package/footer/footerHeading.js +14 -1
- package/footer/footerLink.js +14 -1
- package/footer/footerRow.js +14 -1
- package/footer/footerSection.js +2 -2
- package/footer/footerTrademark.js +3 -2
- package/header/headerAccount.js +3 -3
- package/header/headerAccountUserInfo.js +4 -3
- package/header/headerContent.js +14 -1
- package/header/headerCreateAccount.js +3 -2
- package/header/headerDivider.js +14 -1
- package/header/headerLogo.js +3 -2
- package/header/headerMainLinks.js +3 -2
- package/header/headerMobileContent.js +13 -1
- package/header/headerMobileToggle.js +13 -1
- package/header/headerNotifications.js +3 -2
- package/header/headerServices.js +1 -1
- package/header/headerServicesMessage.js +3 -2
- package/header/headerSignIn.js +3 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/input/context.d.ts +2 -2
- package/input/context.js +3 -3
- package/input/input.js +1 -1
- package/input/inputIcon.js +15 -2
- package/input/inputInput.js +14 -2
- package/link/context.d.ts +2 -2
- package/link/context.js +3 -3
- package/link/linkIcon.js +15 -2
- package/link/linkText.js +15 -2
- package/list/context.d.ts +2 -2
- package/list/context.js +3 -3
- package/list/listDivider.js +15 -2
- package/list/listHeading.js +15 -2
- package/list/listIcon.js +15 -2
- package/list/listItem.js +3 -3
- package/list/listText.js +15 -2
- package/menu/menuButton.js +15 -2
- package/menu/menuItem.js +2 -2
- package/menu/menuList.js +4 -3
- package/modal/modalBackdrop.js +13 -1
- package/modal/modalContent.js +13 -1
- package/notification/context.d.ts +2 -2
- package/notification/context.js +3 -3
- package/notification/notificationButton.js +16 -3
- package/notification/notificationIcon.js +16 -3
- package/notification/notificationText.js +15 -2
- package/notification/notificationTitle.js +15 -2
- package/package.json +1 -1
- package/pagination/context.d.ts +4 -0
- package/pagination/context.js +23 -0
- package/pagination/helpers.d.ts +3 -0
- package/pagination/helpers.js +56 -0
- package/pagination/index.d.ts +13 -0
- package/pagination/index.js +31 -0
- package/pagination/pagination.d.ts +21 -0
- package/pagination/pagination.js +70 -0
- package/pagination/pagination.types.d.ts +31 -0
- package/pagination/pagination.types.js +2 -0
- package/pagination/paginationButton.d.ts +4 -0
- package/pagination/paginationButton.js +51 -0
- package/pagination/paginationEllipsis.d.ts +4 -0
- package/pagination/paginationEllipsis.js +41 -0
- package/pagination/paginationGoToPage.d.ts +4 -0
- package/pagination/paginationGoToPage.js +53 -0
- package/pagination/paginationNavigation.d.ts +4 -0
- package/pagination/paginationNavigation.js +68 -0
- package/pagination/paginationPrevNext.d.ts +4 -0
- package/pagination/paginationPrevNext.js +49 -0
- package/pagination/paginationResults.d.ts +4 -0
- package/pagination/paginationResults.js +42 -0
- package/pagination/theme.d.ts +8 -0
- package/pagination/theme.js +14 -0
- package/pagination/usePagination.d.ts +14 -0
- package/pagination/usePagination.js +58 -0
- package/pagination/usePagination.types.d.ts +12 -0
- package/pagination/usePagination.types.js +2 -0
- package/popover/popoverContent.js +2 -2
- package/popover/popoverTrigger.js +3 -3
- package/radio/context.d.ts +2 -2
- package/radio/context.js +3 -3
- package/radio/radio.js +1 -1
- package/spinner/consts.d.ts +0 -12
- package/spinner/consts.js +4 -8
- package/spinner/spinner.js +2 -2
- package/switch/context.d.ts +2 -2
- package/switch/context.js +3 -3
- package/switch/switchButton.js +2 -2
- package/switch/switchLabel.js +15 -2
- package/tag/context.d.ts +2 -2
- package/tag/context.js +3 -3
- package/tag/tagButton.js +16 -3
- package/tag/tagIcon.js +15 -2
- package/tag/tagText.js +15 -2
- package/textarea/textarea.js +1 -1
- package/theme/components.d.ts +7 -0
- package/theme/components.js +20 -18
- package/theme/defaultTheme.d.ts +7 -0
- package/utils/react.d.ts +16 -2
- package/utils/react.js +41 -3
|
@@ -34,15 +34,15 @@ var context_1 = require("./context");
|
|
|
34
34
|
/** Displays provided content in an overlaying wrapper. */
|
|
35
35
|
exports.PopoverContent = (0, core_1.vui)(function (props, ref) {
|
|
36
36
|
var _a;
|
|
37
|
+
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
37
38
|
var popoverProps = (_a = (0, context_1.usePopoverContext)()) !== null && _a !== void 0 ? _a : {};
|
|
38
39
|
var isLazy = popoverProps.isLazy, isOpen = popoverProps.isOpen, setPopper = popoverProps.setPopper;
|
|
39
|
-
var children = props.children, rest = __rest(props, ["children"]);
|
|
40
40
|
var styles = (0, core_1.useStyleConfig)('Popover', __assign(__assign({}, popoverProps), props));
|
|
41
41
|
var shouldRenderChildren = isLazy ? isOpen : true;
|
|
42
42
|
return (
|
|
43
43
|
// Wrapping div prevents an error thrown when conditionally unmounting this component
|
|
44
44
|
react_1.default.createElement("div", null,
|
|
45
|
-
react_1.default.createElement(box_1.default, __assign({ bg: "white", borderRadius: "md", boxShadow: "2", className:
|
|
45
|
+
react_1.default.createElement(box_1.default, __assign({ bg: "white", borderRadius: "md", boxShadow: "2", className: (0, utils_1.cs)('vui-popoverContent', className), overflowY: "auto", ref: (0, utils_1.mergeRefs)(setPopper, ref) }, styles.content, rest), shouldRenderChildren ? children : null)));
|
|
46
46
|
});
|
|
47
47
|
exports.PopoverContent.displayName = 'PopoverContent';
|
|
48
48
|
exports.default = exports.PopoverContent;
|
|
@@ -37,17 +37,17 @@ var context_1 = require("./context");
|
|
|
37
37
|
*/
|
|
38
38
|
exports.PopoverTrigger = (0, core_1.vui)(function (props, ref) {
|
|
39
39
|
var _a;
|
|
40
|
+
// @ts-ignore - TS incorrectly doesn't recognize 'as' prop
|
|
41
|
+
var As = props.as, className = props.className, onClickProp = props.onClick, rest = __rest(props, ["as", "className", "onClick"]);
|
|
40
42
|
var _b = (_a = (0, context_1.usePopoverContext)()) !== null && _a !== void 0 ? _a : {}, setReference = _b.setReference, popoverProps = __rest(_b, ["setReference"]);
|
|
41
43
|
var styles = (0, core_1.useStyleConfig)('Popover', __assign(__assign({}, popoverProps), props));
|
|
42
|
-
// @ts-ignore - TS incorrectly doesn't recognize 'as' prop
|
|
43
|
-
var As = props.as, onClickProp = props.onClick, rest = __rest(props, ["as", "onClick"]);
|
|
44
44
|
var Element = As || core_1.v.button;
|
|
45
45
|
var onClick = function (e) {
|
|
46
46
|
// Avoids triggering parent's onClick, like when inside a ListItem
|
|
47
47
|
e.stopPropagation();
|
|
48
48
|
onClickProp === null || onClickProp === void 0 ? void 0 : onClickProp(e);
|
|
49
49
|
};
|
|
50
|
-
return (react_1.default.createElement(Element, __assign({ className:
|
|
50
|
+
return (react_1.default.createElement(Element, __assign({ className: (0, utils_1.cs)('vui-popoverTrigger', className), onClick: onClick, ref: (0, utils_1.mergeRefs)(setReference, ref) }, styles.trigger, rest)));
|
|
51
51
|
});
|
|
52
52
|
exports.PopoverTrigger.displayName = 'PopoverTrigger';
|
|
53
53
|
exports.default = exports.PopoverTrigger;
|
package/radio/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Dict } from '../utils';
|
|
3
|
-
declare const RadioGroupProvider: import("react").Provider<Dict<any>>,
|
|
4
|
-
export { RadioGroupProvider,
|
|
3
|
+
declare const RadioGroupProvider: import("react").Provider<Dict<any>>, useRadioGroupContext: () => Dict<any>;
|
|
4
|
+
export { RadioGroupProvider, useRadioGroupContext };
|
package/radio/context.js
CHANGED
|
@@ -16,8 +16,8 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
19
|
+
exports.useRadioGroupContext = exports.RadioGroupProvider = void 0;
|
|
20
20
|
var utils_1 = require("../utils");
|
|
21
|
-
var _a = __read((0, utils_1.createContext)({ isOptional: true }), 2), RadioGroupProvider = _a[0],
|
|
21
|
+
var _a = __read((0, utils_1.createContext)({ isOptional: true }), 2), RadioGroupProvider = _a[0], useRadioGroupContext = _a[1];
|
|
22
22
|
exports.RadioGroupProvider = RadioGroupProvider;
|
|
23
|
-
exports.
|
|
23
|
+
exports.useRadioGroupContext = useRadioGroupContext;
|
package/radio/radio.js
CHANGED
|
@@ -85,7 +85,7 @@ exports.RadioBase = core_1.styled.labelBox(templateObject_3 || (templateObject_3
|
|
|
85
85
|
*/
|
|
86
86
|
exports.Radio = (0, core_1.vui)(function (props, ref) {
|
|
87
87
|
var _a, _b;
|
|
88
|
-
var _c = (_a = (0, context_1.
|
|
88
|
+
var _c = (_a = (0, context_1.useRadioGroupContext)()) !== null && _a !== void 0 ? _a : {}, groupDefaultValue = _c.defaultValue, groupIsChecked = _c.isChecked, groupOnChange = _c.onChange, groupValue = _c.value, radioGroupProps = __rest(_c, ["defaultValue", "isChecked", "onChange", "value"]);
|
|
89
89
|
var defaultIsChecked = groupIsChecked !== undefined ? groupIsChecked === props.value : undefined;
|
|
90
90
|
var mergedProps = __assign(__assign({}, radioGroupProps), props);
|
|
91
91
|
var _d = (0, core_1.omitThemingProps)(mergedProps), _e = _d.checked, checked = _e === void 0 ? groupValue !== undefined ? props.value === groupValue : undefined : _e, children = _d.children, className = _d.className, _f = _d.defaultChecked, defaultChecked = _f === void 0 ? groupDefaultValue !== undefined ? props.value === groupDefaultValue : undefined : _f, disabled = _d.disabled, _g = _d.icon, iconProp = _g === void 0 ? 'cuiRadioUnselected' : _g, _h = _d.iconChecked, iconChecked = _h === void 0 ? 'cuiRadioSelected' : _h, id = _d.id, inputProps = _d.inputProps, inputRef = _d.inputRef, label = _d.label, name = _d.name, onChange = _d.onChange, required = _d.required, value = _d.value, rest = __rest(_d, ["checked", "children", "className", "defaultChecked", "disabled", "icon", "iconChecked", "id", "inputProps", "inputRef", "label", "name", "onChange", "required", "value"]);
|
package/spinner/consts.d.ts
CHANGED
|
@@ -4,33 +4,21 @@ export declare const spinnerPositionMapping: {
|
|
|
4
4
|
container: {
|
|
5
5
|
flexDirection: string;
|
|
6
6
|
};
|
|
7
|
-
circle: {
|
|
8
|
-
mb: number;
|
|
9
|
-
};
|
|
10
7
|
};
|
|
11
8
|
left: {
|
|
12
9
|
container: {
|
|
13
10
|
flexDirection: string;
|
|
14
11
|
};
|
|
15
|
-
circle: {
|
|
16
|
-
ml: number;
|
|
17
|
-
};
|
|
18
12
|
};
|
|
19
13
|
right: {
|
|
20
14
|
container: {
|
|
21
15
|
flexDirection: string;
|
|
22
16
|
};
|
|
23
|
-
circle: {
|
|
24
|
-
mr: number;
|
|
25
|
-
};
|
|
26
17
|
};
|
|
27
18
|
top: {
|
|
28
19
|
container: {
|
|
29
20
|
flexDirection: string;
|
|
30
21
|
};
|
|
31
|
-
circle: {
|
|
32
|
-
mt: number;
|
|
33
|
-
};
|
|
34
22
|
};
|
|
35
23
|
};
|
|
36
24
|
export declare const spinnerSpeedMapping: Dict<string>;
|
package/spinner/consts.js
CHANGED
|
@@ -3,20 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.spinnerSpeedMapping = exports.spinnerPositionMapping = void 0;
|
|
4
4
|
exports.spinnerPositionMapping = {
|
|
5
5
|
bottom: {
|
|
6
|
-
container: { flexDirection: 'column' }
|
|
7
|
-
circle: { mb: 1 }
|
|
6
|
+
container: { flexDirection: 'column' }
|
|
8
7
|
},
|
|
9
8
|
left: {
|
|
10
|
-
container: { flexDirection: 'row-reverse' }
|
|
11
|
-
circle: { ml: 1 }
|
|
9
|
+
container: { flexDirection: 'row-reverse' }
|
|
12
10
|
},
|
|
13
11
|
right: {
|
|
14
|
-
container: { flexDirection: 'row' }
|
|
15
|
-
circle: { mr: 1 }
|
|
12
|
+
container: { flexDirection: 'row' }
|
|
16
13
|
},
|
|
17
14
|
top: {
|
|
18
|
-
container: { flexDirection: 'column-reverse' }
|
|
19
|
-
circle: { mt: 1 }
|
|
15
|
+
container: { flexDirection: 'column-reverse' }
|
|
20
16
|
}
|
|
21
17
|
};
|
|
22
18
|
exports.spinnerSpeedMapping = {
|
package/spinner/spinner.js
CHANGED
|
@@ -59,8 +59,8 @@ exports.Spinner = (0, core_1.vui)(function (props, ref) {
|
|
|
59
59
|
h: isCustomSize ? size : undefined,
|
|
60
60
|
w: isCustomSize ? size : undefined
|
|
61
61
|
});
|
|
62
|
-
return (react_1.default.createElement(box_1.default, __assign({ center: true, className: (0, utils_1.cs)('vui-spinner', className), ref: ref, transitionDuration: "fast" }, styles.container, positionProps.container, rest),
|
|
63
|
-
react_1.default.createElement(exports.SpinnerCircle, __assign({ animation: "vui-spin " + speed + " linear infinite", className: "vui-spinnerCircle" }, styles.circle,
|
|
62
|
+
return (react_1.default.createElement(box_1.default, __assign({ center: true, className: (0, utils_1.cs)('vui-spinner', className), gap: 1, ref: ref, transitionDuration: "fast" }, styles.container, positionProps.container, rest),
|
|
63
|
+
react_1.default.createElement(exports.SpinnerCircle, __assign({ animation: "vui-spin " + speed + " linear infinite", className: "vui-spinnerCircle" }, styles.circle, circleProps)),
|
|
64
64
|
text && (react_1.default.createElement(t_1.default, __assign({ className: "vui-spinnerText" }, styles.text), text))));
|
|
65
65
|
});
|
|
66
66
|
exports.Spinner.displayName = 'Spinner';
|
package/switch/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SwitchContext } from './switch.types';
|
|
3
|
-
declare const SwitchProvider: import("react").Provider<SwitchContext>,
|
|
4
|
-
export { SwitchProvider,
|
|
3
|
+
declare const SwitchProvider: import("react").Provider<SwitchContext>, useSwitchContext: () => SwitchContext;
|
|
4
|
+
export { SwitchProvider, useSwitchContext };
|
package/switch/context.js
CHANGED
|
@@ -16,8 +16,8 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
19
|
+
exports.useSwitchContext = exports.SwitchProvider = void 0;
|
|
20
20
|
var utils_1 = require("../utils");
|
|
21
|
-
var _a = __read((0, utils_1.createContext)({ isOptional: true }), 2), SwitchProvider = _a[0],
|
|
21
|
+
var _a = __read((0, utils_1.createContext)({ isOptional: true }), 2), SwitchProvider = _a[0], useSwitchContext = _a[1];
|
|
22
22
|
exports.SwitchProvider = SwitchProvider;
|
|
23
|
-
exports.
|
|
23
|
+
exports.useSwitchContext = useSwitchContext;
|
package/switch/switchButton.js
CHANGED
|
@@ -86,12 +86,12 @@ exports.SwitchButtonBase = core_1.styled.spanBox(templateObject_4 || (templateOb
|
|
|
86
86
|
* Handles controlled and uncontrolled modes.
|
|
87
87
|
*/
|
|
88
88
|
exports.SwitchButton = (0, core_1.vui)(function (props, ref) {
|
|
89
|
-
var mergedProps = __assign(__assign({}, (0, context_1.
|
|
89
|
+
var mergedProps = __assign(__assign({}, (0, context_1.useSwitchContext)()), props);
|
|
90
90
|
var _a = (0, core_1.omitThemingProps)(mergedProps), checked = _a.checked, className = _a.className, defaultChecked = _a.defaultChecked, disabled = _a.disabled, id = _a.id, innerLabelOff = _a.innerLabelOff, innerLabelOn = _a.innerLabelOn, inputProps = _a.inputProps, inputRef = _a.inputRef, name = _a.name, onBlur = _a.onBlur, onChange = _a.onChange, onFocus = _a.onFocus, required = _a.required, value = _a.value, rest = __rest(_a, ["checked", "className", "defaultChecked", "disabled", "id", "innerLabelOff", "innerLabelOn", "inputProps", "inputRef", "name", "onBlur", "onChange", "onFocus", "required", "value"]);
|
|
91
91
|
var isControlled = (0, react_1.useRef)(checked !== undefined).current;
|
|
92
92
|
var _b = __read((0, react_1.useState)(checked !== null && checked !== void 0 ? checked : defaultChecked), 2), isChecked = _b[0], setIsChecked = _b[1];
|
|
93
93
|
var _c = __read((0, react_1.useState)(false), 2), isFocused = _c[0], setIsFocused = _c[1];
|
|
94
|
-
var styles = (0, core_1.useStyleConfig)('Switch',
|
|
94
|
+
var styles = (0, core_1.useStyleConfig)('Switch', (0, context_1.useSwitchContext)());
|
|
95
95
|
var _d = styles.button, thumbStyles = _d.thumb, trackStyles = _d.track, buttonStyles = __rest(_d, ["thumb", "track"]);
|
|
96
96
|
(0, react_1.useEffect)(function () {
|
|
97
97
|
isControlled && setIsChecked(checked);
|
package/switch/switchLabel.js
CHANGED
|
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
13
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
26
|
};
|
|
@@ -18,11 +29,13 @@ exports.SwitchLabel = void 0;
|
|
|
18
29
|
var react_1 = __importDefault(require("react"));
|
|
19
30
|
var core_1 = require("../core");
|
|
20
31
|
var t_1 = __importDefault(require("../t"));
|
|
32
|
+
var utils_1 = require("../utils");
|
|
21
33
|
var context_1 = require("./context");
|
|
22
34
|
/** Displays label text within the Switch component. */
|
|
23
35
|
exports.SwitchLabel = (0, core_1.vui)(function (props, ref) {
|
|
24
|
-
var
|
|
25
|
-
|
|
36
|
+
var className = props.className, rest = __rest(props, ["className"]);
|
|
37
|
+
var styles = (0, core_1.useStyleConfig)('Switch', (0, context_1.useSwitchContext)());
|
|
38
|
+
return react_1.default.createElement(t_1.default, __assign({ className: (0, utils_1.cs)('vui-switchLabel', className), display: "flex", ref: ref }, styles.label, rest));
|
|
26
39
|
});
|
|
27
40
|
exports.SwitchLabel.displayName = 'SwitchLabel';
|
|
28
41
|
exports.default = exports.SwitchLabel;
|
package/tag/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Dict } from '../utils';
|
|
3
|
-
declare const TagProvider: import("react").Provider<Dict<any>>,
|
|
4
|
-
export { TagProvider,
|
|
3
|
+
declare const TagProvider: import("react").Provider<Dict<any>>, useTagContext: () => Dict<any>;
|
|
4
|
+
export { TagProvider, useTagContext };
|
package/tag/context.js
CHANGED
|
@@ -16,8 +16,8 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
19
|
+
exports.useTagContext = exports.TagProvider = void 0;
|
|
20
20
|
var utils_1 = require("../utils");
|
|
21
|
-
var _a = __read((0, utils_1.createContext)({ isOptional: true }), 2), TagProvider = _a[0],
|
|
21
|
+
var _a = __read((0, utils_1.createContext)({ isOptional: true }), 2), TagProvider = _a[0], useTagContext = _a[1];
|
|
22
22
|
exports.TagProvider = TagProvider;
|
|
23
|
-
exports.
|
|
23
|
+
exports.useTagContext = useTagContext;
|
package/tag/tagButton.js
CHANGED
|
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
13
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
26
|
};
|
|
@@ -18,12 +29,14 @@ exports.TagButton = void 0;
|
|
|
18
29
|
var react_1 = __importDefault(require("react"));
|
|
19
30
|
var button_1 = __importDefault(require("../button"));
|
|
20
31
|
var core_1 = require("../core");
|
|
32
|
+
var utils_1 = require("../utils");
|
|
21
33
|
var context_1 = require("./context");
|
|
22
34
|
/** Displays a button within the Tag. */
|
|
23
35
|
exports.TagButton = (0, core_1.vui)(function (props, ref) {
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
36
|
+
var className = props.className, rest = __rest(props, ["className"]);
|
|
37
|
+
var mergedProps = __assign(__assign({}, (0, context_1.useTagContext)()), props);
|
|
38
|
+
var styles = (0, core_1.useStyleConfig)('Tag', (0, context_1.useTagContext)());
|
|
39
|
+
return (react_1.default.createElement(button_1.default, __assign({ borderColor: "transparent", className: (0, utils_1.cs)('vui-tagButton', className), colorScheme: mergedProps.colorScheme, disabled: mergedProps.disabled, hoverBorderColor: "transparent", icon: "falTimes", mr: -0.5, ref: ref, variant: "text" }, styles.button, rest)));
|
|
27
40
|
});
|
|
28
41
|
exports.TagButton.displayName = 'TagButton';
|
|
29
42
|
exports.default = exports.TagButton;
|
package/tag/tagIcon.js
CHANGED
|
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
13
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
26
|
};
|
|
@@ -18,11 +29,13 @@ exports.TagIcon = void 0;
|
|
|
18
29
|
var react_1 = __importDefault(require("react"));
|
|
19
30
|
var core_1 = require("../core");
|
|
20
31
|
var icon_1 = __importDefault(require("../icon"));
|
|
32
|
+
var utils_1 = require("../utils");
|
|
21
33
|
var context_1 = require("./context");
|
|
22
34
|
/** Displays an icon within the Tag. */
|
|
23
35
|
exports.TagIcon = (0, core_1.vui)(function (props, ref) {
|
|
24
|
-
var
|
|
25
|
-
|
|
36
|
+
var className = props.className, rest = __rest(props, ["className"]);
|
|
37
|
+
var styles = (0, core_1.useStyleConfig)('Tag', (0, context_1.useTagContext)());
|
|
38
|
+
return react_1.default.createElement(icon_1.default, __assign({ className: (0, utils_1.cs)('vui-tagIcon', className), ref: ref }, styles.icon, rest));
|
|
26
39
|
});
|
|
27
40
|
exports.TagIcon.displayName = 'TagIcon';
|
|
28
41
|
exports.default = exports.TagIcon;
|
package/tag/tagText.js
CHANGED
|
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
13
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
26
|
};
|
|
@@ -18,11 +29,13 @@ exports.TagText = void 0;
|
|
|
18
29
|
var react_1 = __importDefault(require("react"));
|
|
19
30
|
var core_1 = require("../core");
|
|
20
31
|
var t_1 = __importDefault(require("../t"));
|
|
32
|
+
var utils_1 = require("../utils");
|
|
21
33
|
var context_1 = require("./context");
|
|
22
34
|
/** Displays text within the Tag. */
|
|
23
35
|
exports.TagText = (0, core_1.vui)(function (props, ref) {
|
|
24
|
-
var
|
|
25
|
-
|
|
36
|
+
var className = props.className, rest = __rest(props, ["className"]);
|
|
37
|
+
var styles = (0, core_1.useStyleConfig)('Tag', (0, context_1.useTagContext)());
|
|
38
|
+
return react_1.default.createElement(t_1.default, __assign({ className: (0, utils_1.cs)('vui-tagText', className), fontSize: "inherit", ref: ref }, styles.text, rest));
|
|
26
39
|
});
|
|
27
40
|
exports.TagText.displayName = 'TagText';
|
|
28
41
|
exports.default = exports.TagText;
|
package/textarea/textarea.js
CHANGED
|
@@ -120,7 +120,7 @@ exports.Textarea = (0, core_1.vui)(function (props, ref) {
|
|
|
120
120
|
rows: rows,
|
|
121
121
|
value: value
|
|
122
122
|
}, styles.textarea, textareaAliasedProps, textareaProps)),
|
|
123
|
-
showCount && (react_1.default.createElement(t_1.default, { color: "grey.80", position: "absolute", right: 0, size: "sm", top: "calc(100% + 1px)" },
|
|
123
|
+
showCount && (react_1.default.createElement(t_1.default, { className: "vui-textareaCount", color: "grey.80", position: "absolute", right: 0, size: "sm", top: "calc(100% + 1px)" },
|
|
124
124
|
count,
|
|
125
125
|
" / ",
|
|
126
126
|
maxLength))));
|
package/theme/components.d.ts
CHANGED
package/theme/components.js
CHANGED
|
@@ -23,15 +23,16 @@ var theme_17 = __importDefault(require("../menu/theme"));
|
|
|
23
23
|
var theme_18 = __importDefault(require("../modal/theme"));
|
|
24
24
|
var theme_19 = __importDefault(require("../notification/theme"));
|
|
25
25
|
var theme_20 = __importDefault(require("../p/theme"));
|
|
26
|
-
var theme_21 = __importDefault(require("../
|
|
27
|
-
var theme_22 = __importDefault(require("../
|
|
28
|
-
var theme_23 = __importDefault(require("../
|
|
29
|
-
var theme_24 = __importDefault(require("../
|
|
30
|
-
var theme_25 = __importDefault(require("../
|
|
31
|
-
var theme_26 = __importDefault(require("../
|
|
32
|
-
var theme_27 = __importDefault(require("../
|
|
33
|
-
var theme_28 = __importDefault(require("../
|
|
34
|
-
var theme_29 = __importDefault(require("../
|
|
26
|
+
var theme_21 = __importDefault(require("../pagination/theme"));
|
|
27
|
+
var theme_22 = __importDefault(require("../panel/theme"));
|
|
28
|
+
var theme_23 = __importDefault(require("../popover/theme"));
|
|
29
|
+
var theme_24 = __importDefault(require("../radio/theme"));
|
|
30
|
+
var theme_25 = __importDefault(require("../skeleton/theme"));
|
|
31
|
+
var theme_26 = __importDefault(require("../spinner/theme"));
|
|
32
|
+
var theme_27 = __importDefault(require("../switch/theme"));
|
|
33
|
+
var theme_28 = __importDefault(require("../t/theme"));
|
|
34
|
+
var theme_29 = __importDefault(require("../tag/theme"));
|
|
35
|
+
var theme_30 = __importDefault(require("../textarea/theme"));
|
|
35
36
|
exports.default = {
|
|
36
37
|
Avatar: theme_1.default,
|
|
37
38
|
Box: theme_2.default,
|
|
@@ -53,13 +54,14 @@ exports.default = {
|
|
|
53
54
|
Modal: theme_18.default,
|
|
54
55
|
Notification: theme_19.default,
|
|
55
56
|
P: theme_20.default,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
Pagination: theme_21.default,
|
|
58
|
+
Panel: theme_22.default,
|
|
59
|
+
Popover: theme_23.default,
|
|
60
|
+
Radio: theme_24.default,
|
|
61
|
+
Skeleton: theme_25.default,
|
|
62
|
+
Spinner: theme_26.default,
|
|
63
|
+
Switch: theme_27.default,
|
|
64
|
+
T: theme_28.default,
|
|
65
|
+
Tag: theme_29.default,
|
|
66
|
+
Textarea: theme_30.default
|
|
65
67
|
};
|
package/theme/defaultTheme.d.ts
CHANGED
package/utils/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { RefObject } from 'react';
|
|
1
|
+
import React, { DependencyList, RefObject } from 'react';
|
|
2
2
|
import { AnyFunction, CreateContextOptions, CreateContextReturn } from './types';
|
|
3
3
|
declare type ReactRef<T> = React.Ref<T> | React.RefObject<T> | React.MutableRefObject<T>;
|
|
4
4
|
/**
|
|
@@ -11,7 +11,7 @@ export declare function createContext<ContextType>(options?: CreateContextOption
|
|
|
11
11
|
/** Assigns a node to all provided refs. */
|
|
12
12
|
export declare function mergeRefs<T>(...refs: (ReactRef<T> | undefined)[]): (node: T | null) => void;
|
|
13
13
|
/** Returns given callback with a stable reference, but keeps it updated internally. */
|
|
14
|
-
export declare function useCallbackRef<T extends AnyFunction>(callback?: T): T;
|
|
14
|
+
export declare function useCallbackRef<T extends AnyFunction>(callback?: T, deps?: DependencyList): T;
|
|
15
15
|
/**
|
|
16
16
|
* Triggers given callback when an event happens outside of a given element.
|
|
17
17
|
* Event listeners are attached to the window object.
|
|
@@ -20,6 +20,20 @@ export declare function useCallbackRef<T extends AnyFunction>(callback?: T): T;
|
|
|
20
20
|
* @param events - array of events listened for (default: ['mousedown', 'touchstart'])
|
|
21
21
|
*/
|
|
22
22
|
export declare function useClickOutside(ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[], callback?: (event: Event) => void, events?: string[]): void;
|
|
23
|
+
export declare type UseControlledProps<T> = {
|
|
24
|
+
value?: T;
|
|
25
|
+
defaultValue?: T;
|
|
26
|
+
onChange?: (value: T) => void;
|
|
27
|
+
};
|
|
28
|
+
/** Supports state management in components that can be controlled or uncontrolled. */
|
|
29
|
+
export declare function useControlled<T>(props: UseControlledProps<T>): [T, React.Dispatch<React.SetStateAction<T>>, {
|
|
30
|
+
isControlled: boolean;
|
|
31
|
+
reset: () => void;
|
|
32
|
+
}];
|
|
23
33
|
/** Returns an array with each prefix added to the id. Useful for aria attributes in compound components. */
|
|
24
34
|
export declare function useIds(id: string, prefixes: string[]): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Provides a function, which can be called to check if component using the hook is mounted or unmounted.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useIsMounted(): () => boolean;
|
|
25
39
|
export {};
|
package/utils/react.js
CHANGED
|
@@ -45,9 +45,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.useIds = exports.useClickOutside = exports.useCallbackRef = exports.mergeRefs = exports.createContext = exports.assignRef = void 0;
|
|
48
|
+
exports.useIsMounted = exports.useIds = exports.useControlled = exports.useClickOutside = exports.useCallbackRef = exports.mergeRefs = exports.createContext = exports.assignRef = void 0;
|
|
49
49
|
var react_1 = __importStar(require("react"));
|
|
50
50
|
var assertion_1 = require("./assertion");
|
|
51
|
+
var function_1 = require("./function");
|
|
51
52
|
/**
|
|
52
53
|
* Assigns given value to the provided ref.
|
|
53
54
|
* Supports ref as function (e.g. useState) and classic ref (e.g. useRef).
|
|
@@ -96,7 +97,8 @@ function mergeRefs() {
|
|
|
96
97
|
exports.mergeRefs = mergeRefs;
|
|
97
98
|
// TODO: Bring it from UI-Utils
|
|
98
99
|
/** Returns given callback with a stable reference, but keeps it updated internally. */
|
|
99
|
-
function useCallbackRef(callback) {
|
|
100
|
+
function useCallbackRef(callback, deps) {
|
|
101
|
+
if (deps === void 0) { deps = []; }
|
|
100
102
|
var ref = (0, react_1.useRef)(callback);
|
|
101
103
|
ref.current = callback;
|
|
102
104
|
return (0, react_1.useCallback)((function () {
|
|
@@ -106,7 +108,7 @@ function useCallbackRef(callback) {
|
|
|
106
108
|
args[_i] = arguments[_i];
|
|
107
109
|
}
|
|
108
110
|
return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([ref], __read(args), false));
|
|
109
|
-
}),
|
|
111
|
+
}), deps);
|
|
110
112
|
}
|
|
111
113
|
exports.useCallbackRef = useCallbackRef;
|
|
112
114
|
var defaultEvents = ['mousedown', 'touchstart'];
|
|
@@ -136,8 +138,44 @@ function useClickOutside(ref, callback, events) {
|
|
|
136
138
|
}, [eventsString, ref]);
|
|
137
139
|
}
|
|
138
140
|
exports.useClickOutside = useClickOutside;
|
|
141
|
+
// TODO: Move to ui-utils
|
|
142
|
+
/** Supports state management in components that can be controlled or uncontrolled. */
|
|
143
|
+
function useControlled(props) {
|
|
144
|
+
var defaultValue = props.defaultValue, onChangeProp = props.onChange, valueProp = props.value;
|
|
145
|
+
var _a = __read((0, react_1.useState)(defaultValue), 2), valueState = _a[0], setValue = _a[1];
|
|
146
|
+
var isControlled = valueProp !== undefined;
|
|
147
|
+
var value = isControlled ? valueProp : valueState;
|
|
148
|
+
/** Triggers the external callback with the new value. In uncontrolled mode, updates state. */
|
|
149
|
+
var onChange = useCallbackRef(function (next) {
|
|
150
|
+
var newValue = (0, function_1.runIfFn)(next);
|
|
151
|
+
if (!isControlled)
|
|
152
|
+
setValue(newValue);
|
|
153
|
+
onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(newValue);
|
|
154
|
+
});
|
|
155
|
+
/** In uncontrolled mode, sets the state to the default value. */
|
|
156
|
+
var reset = useCallbackRef(function () {
|
|
157
|
+
!isControlled && defaultValue && onChange(defaultValue);
|
|
158
|
+
});
|
|
159
|
+
return [value, onChange, { isControlled: isControlled, reset: reset }];
|
|
160
|
+
}
|
|
161
|
+
exports.useControlled = useControlled;
|
|
139
162
|
/** Returns an array with each prefix added to the id. Useful for aria attributes in compound components. */
|
|
140
163
|
function useIds(id, prefixes) {
|
|
141
164
|
return prefixes.map(function (prefix) { return prefix + "-" + id; });
|
|
142
165
|
}
|
|
143
166
|
exports.useIds = useIds;
|
|
167
|
+
// TODO: Bring it from ui-utils
|
|
168
|
+
/**
|
|
169
|
+
* Provides a function, which can be called to check if component using the hook is mounted or unmounted.
|
|
170
|
+
*/
|
|
171
|
+
function useIsMounted() {
|
|
172
|
+
var isMounted = (0, react_1.useRef)(false);
|
|
173
|
+
(0, react_1.useEffect)(function () {
|
|
174
|
+
isMounted.current = true;
|
|
175
|
+
return function () {
|
|
176
|
+
isMounted.current = false;
|
|
177
|
+
};
|
|
178
|
+
}, []);
|
|
179
|
+
return (0, react_1.useCallback)(function () { return isMounted.current; }, []);
|
|
180
|
+
}
|
|
181
|
+
exports.useIsMounted = useIsMounted;
|