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.cjs CHANGED
@@ -48,36 +48,22 @@ var ReactModalNamespace__namespace = /*#__PURE__*/_interopNamespace(ReactModalNa
48
48
  var AsyncSelect__default = /*#__PURE__*/_interopDefault(AsyncSelect);
49
49
 
50
50
  // src/assets/spinner.tsx
51
- var SpinnerIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs(
51
+ var SpinnerIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
52
52
  "svg",
53
53
  {
54
- width: 16,
55
- height: 16,
56
- viewBox: "0 0 24 24",
54
+ ...props,
55
+ width: `${props.width || 33}`,
56
+ height: `${props.height || 33}`,
57
+ viewBox: "0 0 33 33",
57
58
  fill: "none",
58
59
  xmlns: "http://www.w3.org/2000/svg",
59
- ...props,
60
- children: [
61
- /* @__PURE__ */ jsxRuntime.jsx(
62
- "circle",
63
- {
64
- className: "opacity-25",
65
- cx: "12",
66
- cy: "12",
67
- r: "10",
68
- stroke: "currentColor",
69
- strokeWidth: "4"
70
- }
71
- ),
72
- /* @__PURE__ */ jsxRuntime.jsx(
73
- "path",
74
- {
75
- className: "opacity-75",
76
- fill: "currentColor",
77
- 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"
78
- }
79
- )
80
- ]
60
+ children: /* @__PURE__ */ jsxRuntime.jsx(
61
+ "path",
62
+ {
63
+ 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",
64
+ fill: "#009EDB"
65
+ }
66
+ )
81
67
  }
82
68
  );
83
69
  var sizes = {
@@ -2312,7 +2298,7 @@ var ModalDialog = ({
2312
2298
  description,
2313
2299
  children
2314
2300
  }) => {
2315
- const customStyles2 = {
2301
+ const customStyles3 = {
2316
2302
  content: {
2317
2303
  top: "50%",
2318
2304
  left: "50%",
@@ -2343,7 +2329,7 @@ var ModalDialog = ({
2343
2329
  ariaHideApp: false,
2344
2330
  isOpen: open,
2345
2331
  onRequestClose: onClose,
2346
- style: customStyles2,
2332
+ style: customStyles3,
2347
2333
  contentLabel: "Example Modal",
2348
2334
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx7__default.default(sizes2[size]), children: [
2349
2335
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pb-2 border-b border-b-neutral-200 flex items-center justify-between", children: [
@@ -2796,6 +2782,393 @@ var SelectField = ({
2796
2782
  var ValueContainer = ({ children, ...props }) => {
2797
2783
  return /* @__PURE__ */ jsxRuntime.jsx(reactSelect.components.ValueContainer, { ...props, children });
2798
2784
  };
2785
+
2786
+ // src/components/SelectFieldBip/SelectFieldBip.styles.tsx
2787
+ var customStyles2 = {
2788
+ indicatorSeparator: (provided, props) => {
2789
+ var _a;
2790
+ return {
2791
+ ...provided,
2792
+ backgroundColor: props.hasValue && ((_a = provided == null ? void 0 : provided.selectProps) == null ? void 0 : _a.isSearchable) ? "var(--input)" : "transparent",
2793
+ padding: "0px"
2794
+ };
2795
+ },
2796
+ clearIndicator: (provided) => ({
2797
+ ...provided,
2798
+ color: "var(--label)",
2799
+ ":hover": {
2800
+ color: "var(--label)"
2801
+ }
2802
+ }),
2803
+ dropdownIndicator: (provided, state) => {
2804
+ var _a;
2805
+ return {
2806
+ ...provided,
2807
+ color: "var(--paragraph)",
2808
+ transform: ((_a = state == null ? void 0 : state.selectProps) == null ? void 0 : _a.menuIsOpen) ? "rotate(180deg)" : "rotate(0)",
2809
+ ":hover": {
2810
+ color: "var(--paragraph)"
2811
+ }
2812
+ };
2813
+ },
2814
+ input: (provided, state) => ({
2815
+ ...provided,
2816
+ paddingLeft: state.selectProps.hasIcon ? "34px" : "0px",
2817
+ paddingTop: state.selectProps.hasLabel ? "10px" : "0px"
2818
+ }),
2819
+ menu: (provided) => ({
2820
+ ...provided,
2821
+ marginTop: "4px",
2822
+ border: "1px solid var(--dark-blue-300)",
2823
+ boxShadow: "none",
2824
+ borderRadius: "8px",
2825
+ background: "white",
2826
+ zIndex: 60
2827
+ }),
2828
+ menuList: (provided) => ({
2829
+ ...provided,
2830
+ padding: "0px 8px"
2831
+ }),
2832
+ singleValue: (base, state) => ({
2833
+ ...base,
2834
+ paddingLeft: state.selectProps.hasIcon ? "34px" : "0px",
2835
+ paddingTop: state.selectProps.hasLabel ? "10px" : "0",
2836
+ color: state.data.value === "active" ? "#0EAF86" : "black",
2837
+ display: "flex"
2838
+ }),
2839
+ placeholder: (provided, state) => ({
2840
+ ...provided,
2841
+ paddingLeft: state.selectProps.hasIcon ? "34px" : "0px"
2842
+ }),
2843
+ control: (provided, state) => ({
2844
+ ...provided,
2845
+ cursor: "pointer",
2846
+ border: state.selectProps.hasError ? "1px solid var(--dangerous-700)" : state.menuIsOpen ? "1px solid var(--blue-700)" : "1px solid var(--dark-blue-300)",
2847
+ boxShadow: "none",
2848
+ outline: "none",
2849
+ borderRadius: "0.5rem",
2850
+ placeholder: " ",
2851
+ height: "46px",
2852
+ backgroundColor: state.isDisabled ? "var(--light-100)" : "white",
2853
+ ":hover": {
2854
+ border: state.selectProps.hasError ? "1px solid var(--dangerous-700)" : state.menuIsOpen ? "1px solid var(--blue-700)" : "1px solid var(--dark-blue-300)"
2855
+ }
2856
+ }),
2857
+ multiValue: (provided) => ({
2858
+ ...provided,
2859
+ borderRadius: "20px",
2860
+ backgroundColor: "var(--light-100)",
2861
+ padding: "0px 8px"
2862
+ }),
2863
+ multiValueLabel: (provided) => ({
2864
+ ...provided,
2865
+ color: "var(--paragraph)"
2866
+ }),
2867
+ multiValueRemove: (provided) => ({
2868
+ ...provided,
2869
+ color: "var(--dark-blue-400)",
2870
+ ":hover": {
2871
+ color: "var(--dangerous-700)"
2872
+ }
2873
+ }),
2874
+ option: (provided, state) => {
2875
+ let color = state.isSelected ? "white" : (state == null ? void 0 : state.isDisabled) ? "var(--label)" : "var(--paragraph)";
2876
+ return {
2877
+ ...provided,
2878
+ cursor: state.isDisabled ? "auto" : "pointer",
2879
+ pointerEvents: state.isDisabled ? "none" : "",
2880
+ borderRadius: "8px",
2881
+ margin: "4px 0px",
2882
+ padding: "10px 12px",
2883
+ backgroundColor: state.isSelected ? "var(--blue-700)" : "white",
2884
+ color,
2885
+ fontWeight: state.isSelected ? 700 : 400,
2886
+ "&:hover": {
2887
+ backgroundColor: state.isSelected ? "var(--blue-700)" : "var(--light-200)"
2888
+ },
2889
+ "&:active": {
2890
+ backgroundColor: "var(--blue-700)",
2891
+ color: "white !important",
2892
+ fontWeight: 700
2893
+ },
2894
+ "&:active i": {
2895
+ color: "white !important",
2896
+ fontWeight: 700
2897
+ },
2898
+ " i": {
2899
+ color: "white !important"
2900
+ }
2901
+ };
2902
+ },
2903
+ container: (provided) => ({
2904
+ ...provided,
2905
+ border: "none",
2906
+ outline: "none",
2907
+ boxShadow: "none",
2908
+ padding: "none",
2909
+ margin: "none"
2910
+ })
2911
+ };
2912
+ var SelectFieldBip = ({
2913
+ name,
2914
+ label,
2915
+ error,
2916
+ defaultValue,
2917
+ control,
2918
+ placeholder,
2919
+ isSearchable = false,
2920
+ required,
2921
+ debounce: debounce2,
2922
+ filterOptions,
2923
+ disabled,
2924
+ onChangeValue,
2925
+ optionStyle,
2926
+ valueStyle,
2927
+ icon,
2928
+ onErrorBip,
2929
+ clearAfterSelect = true,
2930
+ messages = {
2931
+ searching: "Searching...",
2932
+ debounce: `Type at least {debounce} characters`,
2933
+ emptyMessage: "No options found",
2934
+ loading: "Loading..."
2935
+ }
2936
+ }) => {
2937
+ var _a;
2938
+ const { Option, SingleValue } = reactSelect.components;
2939
+ const selectRef = React2.useRef(null);
2940
+ const [inputValue, setInputValue] = React2.useState("");
2941
+ const [loading, setLoading] = React2.useState(false);
2942
+ const [cachedOptions, setCachedOptions] = React2.useState([]);
2943
+ const fetchOptions = async (value) => {
2944
+ if (isSearchable && filterOptions) {
2945
+ if (!debounce2 || debounce2 && value.length >= debounce2) {
2946
+ setLoading(true);
2947
+ const result = await filterOptions(value);
2948
+ setCachedOptions(result);
2949
+ setLoading(false);
2950
+ return result;
2951
+ }
2952
+ }
2953
+ return [];
2954
+ };
2955
+ const fieldValidation = useFieldErrorsStore((state) => state.field);
2956
+ const fieldValidationMessages = [
2957
+ (_a = fieldValidation[name]) == null ? void 0 : _a.message,
2958
+ error == null ? void 0 : error.message
2959
+ ];
2960
+ const hasError = {
2961
+ hasError: fieldValidationMessages.some((item) => item !== void 0)
2962
+ };
2963
+ const hasLabel = {
2964
+ hasLabel: (label == null ? void 0 : label.length) > 0
2965
+ };
2966
+ const hasIcon = {
2967
+ hasIcon: icon
2968
+ };
2969
+ 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"}`;
2970
+ const debouncedFetchOptions = React2.useMemo(() => {
2971
+ return debounce_default((value, callback) => {
2972
+ fetchOptions(value).then(callback);
2973
+ }, 300);
2974
+ }, [filterOptions]);
2975
+ React2.useEffect(() => {
2976
+ return () => {
2977
+ debouncedFetchOptions.cancel();
2978
+ };
2979
+ }, [debouncedFetchOptions]);
2980
+ return /* @__PURE__ */ jsxRuntime.jsx(
2981
+ reactHookForm.Controller,
2982
+ {
2983
+ name,
2984
+ control,
2985
+ defaultValue,
2986
+ render: ({ field }) => {
2987
+ const CustomSingleValue = (props) => {
2988
+ return /* @__PURE__ */ jsxRuntime.jsx(SingleValue, { ...props, children: valueStyle ? valueStyle(props == null ? void 0 : props.data) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2989
+ props.data.label,
2990
+ " "
2991
+ ] }) });
2992
+ };
2993
+ const IconOption = (props) => {
2994
+ return /* @__PURE__ */ jsxRuntime.jsx(Option, { ...props, children: optionStyle ? optionStyle(props == null ? void 0 : props.data) : /* @__PURE__ */ jsxRuntime.jsx(
2995
+ "div",
2996
+ {
2997
+ style: {
2998
+ display: "flex",
2999
+ alignItems: "center",
3000
+ justifyContent: "space-between"
3001
+ },
3002
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: clsx7__default.default("text-p-md focus:text-white"), children: props.data.label })
3003
+ }
3004
+ ) });
3005
+ };
3006
+ const LoadingMessage = (props) => {
3007
+ if (!debounce2 || debounce2 && inputValue.length >= debounce2) {
3008
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3009
+ "div",
3010
+ {
3011
+ ...props.innerProps,
3012
+ className: "flex items-center gap-[6px] p-2",
3013
+ children: [
3014
+ /* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, { width: 16, height: 16, className: "animate-spin" }),
3015
+ messages.searching
3016
+ ]
3017
+ }
3018
+ );
3019
+ } else if (debounce2 && inputValue.length < debounce2) {
3020
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 text-dark-blue-300", children: messages.debounce.replace("{debounce}", String(debounce2)) });
3021
+ }
3022
+ };
3023
+ const NoOptionsMessage = (props) => {
3024
+ var _a2;
3025
+ if (inputValue.length == 0 && debounce2 > 0 || debounce2 > 0 && inputValue.length < debounce2) {
3026
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 text-dark-blue-300", children: messages.debounce.replace("{debounce}", String(debounce2)) });
3027
+ } else if (inputValue.length > 0 && ((_a2 = props == null ? void 0 : props.options) == null ? void 0 : _a2.length) == 0) {
3028
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 text-dark-blue-300", children: messages.emptyMessage });
3029
+ }
3030
+ };
3031
+ const DropdownIndicatorCustom = (props) => {
3032
+ return null;
3033
+ };
3034
+ const handleKeyDown = async (event) => {
3035
+ var _a2;
3036
+ if (event.key === "Enter") {
3037
+ event.preventDefault();
3038
+ debouncedFetchOptions.cancel();
3039
+ const fetchedOptions = await fetchOptions(event.target.value);
3040
+ if ((fetchedOptions == null ? void 0 : fetchedOptions.length) > 0) {
3041
+ onChange(fetchedOptions[0]);
3042
+ setTimeout(() => {
3043
+ var _a3, _b, _c;
3044
+ setInputValue("");
3045
+ (_a3 = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _a3.clearValue();
3046
+ (_b = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _b.focus();
3047
+ (_c = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _c.onMenuClose();
3048
+ field.onChange(null);
3049
+ }, 10);
3050
+ } else {
3051
+ onErrorBip((_a2 = event == null ? void 0 : event.target) == null ? void 0 : _a2.value);
3052
+ selectRef.current.inputRef.select();
3053
+ selectRef.current.onMenuClose();
3054
+ }
3055
+ }
3056
+ };
3057
+ const handleInputChange = (value, actionMeta) => {
3058
+ if (actionMeta.action === "input-change") {
3059
+ setInputValue(value);
3060
+ }
3061
+ return value;
3062
+ };
3063
+ const onChange = async (value, action) => {
3064
+ var _a2, _b, _c, _d, _e;
3065
+ if (onChangeValue) onChangeValue(value);
3066
+ if ((action == null ? void 0 : action.action) === "select-option") {
3067
+ if (clearAfterSelect) {
3068
+ setInputValue("");
3069
+ (_a2 = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _a2.clearValue();
3070
+ (_b = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _b.onMenuClose();
3071
+ (_c = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _c.focus();
3072
+ field.onChange(null);
3073
+ } else {
3074
+ field.onChange(value);
3075
+ setInputValue("");
3076
+ (_d = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _d.onMenuClose();
3077
+ }
3078
+ }
3079
+ if (action === "clear-value") {
3080
+ setInputValue("");
3081
+ setCachedOptions([]);
3082
+ (_e = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _e.clearValue();
3083
+ field.onChange(null);
3084
+ }
3085
+ };
3086
+ const loadOptions = (value, callback) => {
3087
+ debouncedFetchOptions(value, callback);
3088
+ };
3089
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", id: "multiselect", children: [
3090
+ icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: iconStyle, children: icon }),
3091
+ /* @__PURE__ */ jsxRuntime.jsx(
3092
+ AsyncSelect__default.default,
3093
+ {
3094
+ onKeyDown: handleKeyDown,
3095
+ ...field,
3096
+ ...hasError,
3097
+ ...hasLabel,
3098
+ ...hasIcon,
3099
+ ref: selectRef,
3100
+ isDisabled: disabled,
3101
+ onBlur: () => handleInputChange("", {
3102
+ action: "input-change"
3103
+ }),
3104
+ loadingMessage: () => /* @__PURE__ */ jsxRuntime.jsx("div", { children: messages.loading }),
3105
+ isLoading: loading,
3106
+ loadOptions,
3107
+ defaultOptions: false,
3108
+ name: field.name,
3109
+ isClearable: false,
3110
+ styles: customStyles2,
3111
+ placeholder: placeholder || " ",
3112
+ isSearchable,
3113
+ tabSelectsValue: true,
3114
+ components: {
3115
+ SingleValue: CustomSingleValue,
3116
+ ValueContainer: ValueContainer2,
3117
+ Option: IconOption,
3118
+ LoadingIndicator: () => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}),
3119
+ LoadingMessage,
3120
+ NoOptionsMessage,
3121
+ DropdownIndicator: DropdownIndicatorCustom
3122
+ },
3123
+ closeMenuOnSelect: false,
3124
+ blurInputOnSelect: true,
3125
+ hideSelectedOptions: false,
3126
+ onChange,
3127
+ inputValue,
3128
+ onInputChange: handleInputChange
3129
+ }
3130
+ ),
3131
+ inputValue !== "" && /* @__PURE__ */ jsxRuntime.jsx(
3132
+ "i",
3133
+ {
3134
+ onClick: () => onChange(null, "clear-value"),
3135
+ className: "uil uil-times text-[18px] absolute right-2 top-[11px] cursor-pointer text-label"
3136
+ }
3137
+ ),
3138
+ /* @__PURE__ */ jsxRuntime.jsxs(
3139
+ "span",
3140
+ {
3141
+ className: clsx7__default.default(
3142
+ "text-label text-sm left-2.5 cursor-pointer pointer-events-none",
3143
+ {
3144
+ [" scale-75 -translate-y-3 "]: field.value,
3145
+ ["text-dangerous-700"]: hasError.hasError
3146
+ }
3147
+ ),
3148
+ children: [
3149
+ label,
3150
+ required && label && /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "text-dangerous-700", children: "\xA0*" })
3151
+ ]
3152
+ }
3153
+ ),
3154
+ fieldValidationMessages.map((message, index) => /* @__PURE__ */ jsxRuntime.jsx(
3155
+ "div",
3156
+ {
3157
+ className: "text-dangerous-700 text-xs mt-1 ml-[2px]",
3158
+ role: "alert",
3159
+ "aria-label": message,
3160
+ children: message
3161
+ },
3162
+ index
3163
+ ))
3164
+ ] });
3165
+ }
3166
+ }
3167
+ );
3168
+ };
3169
+ var ValueContainer2 = ({ children, ...props }) => {
3170
+ return /* @__PURE__ */ jsxRuntime.jsx(reactSelect.components.ValueContainer, { ...props, children });
3171
+ };
2799
3172
  var Radio = ({
2800
3173
  disabled,
2801
3174
  control,
@@ -3755,6 +4128,7 @@ exports.Popover = Popover3;
3755
4128
  exports.Radio = Radio;
3756
4129
  exports.RocketIcon = RocketIcon;
3757
4130
  exports.SelectField = SelectField;
4131
+ exports.SelectFieldBip = SelectFieldBip;
3758
4132
  exports.SpinnerIcon = SpinnerIcon;
3759
4133
  exports.Table = Table;
3760
4134
  exports.TableBody = TableBody;