@ballistix.digital/react-components 1.0.1 → 1.0.3

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.d.ts CHANGED
@@ -843,10 +843,33 @@ type TProps$2 = {
843
843
  };
844
844
  declare const SlideOverOverlay: FC<TProps$2>;
845
845
 
846
+ declare const styles: {
847
+ controls: {
848
+ container: string;
849
+ content: string;
850
+ head: string;
851
+ body: string;
852
+ dropdown: {
853
+ reset: string;
854
+ container: string;
855
+ input: string;
856
+ label: string;
857
+ actions: string;
858
+ upIcon: string;
859
+ downIcon: string;
860
+ };
861
+ };
862
+ label: string;
863
+ icon: string;
864
+ };
865
+
866
+ type TTableColumnOptionsStyles = DeepPartialType$1<typeof styles>;
867
+
846
868
  type TProps$1 = {
847
869
  table: Table<any>;
848
870
  setColumnOrder: Dispatch<SetStateAction<ColumnOrderState>>;
849
871
  trigger: ReactNode;
872
+ styles?: TTableColumnOptionsStyles;
850
873
  resetConfig?: {
851
874
  tableId: string;
852
875
  label?: string;
@@ -1135,7 +1158,7 @@ type TAddressInputGroupFormValue = {
1135
1158
  street: string;
1136
1159
  houseNumber: string;
1137
1160
  zipCode: string;
1138
- busNumber: string;
1161
+ busNumber?: string;
1139
1162
  lat: number;
1140
1163
  lng: number;
1141
1164
  info?: string;
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
2
  import { ArrowPathIcon, ChevronDownIcon, EllipsisVerticalIcon, ExclamationCircleIcon, ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon, ChevronUpIcon, ChevronUpDownIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
3
- import { isArray, map, set, get, noop as noop$1, indexOf, toSafeInteger, pick, isEmpty, some, forEach, assign, intersection } from 'lodash';
3
+ import { isArray, map, set, get, noop as noop$1, indexOf, toSafeInteger, pick, isEmpty, some, forEach, assign, intersection, trim, lastIndexOf } from 'lodash';
4
4
  import get$1 from 'lodash/get';
5
5
  import React, { useState, useMemo, Children, Fragment, useEffect, useCallback, useRef, forwardRef, useImperativeHandle, useReducer, createElement, PureComponent, Component } from 'react';
6
6
  import { library } from '@fortawesome/fontawesome-svg-core';
@@ -2607,7 +2607,7 @@ var styles$8 = {
2607
2607
 
2608
2608
  var TableColumnOptionsCustom = function (props) {
2609
2609
  var _a;
2610
- var table = props.table, trigger = props.trigger, setColumnOrder = props.setColumnOrder, resetConfig = props.resetConfig;
2610
+ var table = props.table, trigger = props.trigger, setColumnOrder = props.setColumnOrder, stylesOverrides = props.styles, resetConfig = props.resetConfig;
2611
2611
  var handleUpdateColumnOrder = useCallback(function (table, column, location, setColumnOrder) {
2612
2612
  var _a;
2613
2613
  var ids = (_a = table
@@ -2619,7 +2619,16 @@ var TableColumnOptionsCustom = function (props) {
2619
2619
  ids.splice(location, 0, column.id);
2620
2620
  setColumnOrder(ids);
2621
2621
  }, []);
2622
- return (jsxs(Popover, { children: [jsx(Popover.Button, { children: trigger }), jsxs(Popover.Panel, { className: styles$7.controls.content, children: [resetConfig && (jsxs("div", { className: styles$7.controls.dropdown.reset, onClick: function () {
2622
+ var handleGenerateStyle = function () {
2623
+ var result = deepCopyObject(styles$7);
2624
+ var keys = calculateNestedKeys(styles$7);
2625
+ keys.forEach(function (key) {
2626
+ set(result, key, toClassName(get(styles$7, key), get(stylesOverrides, key)));
2627
+ });
2628
+ return result;
2629
+ };
2630
+ var styles = handleGenerateStyle();
2631
+ return (jsxs(Popover, { children: [jsx(Popover.Button, { children: trigger }), jsxs(Popover.Panel, { className: styles.controls.content, children: [resetConfig && (jsxs("div", { className: styles.controls.dropdown.reset, onClick: function () {
2623
2632
  removeTableState(resetConfig.tableId);
2624
2633
  table.resetColumnVisibility(true);
2625
2634
  table.resetColumnOrder();
@@ -2628,9 +2637,9 @@ var TableColumnOptionsCustom = function (props) {
2628
2637
  .getAllLeafColumns()
2629
2638
  .map(function (column, index) {
2630
2639
  var isAccessorColumn = !!(column === null || column === void 0 ? void 0 : column.accessorFn);
2631
- return (jsxs("div", { className: toClassName(styles$7.controls.dropdown.container, !isAccessorColumn && 'hidden'), children: [jsx("input", { className: styles$7.controls.dropdown.input, type: "checkbox", checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }), jsx("label", { className: styles$7.controls.dropdown.label, children: column.columnDef.header }), jsxs("div", { className: styles$7.controls.dropdown.actions, children: [jsx(ChevronDownIcon$1, { className: styles$7.controls.dropdown.upIcon, onClick: function () {
2640
+ return (jsxs("div", { className: toClassName(styles.controls.dropdown.container, !isAccessorColumn && 'hidden'), children: [jsx("input", { className: styles.controls.dropdown.input, type: "checkbox", checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }), jsx("label", { className: styles.controls.dropdown.label, children: column.columnDef.header }), jsxs("div", { className: styles.controls.dropdown.actions, children: [jsx(ChevronDownIcon$1, { className: styles.controls.dropdown.upIcon, onClick: function () {
2632
2641
  return handleUpdateColumnOrder(table, column, index - 1, setColumnOrder);
2633
- } }), jsx(ChevronDownIcon$1, { className: styles$7.controls.dropdown.downIcon, onClick: function () {
2642
+ } }), jsx(ChevronDownIcon$1, { className: styles.controls.dropdown.downIcon, onClick: function () {
2634
2643
  return handleUpdateColumnOrder(table, column, index + 1, setColumnOrder);
2635
2644
  } })] })] }, column.id));
2636
2645
  })] })] }));
@@ -10779,6 +10788,26 @@ var AddressInputGroupForm = function (props) {
10779
10788
  var zipCode = handleExtractValueWithKey('postal_code');
10780
10789
  var houseNumber = handleExtractValueWithKey('street_number');
10781
10790
  var busNumber = handleExtractValueWithKey('post_box');
10791
+ if (
10792
+ // if busNumber is not found with the method above, try to find it in the user inputted label
10793
+ !busNumber &&
10794
+ (
10795
+ // if the label contains the houseNumber and city somewhere after the houseNumber
10796
+ e === null || e === void 0 ? void 0 : e.label.includes(houseNumber)) &&
10797
+ (e === null || e === void 0 ? void 0 : e.label.split(houseNumber)[1].includes(city))) {
10798
+ // split the label at the houseNumber and city
10799
+ var splitLabel = e === null || e === void 0 ? void 0 : e.label.split(houseNumber)[1].split(city)[0];
10800
+ // replace the zipCode from the label if it came before the city
10801
+ var replaceZipcode = splitLabel.replace(zipCode, '');
10802
+ // trim the label
10803
+ var trimmedLabel = trim(replaceZipcode);
10804
+ // if the trimmed label is shorter than 3 characters, it's probably the busNumber. Otherwise, something probably went wrong.
10805
+ if (trimmedLabel.length <= 3) {
10806
+ busNumber = trimmedLabel.includes(',')
10807
+ ? trimmedLabel.substring(0, lastIndexOf(trimmedLabel, ','))
10808
+ : trimmedLabel;
10809
+ }
10810
+ }
10782
10811
  var location = {
10783
10812
  street: street,
10784
10813
  city: city,