nexaas-ui-components 1.0.17 → 1.0.18

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
@@ -19,36 +19,22 @@ import { useReactTable, getExpandedRowModel, getFacetedUniqueValues, getFacetedR
19
19
  import { rankItem } from '@tanstack/match-sorter-utils';
20
20
 
21
21
  // src/assets/spinner.tsx
22
- var SpinnerIcon = (props) => /* @__PURE__ */ jsxs(
22
+ var SpinnerIcon = (props) => /* @__PURE__ */ jsx(
23
23
  "svg",
24
24
  {
25
- width: 16,
26
- height: 16,
27
- viewBox: "0 0 24 24",
25
+ ...props,
26
+ width: `${props.width || 33}`,
27
+ height: `${props.height || 33}`,
28
+ viewBox: "0 0 33 33",
28
29
  fill: "none",
29
30
  xmlns: "http://www.w3.org/2000/svg",
30
- ...props,
31
- children: [
32
- /* @__PURE__ */ jsx(
33
- "circle",
34
- {
35
- className: "opacity-25",
36
- cx: "12",
37
- cy: "12",
38
- r: "10",
39
- stroke: "currentColor",
40
- strokeWidth: "4"
41
- }
42
- ),
43
- /* @__PURE__ */ jsx(
44
- "path",
45
- {
46
- className: "opacity-75",
47
- fill: "currentColor",
48
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
49
- }
50
- )
51
- ]
31
+ children: /* @__PURE__ */ jsx(
32
+ "path",
33
+ {
34
+ d: "M21.4671 32.1821C18.269 33.1951 14.8378 33.2061 11.6333 32.2137C8.42885 31.2213 5.6044 29.2729 3.53866 26.6297C1.47293 23.9866 0.264665 20.7751 0.0758752 17.4258C-0.112914 14.0765 0.726798 10.7495 2.48242 7.89096C4.23804 5.03242 6.82565 2.77896 9.89828 1.43272C12.9709 0.0864894 16.3817 -0.288163 19.6733 0.359002C22.9649 1.00617 25.98 2.64421 28.3142 5.0535C30.6485 7.46279 32.1903 10.5282 32.7331 13.8386L28.9102 14.4653C28.4953 11.9345 27.3165 9.59102 25.532 7.74911C23.7474 5.9072 21.4424 4.65491 18.926 4.16015C16.4095 3.66539 13.802 3.95181 11.4529 4.98101C9.10388 6.01021 7.12564 7.73299 5.78346 9.91835C4.44128 12.1037 3.79932 14.6472 3.94365 17.2077C4.08798 19.7683 5.01171 22.2235 6.59097 24.2442C8.17023 26.2649 10.3295 27.7544 12.7794 28.5132C15.2292 29.2719 17.8524 29.2634 20.2973 28.489L21.4671 32.1821Z",
35
+ fill: "#009EDB"
36
+ }
37
+ )
52
38
  }
53
39
  );
54
40
  var sizes = {
@@ -2283,7 +2269,7 @@ var ModalDialog = ({
2283
2269
  description,
2284
2270
  children
2285
2271
  }) => {
2286
- const customStyles2 = {
2272
+ const customStyles3 = {
2287
2273
  content: {
2288
2274
  top: "50%",
2289
2275
  left: "50%",
@@ -2314,7 +2300,7 @@ var ModalDialog = ({
2314
2300
  ariaHideApp: false,
2315
2301
  isOpen: open,
2316
2302
  onRequestClose: onClose,
2317
- style: customStyles2,
2303
+ style: customStyles3,
2318
2304
  contentLabel: "Example Modal",
2319
2305
  children: /* @__PURE__ */ jsxs("div", { className: clsx7(sizes2[size]), children: [
2320
2306
  /* @__PURE__ */ jsxs("div", { className: "pb-2 border-b border-b-neutral-200 flex items-center justify-between", children: [
@@ -2767,6 +2753,393 @@ var SelectField = ({
2767
2753
  var ValueContainer = ({ children, ...props }) => {
2768
2754
  return /* @__PURE__ */ jsx(components.ValueContainer, { ...props, children });
2769
2755
  };
2756
+
2757
+ // src/components/SelectFieldBip/SelectFieldBip.styles.tsx
2758
+ var customStyles2 = {
2759
+ indicatorSeparator: (provided, props) => {
2760
+ var _a;
2761
+ return {
2762
+ ...provided,
2763
+ backgroundColor: props.hasValue && ((_a = provided == null ? void 0 : provided.selectProps) == null ? void 0 : _a.isSearchable) ? "var(--input)" : "transparent",
2764
+ padding: "0px"
2765
+ };
2766
+ },
2767
+ clearIndicator: (provided) => ({
2768
+ ...provided,
2769
+ color: "var(--label)",
2770
+ ":hover": {
2771
+ color: "var(--label)"
2772
+ }
2773
+ }),
2774
+ dropdownIndicator: (provided, state) => {
2775
+ var _a;
2776
+ return {
2777
+ ...provided,
2778
+ color: "var(--paragraph)",
2779
+ transform: ((_a = state == null ? void 0 : state.selectProps) == null ? void 0 : _a.menuIsOpen) ? "rotate(180deg)" : "rotate(0)",
2780
+ ":hover": {
2781
+ color: "var(--paragraph)"
2782
+ }
2783
+ };
2784
+ },
2785
+ input: (provided, state) => ({
2786
+ ...provided,
2787
+ paddingLeft: state.selectProps.hasIcon ? "34px" : "0px",
2788
+ paddingTop: state.selectProps.hasLabel ? "10px" : "0px"
2789
+ }),
2790
+ menu: (provided) => ({
2791
+ ...provided,
2792
+ marginTop: "4px",
2793
+ border: "1px solid var(--dark-blue-300)",
2794
+ boxShadow: "none",
2795
+ borderRadius: "8px",
2796
+ background: "white",
2797
+ zIndex: 60
2798
+ }),
2799
+ menuList: (provided) => ({
2800
+ ...provided,
2801
+ padding: "0px 8px"
2802
+ }),
2803
+ singleValue: (base, state) => ({
2804
+ ...base,
2805
+ paddingLeft: state.selectProps.hasIcon ? "34px" : "0px",
2806
+ paddingTop: state.selectProps.hasLabel ? "10px" : "0",
2807
+ color: state.data.value === "active" ? "#0EAF86" : "black",
2808
+ display: "flex"
2809
+ }),
2810
+ placeholder: (provided, state) => ({
2811
+ ...provided,
2812
+ paddingLeft: state.selectProps.hasIcon ? "34px" : "0px"
2813
+ }),
2814
+ control: (provided, state) => ({
2815
+ ...provided,
2816
+ cursor: "pointer",
2817
+ border: state.selectProps.hasError ? "1px solid var(--dangerous-700)" : state.menuIsOpen ? "1px solid var(--blue-700)" : "1px solid var(--dark-blue-300)",
2818
+ boxShadow: "none",
2819
+ outline: "none",
2820
+ borderRadius: "0.5rem",
2821
+ placeholder: " ",
2822
+ height: "46px",
2823
+ backgroundColor: state.isDisabled ? "var(--light-100)" : "white",
2824
+ ":hover": {
2825
+ border: state.selectProps.hasError ? "1px solid var(--dangerous-700)" : state.menuIsOpen ? "1px solid var(--blue-700)" : "1px solid var(--dark-blue-300)"
2826
+ }
2827
+ }),
2828
+ multiValue: (provided) => ({
2829
+ ...provided,
2830
+ borderRadius: "20px",
2831
+ backgroundColor: "var(--light-100)",
2832
+ padding: "0px 8px"
2833
+ }),
2834
+ multiValueLabel: (provided) => ({
2835
+ ...provided,
2836
+ color: "var(--paragraph)"
2837
+ }),
2838
+ multiValueRemove: (provided) => ({
2839
+ ...provided,
2840
+ color: "var(--dark-blue-400)",
2841
+ ":hover": {
2842
+ color: "var(--dangerous-700)"
2843
+ }
2844
+ }),
2845
+ option: (provided, state) => {
2846
+ let color = state.isSelected ? "white" : (state == null ? void 0 : state.isDisabled) ? "var(--label)" : "var(--paragraph)";
2847
+ return {
2848
+ ...provided,
2849
+ cursor: state.isDisabled ? "auto" : "pointer",
2850
+ pointerEvents: state.isDisabled ? "none" : "",
2851
+ borderRadius: "8px",
2852
+ margin: "4px 0px",
2853
+ padding: "10px 12px",
2854
+ backgroundColor: state.isSelected ? "var(--blue-700)" : "white",
2855
+ color,
2856
+ fontWeight: state.isSelected ? 700 : 400,
2857
+ "&:hover": {
2858
+ backgroundColor: state.isSelected ? "var(--blue-700)" : "var(--light-200)"
2859
+ },
2860
+ "&:active": {
2861
+ backgroundColor: "var(--blue-700)",
2862
+ color: "white !important",
2863
+ fontWeight: 700
2864
+ },
2865
+ "&:active i": {
2866
+ color: "white !important",
2867
+ fontWeight: 700
2868
+ },
2869
+ " i": {
2870
+ color: "white !important"
2871
+ }
2872
+ };
2873
+ },
2874
+ container: (provided) => ({
2875
+ ...provided,
2876
+ border: "none",
2877
+ outline: "none",
2878
+ boxShadow: "none",
2879
+ padding: "none",
2880
+ margin: "none"
2881
+ })
2882
+ };
2883
+ var SelectFieldBip = ({
2884
+ name,
2885
+ label,
2886
+ error,
2887
+ defaultValue,
2888
+ control,
2889
+ placeholder,
2890
+ isSearchable = false,
2891
+ required,
2892
+ debounce: debounce2,
2893
+ filterOptions,
2894
+ disabled,
2895
+ onChangeValue,
2896
+ optionStyle,
2897
+ valueStyle,
2898
+ icon,
2899
+ onErrorBip,
2900
+ clearAfterSelect = true,
2901
+ messages = {
2902
+ searching: "Searching...",
2903
+ debounce: `Type at least {debounce} characters`,
2904
+ emptyMessage: "No options found",
2905
+ loading: "Loading..."
2906
+ }
2907
+ }) => {
2908
+ var _a;
2909
+ const { Option, SingleValue } = components;
2910
+ const selectRef = useRef(null);
2911
+ const [inputValue, setInputValue] = useState("");
2912
+ const [loading, setLoading] = useState(false);
2913
+ const [cachedOptions, setCachedOptions] = useState([]);
2914
+ const fetchOptions = async (value) => {
2915
+ if (isSearchable && filterOptions) {
2916
+ if (!debounce2 || debounce2 && value.length >= debounce2) {
2917
+ setLoading(true);
2918
+ const result = await filterOptions(value);
2919
+ setCachedOptions(result);
2920
+ setLoading(false);
2921
+ return result;
2922
+ }
2923
+ }
2924
+ return [];
2925
+ };
2926
+ const fieldValidation = useFieldErrorsStore((state) => state.field);
2927
+ const fieldValidationMessages = [
2928
+ (_a = fieldValidation[name]) == null ? void 0 : _a.message,
2929
+ error == null ? void 0 : error.message
2930
+ ];
2931
+ const hasError = {
2932
+ hasError: fieldValidationMessages.some((item) => item !== void 0)
2933
+ };
2934
+ const hasLabel = {
2935
+ hasLabel: (label == null ? void 0 : label.length) > 0
2936
+ };
2937
+ const hasIcon = {
2938
+ hasIcon: icon
2939
+ };
2940
+ const iconStyle = `z-[70] absolute bg-neutral-100 h-[44px] top-[1px] left-[1px] rounded-l-lg flex justify-center items-center w-[38px] text-[22px] ${hasError.hasError ? "text-dangerous-500" : "text-label"}`;
2941
+ const debouncedFetchOptions = useMemo(() => {
2942
+ return debounce_default((value, callback) => {
2943
+ fetchOptions(value).then(callback);
2944
+ }, 300);
2945
+ }, [filterOptions]);
2946
+ useEffect(() => {
2947
+ return () => {
2948
+ debouncedFetchOptions.cancel();
2949
+ };
2950
+ }, [debouncedFetchOptions]);
2951
+ return /* @__PURE__ */ jsx(
2952
+ Controller,
2953
+ {
2954
+ name,
2955
+ control,
2956
+ defaultValue,
2957
+ render: ({ field }) => {
2958
+ const CustomSingleValue = (props) => {
2959
+ return /* @__PURE__ */ jsx(SingleValue, { ...props, children: valueStyle ? valueStyle(props == null ? void 0 : props.data) : /* @__PURE__ */ jsxs(Fragment, { children: [
2960
+ props.data.label,
2961
+ " "
2962
+ ] }) });
2963
+ };
2964
+ const IconOption = (props) => {
2965
+ return /* @__PURE__ */ jsx(Option, { ...props, children: optionStyle ? optionStyle(props == null ? void 0 : props.data) : /* @__PURE__ */ jsx(
2966
+ "div",
2967
+ {
2968
+ style: {
2969
+ display: "flex",
2970
+ alignItems: "center",
2971
+ justifyContent: "space-between"
2972
+ },
2973
+ children: /* @__PURE__ */ jsx("span", { className: clsx7("text-p-md focus:text-white"), children: props.data.label })
2974
+ }
2975
+ ) });
2976
+ };
2977
+ const LoadingMessage = (props) => {
2978
+ if (!debounce2 || debounce2 && inputValue.length >= debounce2) {
2979
+ return /* @__PURE__ */ jsxs(
2980
+ "div",
2981
+ {
2982
+ ...props.innerProps,
2983
+ className: "flex items-center gap-[6px] p-2",
2984
+ children: [
2985
+ /* @__PURE__ */ jsx(SpinnerIcon, { width: 16, height: 16, className: "animate-spin" }),
2986
+ messages.searching
2987
+ ]
2988
+ }
2989
+ );
2990
+ } else if (debounce2 && inputValue.length < debounce2) {
2991
+ return /* @__PURE__ */ jsx("div", { className: "p-2 text-dark-blue-300", children: messages.debounce.replace("{debounce}", String(debounce2)) });
2992
+ }
2993
+ };
2994
+ const NoOptionsMessage = (props) => {
2995
+ var _a2;
2996
+ if (inputValue.length == 0 && debounce2 > 0 || debounce2 > 0 && inputValue.length < debounce2) {
2997
+ return /* @__PURE__ */ jsx("div", { className: "p-2 text-dark-blue-300", children: messages.debounce.replace("{debounce}", String(debounce2)) });
2998
+ } else if (inputValue.length > 0 && ((_a2 = props == null ? void 0 : props.options) == null ? void 0 : _a2.length) == 0) {
2999
+ return /* @__PURE__ */ jsx("div", { className: "p-2 text-dark-blue-300", children: messages.emptyMessage });
3000
+ }
3001
+ };
3002
+ const DropdownIndicatorCustom = (props) => {
3003
+ return null;
3004
+ };
3005
+ const handleKeyDown = async (event) => {
3006
+ var _a2;
3007
+ if (event.key === "Enter") {
3008
+ event.preventDefault();
3009
+ debouncedFetchOptions.cancel();
3010
+ const fetchedOptions = await fetchOptions(event.target.value);
3011
+ if ((fetchedOptions == null ? void 0 : fetchedOptions.length) > 0) {
3012
+ onChange(fetchedOptions[0]);
3013
+ setTimeout(() => {
3014
+ var _a3, _b, _c;
3015
+ setInputValue("");
3016
+ (_a3 = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _a3.clearValue();
3017
+ (_b = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _b.focus();
3018
+ (_c = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _c.onMenuClose();
3019
+ field.onChange(null);
3020
+ }, 10);
3021
+ } else {
3022
+ onErrorBip((_a2 = event == null ? void 0 : event.target) == null ? void 0 : _a2.value);
3023
+ selectRef.current.inputRef.select();
3024
+ selectRef.current.onMenuClose();
3025
+ }
3026
+ }
3027
+ };
3028
+ const handleInputChange = (value, actionMeta) => {
3029
+ if (actionMeta.action === "input-change") {
3030
+ setInputValue(value);
3031
+ }
3032
+ return value;
3033
+ };
3034
+ const onChange = async (value, action) => {
3035
+ var _a2, _b, _c, _d, _e;
3036
+ if (onChangeValue) onChangeValue(value);
3037
+ if ((action == null ? void 0 : action.action) === "select-option") {
3038
+ if (clearAfterSelect) {
3039
+ setInputValue("");
3040
+ (_a2 = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _a2.clearValue();
3041
+ (_b = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _b.onMenuClose();
3042
+ (_c = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _c.focus();
3043
+ field.onChange(null);
3044
+ } else {
3045
+ field.onChange(value);
3046
+ setInputValue("");
3047
+ (_d = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _d.onMenuClose();
3048
+ }
3049
+ }
3050
+ if (action === "clear-value") {
3051
+ setInputValue("");
3052
+ setCachedOptions([]);
3053
+ (_e = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _e.clearValue();
3054
+ field.onChange(null);
3055
+ }
3056
+ };
3057
+ const loadOptions = (value, callback) => {
3058
+ debouncedFetchOptions(value, callback);
3059
+ };
3060
+ return /* @__PURE__ */ jsxs("div", { className: "relative", id: "multiselect", children: [
3061
+ icon && /* @__PURE__ */ jsx("div", { className: iconStyle, children: icon }),
3062
+ /* @__PURE__ */ jsx(
3063
+ AsyncSelect,
3064
+ {
3065
+ onKeyDown: handleKeyDown,
3066
+ ...field,
3067
+ ...hasError,
3068
+ ...hasLabel,
3069
+ ...hasIcon,
3070
+ ref: selectRef,
3071
+ isDisabled: disabled,
3072
+ onBlur: () => handleInputChange("", {
3073
+ action: "input-change"
3074
+ }),
3075
+ loadingMessage: () => /* @__PURE__ */ jsx("div", { children: messages.loading }),
3076
+ isLoading: loading,
3077
+ loadOptions,
3078
+ defaultOptions: false,
3079
+ name: field.name,
3080
+ isClearable: false,
3081
+ styles: customStyles2,
3082
+ placeholder: placeholder || " ",
3083
+ isSearchable,
3084
+ tabSelectsValue: true,
3085
+ components: {
3086
+ SingleValue: CustomSingleValue,
3087
+ ValueContainer: ValueContainer2,
3088
+ Option: IconOption,
3089
+ LoadingIndicator: () => /* @__PURE__ */ jsx(Fragment, {}),
3090
+ LoadingMessage,
3091
+ NoOptionsMessage,
3092
+ DropdownIndicator: DropdownIndicatorCustom
3093
+ },
3094
+ closeMenuOnSelect: false,
3095
+ blurInputOnSelect: true,
3096
+ hideSelectedOptions: false,
3097
+ onChange,
3098
+ inputValue,
3099
+ onInputChange: handleInputChange
3100
+ }
3101
+ ),
3102
+ inputValue !== "" && /* @__PURE__ */ jsx(
3103
+ "i",
3104
+ {
3105
+ onClick: () => onChange(null, "clear-value"),
3106
+ className: "uil uil-times text-[18px] absolute right-2 top-[11px] cursor-pointer text-label"
3107
+ }
3108
+ ),
3109
+ /* @__PURE__ */ jsxs(
3110
+ "span",
3111
+ {
3112
+ className: clsx7(
3113
+ "text-label text-sm left-2.5 cursor-pointer pointer-events-none",
3114
+ {
3115
+ [" scale-75 -translate-y-3 "]: field.value,
3116
+ ["text-dangerous-700"]: hasError.hasError
3117
+ }
3118
+ ),
3119
+ children: [
3120
+ label,
3121
+ required && label && /* @__PURE__ */ jsx("strong", { className: "text-dangerous-700", children: "\xA0*" })
3122
+ ]
3123
+ }
3124
+ ),
3125
+ fieldValidationMessages.map((message, index) => /* @__PURE__ */ jsx(
3126
+ "div",
3127
+ {
3128
+ className: "text-dangerous-700 text-xs mt-1 ml-[2px]",
3129
+ role: "alert",
3130
+ "aria-label": message,
3131
+ children: message
3132
+ },
3133
+ index
3134
+ ))
3135
+ ] });
3136
+ }
3137
+ }
3138
+ );
3139
+ };
3140
+ var ValueContainer2 = ({ children, ...props }) => {
3141
+ return /* @__PURE__ */ jsx(components.ValueContainer, { ...props, children });
3142
+ };
2770
3143
  var Radio = ({
2771
3144
  disabled,
2772
3145
  control,
@@ -3705,6 +4078,6 @@ function DataTable({
3705
4078
  ] });
3706
4079
  }
3707
4080
 
3708
- export { Badge, Button, Calendar, Checkbox, DataTable, DataTablePagination, DatePickerInput, FilterCalendar, FilterOptions, Input, InputMoney, InputNumber, InputPercentage, Logo, MaskedInput, ModalDialog, PaginationSelect, Popover3 as Popover, Radio, RocketIcon, SelectField, SpinnerIcon, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Toggle, ValueContainer };
4081
+ export { Badge, Button, Calendar, Checkbox, DataTable, DataTablePagination, DatePickerInput, FilterCalendar, FilterOptions, Input, InputMoney, InputNumber, InputPercentage, Logo, MaskedInput, ModalDialog, PaginationSelect, Popover3 as Popover, Radio, RocketIcon, SelectField, SelectFieldBip, SpinnerIcon, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Toggle, ValueContainer };
3709
4082
  //# sourceMappingURL=index.js.map
3710
4083
  //# sourceMappingURL=index.js.map