@hitachivantara/uikit-react-core 3.53.0 → 3.54.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/CHANGELOG.md +49 -0
- package/dist/Snackbar/SnackbarProvider/SnackbarProvider.d.ts +30 -0
- package/dist/Snackbar/SnackbarProvider/SnackbarProvider.js +207 -0
- package/dist/Snackbar/SnackbarProvider/SnackbarProvider.js.map +1 -0
- package/dist/Snackbar/SnackbarProvider/index.d.ts +2 -0
- package/dist/Snackbar/SnackbarProvider/index.js +49 -0
- package/dist/Snackbar/SnackbarProvider/index.js.map +1 -0
- package/dist/Snackbar/stories/SnackbarProvider.stories.mdx +51 -0
- package/dist/TagsInput/TagsInput.d.ts +33 -4
- package/dist/TagsInput/TagsInput.js +125 -19
- package/dist/TagsInput/TagsInput.js.map +1 -1
- package/dist/TagsInput/styles.js +12 -8
- package/dist/TagsInput/styles.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy/Snackbar/SnackbarProvider/SnackbarProvider.d.ts +30 -0
- package/dist/legacy/Snackbar/SnackbarProvider/SnackbarProvider.js +169 -0
- package/dist/legacy/Snackbar/SnackbarProvider/SnackbarProvider.js.map +1 -0
- package/dist/legacy/Snackbar/SnackbarProvider/index.d.ts +2 -0
- package/dist/legacy/Snackbar/SnackbarProvider/index.js +3 -0
- package/dist/legacy/Snackbar/SnackbarProvider/index.js.map +1 -0
- package/dist/legacy/Snackbar/stories/SnackbarProvider.stories.mdx +51 -0
- package/dist/legacy/TagsInput/TagsInput.d.ts +33 -4
- package/dist/legacy/TagsInput/TagsInput.js +129 -25
- package/dist/legacy/TagsInput/TagsInput.js.map +1 -1
- package/dist/legacy/TagsInput/styles.js +12 -8
- package/dist/legacy/TagsInput/styles.js.map +1 -1
- package/dist/legacy/index.d.ts +2 -0
- package/dist/legacy/index.js +1 -0
- package/dist/legacy/index.js.map +1 -1
- package/dist/modern/Snackbar/SnackbarProvider/SnackbarProvider.d.ts +30 -0
- package/dist/modern/Snackbar/SnackbarProvider/SnackbarProvider.js +155 -0
- package/dist/modern/Snackbar/SnackbarProvider/SnackbarProvider.js.map +1 -0
- package/dist/modern/Snackbar/SnackbarProvider/index.d.ts +2 -0
- package/dist/modern/Snackbar/SnackbarProvider/index.js +3 -0
- package/dist/modern/Snackbar/SnackbarProvider/index.js.map +1 -0
- package/dist/modern/Snackbar/stories/SnackbarProvider.stories.mdx +51 -0
- package/dist/modern/TagsInput/TagsInput.d.ts +33 -4
- package/dist/modern/TagsInput/TagsInput.js +108 -19
- package/dist/modern/TagsInput/TagsInput.js.map +1 -1
- package/dist/modern/TagsInput/styles.js +12 -8
- package/dist/modern/TagsInput/styles.js.map +1 -1
- package/dist/modern/index.d.ts +2 -0
- package/dist/modern/index.js +1 -0
- package/dist/modern/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;AASA;;AAGA;;AACA;;AAGA;;AAGA;;AAIA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// components\nexport { default as HvAccordion } from \"./Accordion\";\nexport { default as HvActionsGeneric } from \"./ActionsGeneric\";\nexport { default as HvActionBar } from \"./ActionBar\";\nexport { default as HvAssetInventory } from \"./AssetInventory\";\nexport * from \"./AssetInventory\";\nexport { default as HvAvatar } from \"./Avatar\";\nexport { default as HvBadge } from \"./Badge\";\nexport { default as HvBanner } from \"./Banner\";\nexport * from \"./Banner\";\nexport { default as HvBarchart } from \"./Barchart\";\nexport { default as HvBaseDropdown } from \"./BaseDropdown\";\nexport { default as HvBreadcrumb } from \"./BreadCrumb\";\nexport { default as HvBulkActions } from \"./BulkActions\";\nexport { default as HvButton } from \"./Button\";\nexport { default as HvCard } from \"./Card\";\nexport * from \"./Card\";\nexport * from \"./Calendar\";\nexport { default as HvContainer } from \"./Container\";\nexport { default as HvDatePicker } from \"./DatePicker\";\nexport { default as HvDonutchart } from \"./Donutchart\";\nexport { default as HvDropdown } from \"./Dropdown\";\nexport { default as HvDropDownMenu } from \"./DropDownMenu\";\nexport { default as HvEmptyState } from \"./EmptyState\";\nexport { default as HvFilterGroup } from \"./FilterGroup\";\nexport { default as HvFileUploader } from \"./FileUploader\";\nexport * from \"./FileUploader\";\nexport { default as HvFooter } from \"./Footer\";\nexport * from \"./Forms\";\n\nexport { default as HvGrid } from \"./Grid\";\nexport { default as HvGlobalActions } from \"./GlobalActions\";\n\nexport { default as HvHeader } from \"./Header\";\nexport * from \"./Header\";\n\nexport { default as HvBaseInput } from \"./BaseInput\";\nexport { default as HvInput } from \"./Input\";\n\nexport { default as HvKpi } from \"./Kpi\";\n\nexport { default as HvLinechart } from \"./Linechart\";\nexport { default as HvLink } from \"./Link\";\nexport { default as HvListContainer } from \"./ListContainer\";\nexport * from \"./ListContainer\";\n\nexport { default as HvList } from \"./List\";\n\nexport { default as HvSelectionList } from \"./SelectionList\";\n\nexport { default as HvLoading } from \"./Loading\";\nexport { default as HvLogin } from \"./Login\";\nexport { default as HvDialog } from \"./Dialog\";\nexport * from \"./Dialog\";\nexport { default as HvMultiButton } from \"./MultiButton\";\nexport { default as HvPagination } from \"./Pagination\";\n\nexport { default as HvBaseCheckBox } from \"./BaseCheckBox\";\nexport { default as HvCheckBox } from \"./CheckBox\";\nexport { default as HvCheckBoxGroup } from \"./CheckBoxGroup\";\n\nexport { default as HvBaseRadio } from \"./BaseRadio\";\nexport { default as HvRadio } from \"./Radio\";\nexport { default as HvRadioGroup } from \"./RadioGroup\";\n\nexport { default as HvBaseSwitch } from \"./BaseSwitch\";\nexport { default as HvSwitch } from \"./Switch\";\n\nexport { default as HvSnackbar } from \"./Snackbar\";\nexport { default as HvSnackbarContent } from \"./Snackbar/SnackbarContentWrapper\";\nexport { default as HvSnackbarProvider, useHvSnackbar } from \"./Snackbar/SnackbarProvider\";\n\nexport { default as HvTab } from \"./Tab\";\nexport { default as HvTag } from \"./Tag\";\nexport { default as HvTable } from \"./Table\";\nexport { default as HvTabs } from \"./Tabs\";\nexport { default as HvTextArea } from \"./TextArea\";\nexport { default as HvTagsInput } from \"./TagsInput\";\nexport { default as HvToggleButton } from \"./ToggleButton\";\nexport { default as HvTooltip } from \"./Tooltip\";\nexport { default as HvOverflowTooltip } from \"./OverflowTooltip\";\nexport { default as HvTypography } from \"./Typography\";\nexport { default as HvUserPreferences } from \"./UserPreferences\";\n// TODO refactor the HvUserPreferences subcomponents' names\nexport {\n Actions as HvUserPreferencesActions,\n Action as HvUserPreferencesAction,\n} from \"./UserPreferences\";\nexport {\n Options as HvUserPreferencesOptions,\n Option as HvUserPreferencesOption,\n Group as HvUserPreferencesOptionsGroup,\n Label as HvUserPreferencesOptionsGroupLabel,\n} from \"./UserPreferences\";\n\nexport { default as HvScrollToHorizontal } from \"./ScrollTo/Horizontal\";\nexport { default as HvScrollToVertical } from \"./ScrollTo/Vertical\";\nexport { default as useScrollTo } from \"./ScrollTo/useScrollTo\";\n\nexport { default as HvVerticalNavigation } from \"./VerticalNavigation\";\n// TODO refactor the HvVerticalNavigation subcomponents' names\nexport { Navigation as HvVerticalNavigationTree } from \"./VerticalNavigation\";\nexport { TreeView as HvTreeView, TreeViewItem as HvTreeViewItem } from \"./VerticalNavigation\";\nexport {\n Actions as HvVerticalNavigationActions,\n Action as HvVerticalNavigationAction,\n} from \"./VerticalNavigation\";\n\nexport { default as HvPanel } from \"./Panel\";\n\n// HOCs\nexport { default as withId } from \"./withId\";\nexport { default as withTooltip } from \"./withTooltip\";\n\n// Hooks\nexport { default as useUniqueId } from \"./useUniqueId\";\n\n// theme\nexport { default as hvTheme } from \"./theme\";\nexport { themeBuilder, getTheme } from \"./theme\";\n\n// provider\nexport { default as HvProvider } from \"./Provider\";\nexport * from \"./Provider\";\n\n// utils\nexport * from \"./utils\";\n"],"file":"index.js"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OptionsObject,
|
|
3
|
+
ProviderContext,
|
|
4
|
+
SnackbarKey,
|
|
5
|
+
SnackbarMessage,
|
|
6
|
+
SnackbarProviderProps,
|
|
7
|
+
} from "notistack";
|
|
8
|
+
import { SemanticVariantTypes } from "../../Banner";
|
|
9
|
+
import { HvSnackbarContentProps } from "../SnackbarContentWrapper";
|
|
10
|
+
|
|
11
|
+
export interface HvSnackbarProviderProps extends SnackbarProviderProps {
|
|
12
|
+
/**
|
|
13
|
+
* Class object used to override notistack classes.
|
|
14
|
+
*/
|
|
15
|
+
notistackClassesOverride?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface HvEnqueueOptions extends OptionsObject {
|
|
19
|
+
id?: string;
|
|
20
|
+
variant?: SemanticVariantTypes;
|
|
21
|
+
snackbarContentProps?: HvSnackbarContentProps;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface HvSnackbarProviderContext extends ProviderContext {
|
|
25
|
+
enqueueSnackbar: (message: SnackbarMessage, options?: HvEnqueueOptions) => SnackbarKey;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useHvSnackbar(): HvSnackbarProviderContext;
|
|
29
|
+
|
|
30
|
+
export default function HvSnackbarProvider(props: HvSnackbarProviderProps): JSX.Element | null;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import "core-js/modules/es.object.keys.js";
|
|
2
|
+
import "core-js/modules/es.symbol.js";
|
|
3
|
+
import "core-js/modules/es.array.filter.js";
|
|
4
|
+
import "core-js/modules/es.object.to-string.js";
|
|
5
|
+
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
6
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
7
|
+
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
10
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
11
|
+
var _excluded = ["id", "variant", "snackbarContentProps"],
|
|
12
|
+
_excluded2 = ["children", "notistackClassesOverride", "maxSnack", "autoHideDuration", "anchorOrigin"];
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
+
|
|
18
|
+
import React, { forwardRef, useCallback, useMemo } from "react";
|
|
19
|
+
import { makeStyles } from "@material-ui/core";
|
|
20
|
+
import PropTypes from "prop-types";
|
|
21
|
+
import { SnackbarProvider, SnackbarContent, useSnackbar } from "notistack";
|
|
22
|
+
import HvSnackbarContentWrapper from "../SnackbarContentWrapper";
|
|
23
|
+
var HvNotistackSnackMessage = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
24
|
+
var id = _ref.id,
|
|
25
|
+
message = _ref.message,
|
|
26
|
+
_ref$variant = _ref.variant,
|
|
27
|
+
variant = _ref$variant === void 0 ? "success" : _ref$variant,
|
|
28
|
+
snackbarContentProps = _ref.snackbarContentProps;
|
|
29
|
+
return /*#__PURE__*/React.createElement(SnackbarContent, {
|
|
30
|
+
ref: ref
|
|
31
|
+
}, /*#__PURE__*/React.createElement(HvSnackbarContentWrapper, _extends({
|
|
32
|
+
id: id,
|
|
33
|
+
variant: variant,
|
|
34
|
+
showIcon: true,
|
|
35
|
+
label: message
|
|
36
|
+
}, snackbarContentProps)));
|
|
37
|
+
}); // We override notistack hook to be able to customize the snackbar that should be called.
|
|
38
|
+
|
|
39
|
+
var useHvSnackbar = function useHvSnackbar() {
|
|
40
|
+
var _useSnackbar = useSnackbar(),
|
|
41
|
+
enqueueNotistackSnackbar = _useSnackbar.enqueueSnackbar,
|
|
42
|
+
closeSnackbar = _useSnackbar.closeSnackbar;
|
|
43
|
+
|
|
44
|
+
var enqueueSnackbar = useCallback(function (message, options) {
|
|
45
|
+
var id = options.id,
|
|
46
|
+
_options$variant = options.variant,
|
|
47
|
+
variant = _options$variant === void 0 ? "success" : _options$variant,
|
|
48
|
+
snackbarContentProps = options.snackbarContentProps,
|
|
49
|
+
otherOptions = _objectWithoutProperties(options, _excluded);
|
|
50
|
+
|
|
51
|
+
enqueueNotistackSnackbar( /*#__PURE__*/React.createElement(HvNotistackSnackMessage, {
|
|
52
|
+
id: id,
|
|
53
|
+
message: message,
|
|
54
|
+
variant: variant,
|
|
55
|
+
snackbarContentProps: snackbarContentProps
|
|
56
|
+
}), otherOptions);
|
|
57
|
+
}, [enqueueNotistackSnackbar]);
|
|
58
|
+
return useMemo(function () {
|
|
59
|
+
return {
|
|
60
|
+
enqueueSnackbar: enqueueSnackbar,
|
|
61
|
+
closeSnackbar: closeSnackbar
|
|
62
|
+
};
|
|
63
|
+
}, [enqueueSnackbar, closeSnackbar]);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var useStyles = function useStyles(notistackClassesOverride) {
|
|
67
|
+
return makeStyles(function () {
|
|
68
|
+
return _objectSpread({
|
|
69
|
+
containerRoot: {
|
|
70
|
+
"& > div > div": {
|
|
71
|
+
// Overrides notistack extra padding
|
|
72
|
+
padding: "0 !important",
|
|
73
|
+
transition: "all 0s ease 0s !important",
|
|
74
|
+
"& > div > div > div": {
|
|
75
|
+
color: "inherit",
|
|
76
|
+
padding: "0",
|
|
77
|
+
fontSize: "inherit",
|
|
78
|
+
boxShadow: "none",
|
|
79
|
+
alignItems: "center",
|
|
80
|
+
fontFamily: "inherit",
|
|
81
|
+
fontWeight: "inherit",
|
|
82
|
+
lineHeight: "inherit",
|
|
83
|
+
borderRadius: "0",
|
|
84
|
+
letterSpacing: "inherit",
|
|
85
|
+
backgroundColor: "inherit"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, notistackClassesOverride);
|
|
90
|
+
})();
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
var HvSnackbarProvider = function HvSnackbarProvider(_ref2) {
|
|
94
|
+
var children = _ref2.children,
|
|
95
|
+
_ref2$notistackClasse = _ref2.notistackClassesOverride,
|
|
96
|
+
notistackClassesOverride = _ref2$notistackClasse === void 0 ? {} : _ref2$notistackClasse,
|
|
97
|
+
_ref2$maxSnack = _ref2.maxSnack,
|
|
98
|
+
maxSnack = _ref2$maxSnack === void 0 ? 5 : _ref2$maxSnack,
|
|
99
|
+
_ref2$autoHideDuratio = _ref2.autoHideDuration,
|
|
100
|
+
autoHideDuration = _ref2$autoHideDuratio === void 0 ? 5000 : _ref2$autoHideDuratio,
|
|
101
|
+
_ref2$anchorOrigin = _ref2.anchorOrigin,
|
|
102
|
+
anchorOrigin = _ref2$anchorOrigin === void 0 ? {
|
|
103
|
+
vertical: "top",
|
|
104
|
+
horizontal: "right"
|
|
105
|
+
} : _ref2$anchorOrigin,
|
|
106
|
+
others = _objectWithoutProperties(_ref2, _excluded2);
|
|
107
|
+
|
|
108
|
+
var classes = useStyles(notistackClassesOverride);
|
|
109
|
+
return /*#__PURE__*/React.createElement(SnackbarProvider, _extends({
|
|
110
|
+
classes: _objectSpread({}, classes),
|
|
111
|
+
maxSnack: maxSnack,
|
|
112
|
+
autoHideDuration: autoHideDuration,
|
|
113
|
+
anchorOrigin: anchorOrigin
|
|
114
|
+
}, others), children);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
process.env.NODE_ENV !== "production" ? HvSnackbarProvider.propTypes = {
|
|
118
|
+
/**
|
|
119
|
+
* Your component tree.
|
|
120
|
+
*/
|
|
121
|
+
children: PropTypes.node.isRequired,
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Max visible snackbars.
|
|
125
|
+
*/
|
|
126
|
+
maxSnack: PropTypes.number,
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* How much time the snackbar remains visible in milliseconds.
|
|
130
|
+
*/
|
|
131
|
+
autoHideDuration: PropTypes.number,
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Where is the snackbar placed.
|
|
135
|
+
*/
|
|
136
|
+
anchorOrigin: PropTypes.shape({
|
|
137
|
+
vertical: PropTypes.oneOf(["top", "bottom"]),
|
|
138
|
+
horizontal: PropTypes.oneOf(["right", "left"])
|
|
139
|
+
}),
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Class object used to override notistack classes.
|
|
143
|
+
*/
|
|
144
|
+
notistackClassesOverride: PropTypes.instanceOf(Object)
|
|
145
|
+
} : void 0;
|
|
146
|
+
process.env.NODE_ENV !== "production" ? HvNotistackSnackMessage.propTypes = {
|
|
147
|
+
/**
|
|
148
|
+
* Id to be applied to the root node.
|
|
149
|
+
*/
|
|
150
|
+
id: PropTypes.string,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Your component tree.
|
|
154
|
+
*/
|
|
155
|
+
message: PropTypes.string,
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Variant of the snackbar.
|
|
159
|
+
*/
|
|
160
|
+
variant: PropTypes.oneOf(["default", "success", "error"]),
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Extra values to pass to the snackbar.
|
|
164
|
+
*/
|
|
165
|
+
snackbarContentProps: PropTypes.instanceOf(Object)
|
|
166
|
+
} : void 0;
|
|
167
|
+
export default HvSnackbarProvider;
|
|
168
|
+
export { useHvSnackbar };
|
|
169
|
+
//# sourceMappingURL=SnackbarProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/Snackbar/SnackbarProvider/SnackbarProvider.js"],"names":["React","forwardRef","useCallback","useMemo","makeStyles","PropTypes","SnackbarProvider","SnackbarContent","useSnackbar","HvSnackbarContentWrapper","HvNotistackSnackMessage","ref","id","message","variant","snackbarContentProps","useHvSnackbar","enqueueNotistackSnackbar","enqueueSnackbar","closeSnackbar","options","otherOptions","useStyles","notistackClassesOverride","containerRoot","padding","transition","color","fontSize","boxShadow","alignItems","fontFamily","fontWeight","lineHeight","borderRadius","letterSpacing","backgroundColor","HvSnackbarProvider","children","maxSnack","autoHideDuration","anchorOrigin","vertical","horizontal","others","classes","propTypes","node","isRequired","number","shape","oneOf","instanceOf","Object","string"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,UA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C,KAAV,CAAgB,CAAC,SAAD,EAAY,SAAZ,EAAuB,OAAvB,CAAhB,CAZyB;;AAalC;AACF;AACA;AACEpC,EAAAA,oBAAoB,EAAEV,SAAS,CAAC+C,UAAV,CAAqBC,MAArB;AAhBY,CAApC;AAmBA,eAAehB,kBAAf;AACA,SAASrB,aAAT","sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { makeStyles } from \"@material-ui/core\";\nimport PropTypes from \"prop-types\";\nimport { SnackbarProvider, SnackbarContent, useSnackbar } from \"notistack\";\n\nimport HvSnackbarContentWrapper from \"../SnackbarContentWrapper\";\n\nconst HvNotistackSnackMessage = forwardRef(\n ({ id, message, variant = \"success\", snackbarContentProps }, ref) => {\n return (\n <SnackbarContent ref={ref}>\n <HvSnackbarContentWrapper\n id={id}\n variant={variant}\n showIcon\n label={message}\n {...snackbarContentProps}\n />\n </SnackbarContent>\n );\n }\n);\n\n// We override notistack hook to be able to customize the snackbar that should be called.\nconst useHvSnackbar = () => {\n const { enqueueSnackbar: enqueueNotistackSnackbar, closeSnackbar } = useSnackbar();\n const enqueueSnackbar = useCallback(\n (message, options) => {\n const { id, variant = \"success\", snackbarContentProps, ...otherOptions } = options;\n\n enqueueNotistackSnackbar(\n <HvNotistackSnackMessage\n id={id}\n message={message}\n variant={variant}\n snackbarContentProps={snackbarContentProps}\n />,\n otherOptions\n );\n },\n [enqueueNotistackSnackbar]\n );\n return useMemo(\n () => ({\n enqueueSnackbar,\n closeSnackbar,\n }),\n [enqueueSnackbar, closeSnackbar]\n );\n};\n\nconst useStyles = (notistackClassesOverride) =>\n makeStyles(() => ({\n containerRoot: {\n \"& > div > div\": {\n // Overrides notistack extra padding\n padding: \"0 !important\",\n transition: \"all 0s ease 0s !important\",\n \"& > div > div > div\": {\n color: \"inherit\",\n padding: \"0\",\n fontSize: \"inherit\",\n boxShadow: \"none\",\n alignItems: \"center\",\n fontFamily: \"inherit\",\n fontWeight: \"inherit\",\n lineHeight: \"inherit\",\n borderRadius: \"0\",\n letterSpacing: \"inherit\",\n backgroundColor: \"inherit\",\n },\n },\n },\n ...notistackClassesOverride,\n }))();\n\nconst HvSnackbarProvider = ({\n children,\n notistackClassesOverride = {},\n maxSnack = 5,\n autoHideDuration = 5000,\n anchorOrigin = {\n vertical: \"top\",\n horizontal: \"right\",\n },\n ...others\n}) => {\n const classes = useStyles(notistackClassesOverride);\n\n return (\n <SnackbarProvider\n classes={{\n ...classes,\n }}\n maxSnack={maxSnack}\n autoHideDuration={autoHideDuration}\n anchorOrigin={anchorOrigin}\n {...others}\n >\n {children}\n </SnackbarProvider>\n );\n};\n\nHvSnackbarProvider.propTypes = {\n /**\n * Your component tree.\n */\n children: PropTypes.node.isRequired,\n /**\n * Max visible snackbars.\n */\n maxSnack: PropTypes.number,\n /**\n * How much time the snackbar remains visible in milliseconds.\n */\n autoHideDuration: PropTypes.number,\n /**\n * Where is the snackbar placed.\n */\n anchorOrigin: PropTypes.shape({\n vertical: PropTypes.oneOf([\"top\", \"bottom\"]),\n horizontal: PropTypes.oneOf([\"right\", \"left\"]),\n }),\n /**\n * Class object used to override notistack classes.\n */\n notistackClassesOverride: PropTypes.instanceOf(Object),\n};\n\nHvNotistackSnackMessage.propTypes = {\n /**\n * Id to be applied to the root node.\n */\n id: PropTypes.string,\n /**\n * Your component tree.\n */\n message: PropTypes.string,\n /**\n * Variant of the snackbar.\n */\n variant: PropTypes.oneOf([\"default\", \"success\", \"error\"]),\n /**\n * Extra values to pass to the snackbar.\n */\n snackbarContentProps: PropTypes.instanceOf(Object),\n};\n\nexport default HvSnackbarProvider;\nexport { useHvSnackbar };\n"],"file":"SnackbarProvider.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/Snackbar/SnackbarProvider/index.js"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,oBAAxB;AACA,cAAc,oBAAd","sourcesContent":["export { default } from \"./SnackbarProvider\";\nexport * from \"./SnackbarProvider\";\n"],"file":"index.js"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Meta, Story, Preview } from "@storybook/addon-docs";
|
|
2
|
+
|
|
3
|
+
import LinkTo from "@storybook/addon-links/react";
|
|
4
|
+
|
|
5
|
+
import { Usage } from "storybook-root/blocks/Usage";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
SnackbarProvider,
|
|
9
|
+
} from "./SnackbarProvider.stories.js";
|
|
10
|
+
|
|
11
|
+
<Meta title="Components/Snackbar/Provider" />
|
|
12
|
+
|
|
13
|
+
# Snackbar Provider
|
|
14
|
+
|
|
15
|
+
The UI Kit library provides a snackbar provider
|
|
16
|
+
to control the stacking of multiple snackbars in the app.
|
|
17
|
+
|
|
18
|
+
The providers is not meant to be 100% feature complete, but instead,
|
|
19
|
+
ease the majority of use-cases we have been encountering.
|
|
20
|
+
If you need any customization or extension to the behavior,
|
|
21
|
+
please feel free to copy and customize it.
|
|
22
|
+
|
|
23
|
+
This feature needs both the *HvSnackbarProvider* provider and the hook *useHvSnackbar*.
|
|
24
|
+
The provider and the hook are wrappers of the [Notistack](https://github.com/iamhosseindhv/notistack) API.
|
|
25
|
+
|
|
26
|
+
Ideally the `HvSnackbarProvider` should be at the top of the component tree of your application.
|
|
27
|
+
This will allow the snackbar to be triggered in any page.
|
|
28
|
+
For more information of the provider API check the [notistack documentation](https://iamhosseindhv.com/notistack/api).
|
|
29
|
+
|
|
30
|
+
<Usage>{'import { HvSnackbarProvider } from "@hitachivantara/uikit-react-core";'}</Usage>
|
|
31
|
+
|
|
32
|
+
After adding the provider at the root of your app, you can call the ```useHvSnackbar``` at any
|
|
33
|
+
component inside your app. This hook will allow you to request the rendering of a snackbar through the use
|
|
34
|
+
of the ```enqueueSnackbar``` function which follows the API bellow:
|
|
35
|
+
|
|
36
|
+
parameters:
|
|
37
|
+
- `message: string | React.node`: The message to render inside the snackbar.
|
|
38
|
+
- `options: HvEnqueueOptions`: The options to configure the snackbar.
|
|
39
|
+
- `HvEnqueueOptions`:
|
|
40
|
+
- `id?: string`: The id to pass to the snackbar
|
|
41
|
+
- `variant: success | default | warning`: The color of the snackbar
|
|
42
|
+
- `snackbarContentProps?: HvSnackbarContentProps`: Extra properties to be passed onto the snackbar
|
|
43
|
+
|
|
44
|
+
output:
|
|
45
|
+
- `SnackbarKey: string | number`: How many snackbars to render.
|
|
46
|
+
|
|
47
|
+
<Usage>{'import { useHvSnackbar } from "@hitachivantara/uikit-react-core";'}</Usage>
|
|
48
|
+
|
|
49
|
+
<Preview withToolbar>
|
|
50
|
+
<Story inline story={SnackbarProvider} />
|
|
51
|
+
</Preview>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { StandardProps } from "@material-ui/core";
|
|
2
2
|
import { HvTagProps } from "../Tag/Tag";
|
|
3
3
|
import { HvCharCounterProps } from "../Forms/CharCounter";
|
|
4
|
+
import { HvFormStatus } from "../Forms/FormElement";
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import { HvInputProps } from "..";
|
|
7
|
+
import { HvBaseInputValidationMessagesProps } from "../BaseInput";
|
|
6
8
|
|
|
7
9
|
export type HvTagsInputClassKey =
|
|
8
10
|
| "root"
|
|
@@ -12,10 +14,11 @@ export type HvTagsInputClassKey =
|
|
|
12
14
|
| "labelContainer"
|
|
13
15
|
| "label"
|
|
14
16
|
| "characterCounter"
|
|
15
|
-
| "description"
|
|
17
|
+
| "description"
|
|
18
|
+
| "error";
|
|
16
19
|
|
|
17
20
|
export interface HvTagsInputProps
|
|
18
|
-
extends StandardProps<
|
|
21
|
+
extends StandardProps<HvInputProps, HvTagsInputClassKey, "onChange" | "onBlur"> {
|
|
19
22
|
/**
|
|
20
23
|
* The label of the form element.
|
|
21
24
|
*
|
|
@@ -48,6 +51,10 @@ export interface HvTagsInputProps
|
|
|
48
51
|
* Indicates that the form element is not editable.
|
|
49
52
|
*/
|
|
50
53
|
readOnly?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Indicates that the form element is required.
|
|
56
|
+
*/
|
|
57
|
+
required?: boolean;
|
|
51
58
|
|
|
52
59
|
/**
|
|
53
60
|
* If `true` it should autofocus.
|
|
@@ -95,7 +102,29 @@ export interface HvTagsInputProps
|
|
|
95
102
|
/**
|
|
96
103
|
* Called back when the value is changed.
|
|
97
104
|
*/
|
|
98
|
-
onChange?: (
|
|
105
|
+
onChange?: (
|
|
106
|
+
event:
|
|
107
|
+
| React.ChangeEvent<HTMLInputElement>
|
|
108
|
+
| React.KeyboardEvent<HTMLInputElement>
|
|
109
|
+
| React.MouseEvent<HTMLButtonElement>
|
|
110
|
+
| React.MouseEvent<HTMLElement, MouseEvent>
|
|
111
|
+
| React.KeyboardEventHandler<HTMLElement>,
|
|
112
|
+
value: HvTagProps[]
|
|
113
|
+
) => void;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The status of the form element.
|
|
117
|
+
*/
|
|
118
|
+
status?: HvFormStatus;
|
|
119
|
+
/**
|
|
120
|
+
* The error message to show when `status` is "invalid".
|
|
121
|
+
*/
|
|
122
|
+
statusMessage?: React.ReactNode;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* An Object containing the various texts associated with the input.
|
|
126
|
+
*/
|
|
127
|
+
validationMessages?: HvBaseInputValidationMessagesProps;
|
|
99
128
|
}
|
|
100
129
|
|
|
101
130
|
export default function HvTagsInput(props: HvTagsInputProps): JSX.Element | null;
|