@ballistix.digital/react-components 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -22,10 +22,10 @@ var $iA2ta$dndkitmodifiers = require("@dnd-kit/modifiers");
22
22
  var $iA2ta$dndkitsortable = require("@dnd-kit/sortable");
23
23
  var $iA2ta$dndkitutilities = require("@dnd-kit/utilities");
24
24
  var $iA2ta$lodashset = require("lodash/set");
25
+ var $iA2ta$luxon = require("luxon");
25
26
  var $iA2ta$reacttailwindcssdatepicker = require("react-tailwindcss-datepicker");
26
27
  var $iA2ta$formik = require("formik");
27
28
  var $iA2ta$reactdropzone = require("react-dropzone");
28
- var $iA2ta$luxon = require("luxon");
29
29
  var $iA2ta$ubilabsreactgeosuggest = require("@ubilabs/react-geosuggest");
30
30
 
31
31
 
@@ -66,6 +66,23 @@ $parcel$export(module.exports, "TableColumnOptionsCustom", () => $4bd12ae33d8a86
66
66
  $parcel$export(module.exports, "TableExportCustom", () => $48dedbf2c7043ee6$export$2e2bcd8739ae039);
67
67
  $parcel$export(module.exports, "SelectMenuForm", () => $f3fccf014e1f10d5$export$2e2bcd8739ae039);
68
68
  $parcel$export(module.exports, "fromSelectMenuOptionToStringValue", () => $622cd2936b18c771$export$7493424cf90fe793);
69
+ $parcel$export(module.exports, "toClassName", () => $622cd2936b18c771$export$4370d69198e9314a);
70
+ $parcel$export(module.exports, "toAddressString", () => $622cd2936b18c771$export$91d20e9290e3c358);
71
+ $parcel$export(module.exports, "toAddressUrl", () => $622cd2936b18c771$export$ba96624aa3b67894);
72
+ $parcel$export(module.exports, "toNationalRegistryNumberString", () => $622cd2936b18c771$export$f3f93e5bb54c3de5);
73
+ $parcel$export(module.exports, "toPriceString", () => $622cd2936b18c771$export$648c405ef8d23fec);
74
+ $parcel$export(module.exports, "toReadableFileSize", () => $622cd2936b18c771$export$155f7ed6f228c17c);
75
+ $parcel$export(module.exports, "toUserName", () => $622cd2936b18c771$export$b2669f8969cc59be);
76
+ $parcel$export(module.exports, "toUserInitials", () => $622cd2936b18c771$export$d9f806f9324c35ff);
77
+ $parcel$export(module.exports, "toDateString", () => $dbcba7ef8eeead3b$export$b7c4e1545c61edee);
78
+ $parcel$export(module.exports, "toTimeString", () => $dbcba7ef8eeead3b$export$b489b1fb1454ddcf);
79
+ $parcel$export(module.exports, "isValidDate", () => $dbcba7ef8eeead3b$export$c03bb0116ee09d4b);
80
+ $parcel$export(module.exports, "toDateTimeString", () => $dbcba7ef8eeead3b$export$9b56e83e909e2c38);
81
+ $parcel$export(module.exports, "toDaysDifference", () => $dbcba7ef8eeead3b$export$1771f44233a5f72);
82
+ $parcel$export(module.exports, "latestDateString", () => $dbcba7ef8eeead3b$export$8649d02bd537ff66);
83
+ $parcel$export(module.exports, "toDateValue", () => $dbcba7ef8eeead3b$export$df20409d3177a2e0);
84
+ $parcel$export(module.exports, "toTimeValue", () => $dbcba7ef8eeead3b$export$8a6f307d1b8b1960);
85
+ $parcel$export(module.exports, "toUTCDate", () => $dbcba7ef8eeead3b$export$8de20099c30464f2);
69
86
  $parcel$export(module.exports, "DateMenuForm", () => $754fdbc7ee597008$export$2e2bcd8739ae039);
70
87
  $parcel$export(module.exports, "DateRangeMenuForm", () => $6590abe4bc5376d5$export$2e2bcd8739ae039);
71
88
  $parcel$export(module.exports, "__DEPRECATED__CheckboxInputGroupForm", () => $03635ab4c6dbf412$export$2e2bcd8739ae039);
@@ -75,6 +92,8 @@ $parcel$export(module.exports, "FileInputGroupForm", () => $079d45c48b1515dd$exp
75
92
  $parcel$export(module.exports, "OpeningsHourInputGroupForm", () => $9f6cfd21b337aca9$export$2e2bcd8739ae039);
76
93
  $parcel$export(module.exports, "AddressInputGroupForm", () => $7fcfa1d90c4a7e45$export$2e2bcd8739ae039);
77
94
  $parcel$export(module.exports, "useExcel", () => $22d7e244b9ff5d8c$export$4564041bcff0e281);
95
+ $parcel$export(module.exports, "useExcelMapper", () => $c1b6e62d8639d990$export$2e2bcd8739ae039);
96
+ $parcel$export(module.exports, "useColumnHelper", () => $5f561ce307b5bbb8$export$2e2bcd8739ae039);
78
97
  $parcel$export(module.exports, "escapeSpecialCharacters", () => $3e554a35fef8bbfa$export$1476d5e67a64a695);
79
98
 
80
99
 
@@ -5038,6 +5057,151 @@ var $48dedbf2c7043ee6$export$2e2bcd8739ae039 = $48dedbf2c7043ee6$var$TableExcelE
5038
5057
 
5039
5058
 
5040
5059
 
5060
+ var $c1b6e62d8639d990$export$d7f512c98c859244 = 'nl';
5061
+ /**
5062
+ * Custom hook that returns an object of mapper functions for converting various data types into Excel cell objects.
5063
+ *
5064
+ * @param t - The translation function.
5065
+ * @param placeholder - An optional placeholder string used when a value is null or undefined.
5066
+ * @returns An object containing mapper functions for various data types.
5067
+ */ var $c1b6e62d8639d990$var$useExcelMapper = function(t, placeholder) {
5068
+ if (placeholder === void 0) placeholder = '';
5069
+ return (0, $iA2ta$react.useMemo)(function() {
5070
+ var toStringCell = function(cell) {
5071
+ return {
5072
+ value: cell !== null && cell !== void 0 ? cell : placeholder,
5073
+ type: 'string'
5074
+ };
5075
+ };
5076
+ var toDateStringCell = function(cell, lang) {
5077
+ var _a;
5078
+ return {
5079
+ value: (_a = (0, $dbcba7ef8eeead3b$export$b7c4e1545c61edee)(cell, {
5080
+ locale: lang !== null && lang !== void 0 ? lang : $c1b6e62d8639d990$export$d7f512c98c859244
5081
+ })) !== null && _a !== void 0 ? _a : '',
5082
+ type: 'string'
5083
+ };
5084
+ };
5085
+ var toEnumCell = function(enumName) {
5086
+ return function(cell) {
5087
+ return {
5088
+ value: cell ? t("enum.".concat(enumName, ".").concat(cell)) : placeholder,
5089
+ type: 'string'
5090
+ };
5091
+ };
5092
+ };
5093
+ var toStringArrayCell = function(cell) {
5094
+ return {
5095
+ value: !(0, $iA2ta$lodash.isEmpty)(cell) ? cell.join(', ') : placeholder,
5096
+ type: 'string'
5097
+ };
5098
+ };
5099
+ var toOptionCell = function(cell) {
5100
+ var _a, _b;
5101
+ return {
5102
+ value: (_b = (_a = cell.export) !== null && _a !== void 0 ? _a : cell.label) !== null && _b !== void 0 ? _b : placeholder,
5103
+ type: 'string'
5104
+ };
5105
+ };
5106
+ var toOptionsCell = function(cell) {
5107
+ return {
5108
+ value: !(0, $iA2ta$lodash.isEmpty)(cell) ? (0, $iA2ta$lodash.map)(cell, 'label').join(', ') : placeholder,
5109
+ type: 'string'
5110
+ };
5111
+ };
5112
+ var toNumberCell = function(cell) {
5113
+ return {
5114
+ value: cell !== null && cell !== void 0 ? cell : placeholder,
5115
+ type: 'number'
5116
+ };
5117
+ };
5118
+ var toBooleanCell = function(cell) {
5119
+ return {
5120
+ value: cell ? t('label.boolean.true') : t('label.boolean.false'),
5121
+ type: 'string'
5122
+ };
5123
+ };
5124
+ return {
5125
+ toStringCell: toStringCell,
5126
+ toDateStringCell: toDateStringCell,
5127
+ toEnumCell: toEnumCell,
5128
+ toStringArrayCell: toStringArrayCell,
5129
+ toOptionCell: toOptionCell,
5130
+ toOptionsCell: toOptionsCell,
5131
+ toNumberCell: toNumberCell,
5132
+ toBooleanCell: toBooleanCell
5133
+ };
5134
+ }, []);
5135
+ };
5136
+ var $c1b6e62d8639d990$export$2e2bcd8739ae039 = $c1b6e62d8639d990$var$useExcelMapper;
5137
+
5138
+
5139
+ var $dbcba7ef8eeead3b$var$__assign = undefined && undefined.__assign || function() {
5140
+ $dbcba7ef8eeead3b$var$__assign = Object.assign || function(t) {
5141
+ for(var s, i = 1, n = arguments.length; i < n; i++){
5142
+ s = arguments[i];
5143
+ for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
5144
+ }
5145
+ return t;
5146
+ };
5147
+ return $dbcba7ef8eeead3b$var$__assign.apply(this, arguments);
5148
+ };
5149
+ var $dbcba7ef8eeead3b$export$c03bb0116ee09d4b = function(date) {
5150
+ if ((0, $iA2ta$lodash.isNil)(date)) return false;
5151
+ var dt = (0, $iA2ta$luxon.DateTime).fromISO(date);
5152
+ return dt.isValid;
5153
+ };
5154
+ var $dbcba7ef8eeead3b$export$b7c4e1545c61edee = function(date, options) {
5155
+ var _a, _b;
5156
+ var format = (_a = options === null || options === void 0 ? void 0 : options.format) !== null && _a !== void 0 ? _a : 'dd LLL yyyy';
5157
+ var locale = (_b = options === null || options === void 0 ? void 0 : options.locale) !== null && _b !== void 0 ? _b : (0, $c1b6e62d8639d990$export$d7f512c98c859244);
5158
+ if (!$dbcba7ef8eeead3b$export$c03bb0116ee09d4b(date)) return '';
5159
+ return (0, $iA2ta$luxon.DateTime).fromISO(date).setLocale(locale).toFormat(format);
5160
+ };
5161
+ var $dbcba7ef8eeead3b$export$b489b1fb1454ddcf = function(date, options) {
5162
+ var _a, _b;
5163
+ var format = (_a = options === null || options === void 0 ? void 0 : options.format) !== null && _a !== void 0 ? _a : "HH.mm'u'";
5164
+ var locale = (_b = options === null || options === void 0 ? void 0 : options.locale) !== null && _b !== void 0 ? _b : (0, $c1b6e62d8639d990$export$d7f512c98c859244);
5165
+ if (!$dbcba7ef8eeead3b$export$c03bb0116ee09d4b(date)) return '';
5166
+ return (0, $iA2ta$luxon.DateTime).fromISO(date).setLocale(locale).toFormat(format);
5167
+ };
5168
+ var $dbcba7ef8eeead3b$export$9b56e83e909e2c38 = function(date, options) {
5169
+ return $dbcba7ef8eeead3b$export$b7c4e1545c61edee(date, $dbcba7ef8eeead3b$var$__assign($dbcba7ef8eeead3b$var$__assign({}, options), {
5170
+ format: 'dd LLL yyyy, HH:mm'
5171
+ }));
5172
+ };
5173
+ var $dbcba7ef8eeead3b$export$1771f44233a5f72 = function(date) {
5174
+ if (!$dbcba7ef8eeead3b$export$c03bb0116ee09d4b(date)) return undefined;
5175
+ var diff = Math.abs((0, $iA2ta$luxon.DateTime).fromISO(date).diffNow('days').as('days'));
5176
+ return Math.round(diff);
5177
+ };
5178
+ var $dbcba7ef8eeead3b$export$df20409d3177a2e0 = function(date) {
5179
+ if (!$dbcba7ef8eeead3b$export$c03bb0116ee09d4b(date)) return '';
5180
+ return (0, $iA2ta$luxon.DateTime).fromISO(date).toFormat('yyyy-LL-dd');
5181
+ };
5182
+ var $dbcba7ef8eeead3b$export$8de20099c30464f2 = function(date, time) {
5183
+ if (!date || !time) return new Date();
5184
+ var _a = date.split('-').map(Number), year = _a[0], month = _a[1], day = _a[2];
5185
+ var _b = time.split(':').map(Number), hours = _b[0], minutes = _b[1];
5186
+ return new Date(Date.UTC(year, month - 1, day, hours, minutes));
5187
+ };
5188
+ var $dbcba7ef8eeead3b$export$8a6f307d1b8b1960 = $dbcba7ef8eeead3b$export$b489b1fb1454ddcf;
5189
+ var $dbcba7ef8eeead3b$export$8649d02bd537ff66 = function(dates) {
5190
+ if (dates === void 0) dates = [];
5191
+ // Filter out any undefined or falsy values
5192
+ var validDates = dates.filter(Boolean);
5193
+ if (!validDates.length) return '';
5194
+ return validDates.reduce(function(latest, date) {
5195
+ return latest > date ? latest : date;
5196
+ });
5197
+ };
5198
+
5199
+
5200
+
5201
+
5202
+
5203
+
5204
+
5041
5205
 
5042
5206
 
5043
5207
 
@@ -6664,6 +6828,171 @@ var $7fcfa1d90c4a7e45$export$2e2bcd8739ae039 = $7fcfa1d90c4a7e45$var$AddressInpu
6664
6828
 
6665
6829
 
6666
6830
 
6831
+
6832
+
6833
+
6834
+
6835
+
6836
+
6837
+
6838
+
6839
+
6840
+
6841
+
6842
+
6843
+
6844
+
6845
+ var $5f561ce307b5bbb8$var$getDateString = (0, $iA2ta$react.useCallback)(function(date) {
6846
+ var _a, _b, _c;
6847
+ if (!date) return '';
6848
+ if ((_a = date.options) === null || _a === void 0 ? void 0 : _a.format) return (0, $dbcba7ef8eeead3b$export$b7c4e1545c61edee)(date.value, {
6849
+ format: date.options.format
6850
+ });
6851
+ if (((_b = date.options) === null || _b === void 0 ? void 0 : _b.type) === 'dateTime') return (0, $dbcba7ef8eeead3b$export$b489b1fb1454ddcf)(date.value);
6852
+ if (((_c = date.options) === null || _c === void 0 ? void 0 : _c.type) === 'dateAtTime') return (0, $dbcba7ef8eeead3b$export$9b56e83e909e2c38)(date.value);
6853
+ return (0, $dbcba7ef8eeead3b$export$b7c4e1545c61edee)(date.value);
6854
+ }, []);
6855
+ var $5f561ce307b5bbb8$var$useColumnHelpers = function(t) {
6856
+ var accessor = (0, $iA2ta$react.useMemo)(function() {
6857
+ return (0, $iA2ta$tanstackreacttable.createColumnHelper)();
6858
+ }, []).accessor;
6859
+ var _a = (0, $c1b6e62d8639d990$export$2e2bcd8739ae039)(t), toStringCell = _a.toStringCell, toOptionCell = _a.toOptionCell;
6860
+ var getClassName = (0, $iA2ta$react.useCallback)(function(size) {
6861
+ var sizes = {
6862
+ sm: 'max-w-20',
6863
+ md: 'max-w-40',
6864
+ lg: 'max-w-60',
6865
+ xl: 'max-w-80'
6866
+ };
6867
+ return "overflow-hidden text-ellipsis ".concat((0, $iA2ta$lodash.get)(sizes, size, ''), " block");
6868
+ }, []);
6869
+ var createAccessor = (0, $iA2ta$react.useCallback)(function(key, getCellContent, excelMapper, options) {
6870
+ return accessor(key, {
6871
+ header: t("component.form.label.".concat(key)),
6872
+ enableSorting: (0, $iA2ta$lodash.get)(options, 'enableSorting', true),
6873
+ cell: function(cell) {
6874
+ return getCellContent(cell, options);
6875
+ },
6876
+ meta: {
6877
+ excel: excelMapper
6878
+ }
6879
+ });
6880
+ }, [
6881
+ accessor,
6882
+ t
6883
+ ]);
6884
+ var baseCellRenderer = function(value, options) {
6885
+ var _a;
6886
+ var content = (0, $iA2ta$reactjsxruntime.jsx)("p", {
6887
+ className: (0, $622cd2936b18c771$export$4370d69198e9314a)((options === null || options === void 0 ? void 0 : options.size) && getClassName(options.size), options === null || options === void 0 ? void 0 : options.className),
6888
+ children: value
6889
+ });
6890
+ return (options === null || options === void 0 ? void 0 : options.hasTooltip) ? (0, $iA2ta$reactjsxruntime.jsx)((0, $1c4aa673c4ad6947$export$2e2bcd8739ae039), {
6891
+ placement: (_a = options === null || options === void 0 ? void 0 : options.tooltipPlacement) !== null && _a !== void 0 ? _a : "bottom-end",
6892
+ content: value,
6893
+ children: content
6894
+ }) : content;
6895
+ };
6896
+ var stringAccessor = function(key, options) {
6897
+ return createAccessor(key, function(cell) {
6898
+ return baseCellRenderer(cell.getValue(), options);
6899
+ }, toStringCell, options);
6900
+ };
6901
+ var linkAccessor = function(key, options) {
6902
+ return createAccessor(key, function(cell) {
6903
+ var _a;
6904
+ var value = cell.getValue();
6905
+ if (!value) return null;
6906
+ var content = value.href ? (0, $iA2ta$reactjsxruntime.jsx)("a", {
6907
+ href: value.href,
6908
+ className: (0, $622cd2936b18c771$export$4370d69198e9314a)((options === null || options === void 0 ? void 0 : options.size) && getClassName(options.size), options === null || options === void 0 ? void 0 : options.className),
6909
+ target: (options === null || options === void 0 ? void 0 : options.openInNewTab) ? "_blank" : undefined,
6910
+ children: value.label
6911
+ }) : value.label;
6912
+ return (options === null || options === void 0 ? void 0 : options.hasTooltip) ? (0, $iA2ta$reactjsxruntime.jsx)((0, $1c4aa673c4ad6947$export$2e2bcd8739ae039), {
6913
+ placement: (_a = options === null || options === void 0 ? void 0 : options.tooltipPlacement) !== null && _a !== void 0 ? _a : 'bottom-end',
6914
+ content: value.label,
6915
+ children: content
6916
+ }) : content;
6917
+ }, toOptionCell, options);
6918
+ };
6919
+ var buttonAccessor = function(key, options) {
6920
+ return createAccessor(key, function(cell) {
6921
+ var _a;
6922
+ var value = cell.getValue();
6923
+ if (!value) return null;
6924
+ var content = (0, $iA2ta$reactjsxruntime.jsx)("button", {
6925
+ onClick: value.onClick,
6926
+ className: (0, $622cd2936b18c771$export$4370d69198e9314a)((options === null || options === void 0 ? void 0 : options.size) && getClassName(options.size), options === null || options === void 0 ? void 0 : options.className),
6927
+ children: value.label
6928
+ });
6929
+ return (options === null || options === void 0 ? void 0 : options.hasTooltip) ? (0, $iA2ta$reactjsxruntime.jsx)((0, $1c4aa673c4ad6947$export$2e2bcd8739ae039), {
6930
+ placement: (_a = options === null || options === void 0 ? void 0 : options.tooltipPlacement) !== null && _a !== void 0 ? _a : "bottom-end",
6931
+ content: value.label,
6932
+ children: content
6933
+ }) : content;
6934
+ }, toOptionCell, options);
6935
+ };
6936
+ var badgeAccessor = function(key, options) {
6937
+ return createAccessor(key, function(cell) {
6938
+ var _a;
6939
+ var value = cell.getValue();
6940
+ if (!value) return null;
6941
+ var content = (0, $iA2ta$reactjsxruntime.jsx)((0, $0b842d364fa010cf$export$2e2bcd8739ae039), {
6942
+ styles: {
6943
+ container: (0, $622cd2936b18c771$export$4370d69198e9314a)((options === null || options === void 0 ? void 0 : options.size) && getClassName(options.size), options === null || options === void 0 ? void 0 : options.className)
6944
+ },
6945
+ color: value.color || 'gray',
6946
+ children: value.label
6947
+ });
6948
+ return (options === null || options === void 0 ? void 0 : options.hasTooltip) ? (0, $iA2ta$reactjsxruntime.jsx)((0, $1c4aa673c4ad6947$export$2e2bcd8739ae039), {
6949
+ placement: (_a = options === null || options === void 0 ? void 0 : options.tooltipPlacement) !== null && _a !== void 0 ? _a : "bottom-end",
6950
+ content: value.label,
6951
+ children: content
6952
+ }) : content;
6953
+ }, function(cell) {
6954
+ return cell ? toStringCell(cell.label) : toStringCell('');
6955
+ }, options);
6956
+ };
6957
+ var dateAccessor = function(key, options) {
6958
+ return createAccessor(key, function(cell) {
6959
+ return $5f561ce307b5bbb8$var$getDateString(cell.getValue());
6960
+ }, function(cell) {
6961
+ var _a;
6962
+ return cell ? toStringCell((_a = $5f561ce307b5bbb8$var$getDateString(cell)) !== null && _a !== void 0 ? _a : '') : toStringCell('');
6963
+ }, options);
6964
+ };
6965
+ var booleanAccessor = function(key, options) {
6966
+ return createAccessor(key, function(cell) {
6967
+ var _a, _b;
6968
+ var value = cell.getValue();
6969
+ var iconClass = (value === null || value === void 0 ? void 0 : value.value) ? (0, $iA2ta$lodash.compact)([
6970
+ 'text-palette-midnightBlue',
6971
+ (_a = value === null || value === void 0 ? void 0 : value.options) === null || _a === void 0 ? void 0 : _a.trueClassName
6972
+ ]).join(' ') : (0, $iA2ta$lodash.compact)([
6973
+ 'text-palette-lightGray',
6974
+ (_b = value === null || value === void 0 ? void 0 : value.options) === null || _b === void 0 ? void 0 : _b.falseClassName
6975
+ ]).join(' ');
6976
+ return (0, $iA2ta$reactjsxruntime.jsx)((0, $2125901b4a9afff9$export$2e2bcd8739ae039), {
6977
+ className: iconClass,
6978
+ accessor: (value === null || value === void 0 ? void 0 : value.value) ? 'check' : 'xmark'
6979
+ });
6980
+ }, function(cell) {
6981
+ return toStringCell((cell === null || cell === void 0 ? void 0 : cell.value) !== undefined ? t("label.boolean.".concat(cell.value)) : t('label.boolean.unclear'));
6982
+ }, options);
6983
+ };
6984
+ return {
6985
+ stringAccessor: stringAccessor,
6986
+ linkAccessor: linkAccessor,
6987
+ buttonAccessor: buttonAccessor,
6988
+ badgeAccessor: badgeAccessor,
6989
+ dateAccessor: dateAccessor,
6990
+ booleanAccessor: booleanAccessor
6991
+ };
6992
+ };
6993
+ var $5f561ce307b5bbb8$export$2e2bcd8739ae039 = $5f561ce307b5bbb8$var$useColumnHelpers;
6994
+
6995
+
6667
6996
  var $3e554a35fef8bbfa$export$1476d5e67a64a695 = function(str) {
6668
6997
  return str.replace(/#/g, "__HASH__").replace(/\?/g, "__QUESTIONMARK__").replace(/\|/g, "__PIPE__").replace(/\\/g, "__BACKSLASH__").replace(/%/g, "__PROCENT__").replace(/'/g, "__QUOTE__");
6669
6998
  };