@ceed/cds 0.0.125 → 0.0.127

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.
Files changed (101) hide show
  1. package/dist/components/Accordions/Accordions.js +72 -0
  2. package/dist/components/Accordions/index.js +19 -0
  3. package/dist/components/Autocomplete/Autocomplete.js +280 -0
  4. package/dist/components/Autocomplete/index.js +19 -0
  5. package/dist/components/Box/Box.js +9 -0
  6. package/dist/components/Box/index.js +19 -0
  7. package/dist/components/Breadcrumbs/Breadcrumbs.js +96 -0
  8. package/dist/components/Breadcrumbs/index.js +19 -0
  9. package/dist/components/Button/Button.js +54 -0
  10. package/dist/components/Button/index.js +19 -0
  11. package/dist/components/Calendar/Calendar.js +412 -0
  12. package/dist/components/Calendar/hooks/use-calendar-props.js +84 -0
  13. package/dist/components/Calendar/hooks/use-calendar.js +248 -0
  14. package/dist/components/Calendar/index.js +19 -0
  15. package/dist/components/Calendar/types.js +2 -0
  16. package/dist/components/Calendar/utils/index.js +84 -0
  17. package/dist/components/Card/Card.js +25 -0
  18. package/dist/components/Card/index.js +19 -0
  19. package/dist/components/Checkbox/Checkbox.js +34 -0
  20. package/dist/components/Checkbox/index.js +19 -0
  21. package/dist/components/Chip/Chip.js +9 -0
  22. package/dist/components/Chip/index.js +19 -0
  23. package/dist/components/Container/Container.js +91 -0
  24. package/dist/components/Container/index.js +19 -0
  25. package/dist/components/CurrencyInput/CurrencyInput.js +137 -0
  26. package/dist/components/CurrencyInput/hooks/use-currency-setting.js +172 -0
  27. package/dist/components/CurrencyInput/index.js +19 -0
  28. package/dist/components/DataTable/DataTable.js +466 -0
  29. package/dist/components/DataTable/index.js +19 -0
  30. package/dist/components/DataTable/types.js +2 -0
  31. package/dist/components/DatePicker/DatePicker.js +236 -0
  32. package/dist/components/DatePicker/index.js +19 -0
  33. package/dist/components/DateRangePicker/DateRangePicker.js +238 -0
  34. package/dist/components/DateRangePicker/index.js +19 -0
  35. package/dist/components/DialogActions/DialogActions.js +18 -0
  36. package/dist/components/DialogActions/index.js +19 -0
  37. package/dist/components/DialogContent/DialogContent.js +15 -0
  38. package/dist/components/DialogContent/index.js +19 -0
  39. package/dist/components/DialogFrame/DialogFrame.js +57 -0
  40. package/dist/components/DialogFrame/index.js +19 -0
  41. package/dist/components/DialogTitle/DialogTitle.js +15 -0
  42. package/dist/components/DialogTitle/index.js +19 -0
  43. package/dist/components/Divider/Divider.js +34 -0
  44. package/dist/components/Divider/index.js +19 -0
  45. package/dist/components/Dropdown/Dropdown.js +9 -0
  46. package/dist/components/Dropdown/index.js +19 -0
  47. package/dist/components/FormControl/FormControl.js +20 -0
  48. package/dist/components/FormControl/index.js +19 -0
  49. package/dist/components/FormHelperText/FormHelperText.js +9 -0
  50. package/dist/components/FormHelperText/index.js +19 -0
  51. package/dist/components/FormLabel/FormLabel.js +9 -0
  52. package/dist/components/FormLabel/index.js +19 -0
  53. package/dist/components/Grid/Grid.js +9 -0
  54. package/dist/components/Grid/index.js +19 -0
  55. package/dist/components/IconButton/IconButton.js +34 -0
  56. package/dist/components/IconButton/index.js +19 -0
  57. package/dist/components/Input/Input.js +57 -0
  58. package/dist/components/Input/index.js +19 -0
  59. package/dist/components/InsetDrawer/InsetDrawer.js +51 -0
  60. package/dist/components/InsetDrawer/index.js +19 -0
  61. package/dist/components/Markdown/Markdown.js +65 -0
  62. package/dist/components/Markdown/index.js +19 -0
  63. package/dist/components/Menu/Menu.js +62 -0
  64. package/dist/components/Menu/index.js +19 -0
  65. package/dist/components/Modal/Modal.js +69 -0
  66. package/dist/components/Modal/index.js +19 -0
  67. package/dist/components/MonthPicker/MonthPicker.js +232 -0
  68. package/dist/components/MonthPicker/index.js +19 -0
  69. package/dist/components/MonthRangePicker/MonthRangePicker.js +236 -0
  70. package/dist/components/MonthRangePicker/index.js +19 -0
  71. package/dist/components/Radio/Radio.js +13 -0
  72. package/dist/components/Radio/index.js +19 -0
  73. package/dist/components/RadioList/RadioList.js +44 -0
  74. package/dist/components/RadioList/index.js +19 -0
  75. package/dist/components/Select/Select.js +105 -0
  76. package/dist/components/Select/index.js +19 -0
  77. package/dist/components/Sheet/Sheet.js +9 -0
  78. package/dist/components/Sheet/index.js +19 -0
  79. package/dist/components/Stack/Stack.js +9 -0
  80. package/dist/components/Stack/index.js +19 -0
  81. package/dist/components/Switch/Switch.js +60 -0
  82. package/dist/components/Switch/index.js +19 -0
  83. package/dist/components/Table/Table.js +95 -0
  84. package/dist/components/Table/index.js +19 -0
  85. package/dist/components/Tabs/Tabs.js +21 -0
  86. package/dist/components/Tabs/index.js +19 -0
  87. package/dist/components/Textarea/Textarea.js +56 -0
  88. package/dist/components/Textarea/index.js +19 -0
  89. package/dist/components/ThemeProvider/ThemeProvider.js +165 -0
  90. package/dist/components/ThemeProvider/index.js +19 -0
  91. package/dist/components/Tooltip/Tooltip.js +34 -0
  92. package/dist/components/Tooltip/index.js +19 -0
  93. package/dist/components/Typography/Typography.js +34 -0
  94. package/dist/components/Typography/index.js +19 -0
  95. package/dist/components/Uploader/Uploader.js +378 -0
  96. package/dist/components/Uploader/index.js +19 -0
  97. package/dist/components/index.js +108 -0
  98. package/dist/index.js +169 -1
  99. package/dist/index.mjs +1 -0
  100. package/package.json +5 -6
  101. package/dist/index.cjs +0 -1
@@ -0,0 +1,137 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __rest = (this && this.__rest) || function (s, e) {
37
+ var t = {};
38
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
39
+ t[p] = s[p];
40
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
41
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
42
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
43
+ t[p[i]] = s[p[i]];
44
+ }
45
+ return t;
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.CurrencyInput = void 0;
52
+ var react_1 = __importStar(require("react"));
53
+ var intl_messageformat_1 = require("intl-messageformat");
54
+ var react_number_format_1 = require("react-number-format");
55
+ var Input_1 = __importDefault(require("../Input"));
56
+ var FormControl_1 = __importDefault(require("../FormControl"));
57
+ var FormLabel_1 = __importDefault(require("../FormLabel"));
58
+ var FormHelperText_1 = __importDefault(require("../FormHelperText"));
59
+ var use_currency_setting_1 = require("./hooks/use-currency-setting");
60
+ var TextMaskAdapter = react_1.default.forwardRef(function TextMaskAdapter(props, ref) {
61
+ // prop destruction
62
+ var onChange = props.onChange, innerProps = __rest(props, ["onChange"]);
63
+ // lib hooks
64
+ // state, ref, querystring hooks
65
+ // form hooks
66
+ // query hooks
67
+ // calculated values
68
+ // effects
69
+ // handlers
70
+ return (react_1.default.createElement(react_number_format_1.NumericFormat, __assign({}, innerProps, { onValueChange: function (_a) {
71
+ var value = _a.value;
72
+ onChange === null || onChange === void 0 ? void 0 : onChange({
73
+ target: { name: props.name, value: value },
74
+ });
75
+ }, valueIsNumericString: true, getInputRef: ref, allowNegative: false })));
76
+ });
77
+ var CurrencyInput = react_1.default.forwardRef(function CurrencyInput(props, ref) {
78
+ // prop destruction
79
+ var _a = props.currency, currency = _a === void 0 ? "USD" : _a, name = props.name, onChange = props.onChange, label = props.label, error = props.error, helperText = props.helperText, required = props.required, disabled = props.disabled, useMinorUnit = props.useMinorUnit, innerProps = __rest(props, ["currency", "name", "onChange", "label", "error", "helperText", "required", "disabled", "useMinorUnit"]);
80
+ // lib hooks
81
+ var _b = (0, use_currency_setting_1.useCurrencySetting)(currency), symbol = _b.symbol, thousandSeparator = _b.thousandSeparator, decimalSeparator = _b.decimalSeparator, placeholder = _b.placeholder, fixedDecimalScale = _b.fixedDecimalScale, decimalScale = _b.decimalScale;
82
+ // state, ref, querystring hooks
83
+ var _c = (0, react_1.useState)(props.value), _value = _c[0], setValue = _c[1];
84
+ var value = (0, react_1.useMemo)(function () {
85
+ if (_value && useMinorUnit) {
86
+ return _value / Math.pow(10, decimalScale);
87
+ }
88
+ return _value;
89
+ }, [_value, useMinorUnit, decimalScale]);
90
+ var max = (0, react_1.useMemo)(function () {
91
+ if (props.max && useMinorUnit) {
92
+ return props.max / Math.pow(10, decimalScale);
93
+ }
94
+ return props.max;
95
+ }, [props.max, useMinorUnit, decimalScale]);
96
+ var _d = (0, react_1.useState)(!!max && !!value && value > max), isOverLimit = _d[0], setIsOverLimit = _d[1];
97
+ // form hooks
98
+ // query hooks
99
+ // calculated values
100
+ // effects
101
+ // handlers
102
+ var handleChange = (0, react_1.useCallback)(function (event) {
103
+ var _a;
104
+ var amount = useMinorUnit
105
+ ? Number((_a = event.target.value) === null || _a === void 0 ? void 0 : _a.replace(decimalSeparator, ""))
106
+ : Number(event.target.value);
107
+ if (!!max && Number(event.target.value) > max) {
108
+ setIsOverLimit(true);
109
+ }
110
+ else {
111
+ setIsOverLimit(false);
112
+ }
113
+ setValue(amount);
114
+ onChange === null || onChange === void 0 ? void 0 : onChange(__assign(__assign({}, event), { target: { name: name, value: amount } }));
115
+ }, [decimalSeparator, max, name, onChange, useMinorUnit]);
116
+ var currencyFormatter = (react_1.default.createElement(Input_1.default, __assign({}, innerProps, { size: "sm", ref: ref, value: value, placeholder: placeholder, onChange: handleChange, disabled: disabled, required: required, color: error || isOverLimit ? "danger" : props.color, slotProps: {
117
+ input: {
118
+ component: TextMaskAdapter,
119
+ decimalSeparator: decimalSeparator,
120
+ thousandSeparator: thousandSeparator,
121
+ prefix: symbol,
122
+ fixedDecimalScale: fixedDecimalScale,
123
+ decimalScale: decimalScale,
124
+ "aria-label": innerProps["aria-label"],
125
+ },
126
+ }, sx: {
127
+ fontFamily: "monospace",
128
+ } })));
129
+ if (label) {
130
+ return (react_1.default.createElement(FormControl_1.default, { size: "sm", disabled: disabled, required: required, error: error || isOverLimit },
131
+ react_1.default.createElement(FormLabel_1.default, null, label),
132
+ currencyFormatter,
133
+ isOverLimit ? (react_1.default.createElement(FormHelperText_1.default, null, new intl_messageformat_1.IntlMessageFormat("limit: {amount, number, ::currency/".concat(currency, " unit-width-narrow}")).format({ amount: max }))) : (helperText && react_1.default.createElement(FormHelperText_1.default, null, helperText))));
134
+ }
135
+ return currencyFormatter;
136
+ });
137
+ exports.CurrencyInput = CurrencyInput;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useCurrencySetting = void 0;
7
+ var intl_messageformat_1 = __importDefault(require("intl-messageformat"));
8
+ /**
9
+ * @see https://docs.adyen.com/development-resources/currency-codes/
10
+ */
11
+ var CURRENCY_DECIMAL_MAP = {
12
+ AED: 2,
13
+ ALL: 2,
14
+ AMD: 2,
15
+ ANG: 2,
16
+ AOA: 2,
17
+ ARS: 2,
18
+ AUD: 2,
19
+ AWG: 2,
20
+ AZN: 2,
21
+ BAM: 2,
22
+ BBD: 2,
23
+ BDT: 2,
24
+ BGN: 2,
25
+ BHD: 3,
26
+ BMD: 2,
27
+ BND: 2,
28
+ BOB: 2,
29
+ BRL: 2,
30
+ BSD: 2,
31
+ BWP: 2,
32
+ BYN: 2,
33
+ BZD: 2,
34
+ CAD: 2,
35
+ CHF: 2,
36
+ CLP: 2,
37
+ CNH: 2,
38
+ CNY: 2,
39
+ COP: 2,
40
+ CRC: 2,
41
+ CUP: 2,
42
+ CVE: 0,
43
+ CZK: 2,
44
+ DJF: 0,
45
+ DKK: 2,
46
+ DOP: 2,
47
+ DZD: 2,
48
+ EGP: 2,
49
+ ETB: 2,
50
+ EUR: 2,
51
+ FJD: 2,
52
+ FKP: 2,
53
+ GBP: 2,
54
+ GEL: 2,
55
+ GHS: 2,
56
+ GIP: 2,
57
+ GMD: 2,
58
+ GNF: 0,
59
+ GTQ: 2,
60
+ GYD: 2,
61
+ HKD: 2,
62
+ HNL: 2,
63
+ HTG: 2,
64
+ HUF: 2,
65
+ IDR: 0,
66
+ ILS: 2,
67
+ INR: 2,
68
+ IQD: 3,
69
+ ISK: 2,
70
+ JMD: 2,
71
+ JOD: 3,
72
+ JPY: 0,
73
+ KES: 2,
74
+ KGS: 2,
75
+ KHR: 2,
76
+ KMF: 0,
77
+ KRW: 0,
78
+ KWD: 3,
79
+ KYD: 2,
80
+ KZT: 2,
81
+ LAK: 2,
82
+ LBP: 2,
83
+ LKR: 2,
84
+ LYD: 3,
85
+ MAD: 2,
86
+ MDL: 2,
87
+ MKD: 2,
88
+ MMK: 2,
89
+ MNT: 2,
90
+ MOP: 2,
91
+ MRU: 2,
92
+ MUR: 2,
93
+ MVR: 2,
94
+ MWK: 2,
95
+ MXN: 2,
96
+ MYR: 2,
97
+ MZN: 2,
98
+ NAD: 2,
99
+ NGN: 2,
100
+ NIO: 2,
101
+ NOK: 2,
102
+ NPR: 2,
103
+ NZD: 2,
104
+ OMR: 3,
105
+ PAB: 2,
106
+ PEN: 2,
107
+ PGK: 2,
108
+ PHP: 2,
109
+ PKR: 2,
110
+ PLN: 2,
111
+ PYG: 0,
112
+ QAR: 2,
113
+ RON: 2,
114
+ RSD: 2,
115
+ RUB: 2,
116
+ RWF: 0,
117
+ SAR: 2,
118
+ SBD: 2,
119
+ SCR: 2,
120
+ SEK: 2,
121
+ SGD: 2,
122
+ SHP: 2,
123
+ SLE: 2,
124
+ SOS: 2,
125
+ SRD: 2,
126
+ STN: 2,
127
+ SVC: 2,
128
+ SZL: 2,
129
+ THB: 2,
130
+ TND: 3,
131
+ TOP: 2,
132
+ TRY: 2,
133
+ TTD: 2,
134
+ TWD: 2,
135
+ TZS: 2,
136
+ UAH: 2,
137
+ UGX: 0,
138
+ USD: 2,
139
+ UYU: 2,
140
+ UZS: 2,
141
+ VEF: 2,
142
+ VND: 0,
143
+ VUV: 0,
144
+ WST: 2,
145
+ XAF: 0,
146
+ XCD: 2,
147
+ XOF: 0,
148
+ XPF: 0,
149
+ YER: 2,
150
+ ZAR: 2,
151
+ ZMW: 2,
152
+ };
153
+ var useCurrencySetting = function (currencyCode) {
154
+ if (currencyCode === void 0) { currencyCode = "USD"; }
155
+ var _a = new intl_messageformat_1.default("{amount, number, ::currency/".concat(currencyCode, " unit-width-narrow}"))
156
+ .format({ amount: 1000 })
157
+ .toString()
158
+ .replace(/\d/g, "")
159
+ .split(""), symbol = _a[0], thousandSeparator = _a[1], decimalSeparator = _a[2], rest = _a.slice(3);
160
+ var decimalScale = CURRENCY_DECIMAL_MAP[currencyCode];
161
+ return {
162
+ symbol: "".concat(symbol, " "),
163
+ thousandSeparator: thousandSeparator,
164
+ decimalSeparator: decimalSeparator,
165
+ placeholder: decimalSeparator
166
+ ? "".concat(symbol, " 0").concat(decimalSeparator).concat(Array.from(Array(decimalScale)).map(function () { return 0; }).join(''))
167
+ : "".concat(symbol, " 0"),
168
+ fixedDecimalScale: !!decimalSeparator,
169
+ decimalScale: decimalScale,
170
+ };
171
+ };
172
+ exports.useCurrencySetting = useCurrencySetting;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ var CurrencyInput_1 = require("./CurrencyInput");
18
+ __exportStar(require("./CurrencyInput"), exports);
19
+ exports.default = CurrencyInput_1.CurrencyInput;