@embeddable.com/remarkable-ui 2.0.46 → 3.0.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.d.ts CHANGED
@@ -371,8 +371,8 @@ declare const TextField: React$1.ForwardRefExoticComponent<Omit<React$1.InputHTM
371
371
  } & FieldHeaderProps & React$1.RefAttributes<HTMLInputElement>>;
372
372
 
373
373
  type SelectListOptionIcon = React.ReactElement<SVGProps<SVGSVGElement>> | React.ReactElement<ImgHTMLAttributes<HTMLImageElement>>;
374
- type SelectListOptionProps = {
375
- value?: string;
374
+ type SelectListOptionProps<T = string> = {
375
+ value?: T;
376
376
  isSelected?: boolean;
377
377
  label: string;
378
378
  rightLabel?: string;
@@ -381,31 +381,10 @@ type SelectListOptionProps = {
381
381
  disabled?: boolean;
382
382
  onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
383
383
  };
384
- type SelectListOptionPropsWithCategory = SelectListOptionProps & {
384
+ type SelectListOptionPropsWithCategory<T = string> = SelectListOptionProps<T> & {
385
385
  category: string;
386
386
  };
387
- declare const SelectListOption: FC<SelectListOptionProps>;
388
-
389
- type MultiSelectFieldProps = {
390
- startIcon?: React.ComponentType<IconProps>;
391
- disabled?: boolean;
392
- disableApplyButton?: boolean;
393
- isClearable?: boolean;
394
- isLoading?: boolean;
395
- isSearchable?: boolean;
396
- noOptionsMessage?: string;
397
- options: (SelectListOptionProps | SelectListOptionPropsWithCategory)[];
398
- placeholder?: string;
399
- submitLabel?: string;
400
- values?: string[];
401
- avoidCollisions?: boolean;
402
- onChange: (value: string[]) => void;
403
- onPendingChange?: (values: string[]) => void;
404
- onSearch?: (search: string) => void;
405
- error?: boolean;
406
- errorMessage?: string;
407
- } & FieldHeaderProps;
408
- declare const MultiSelectField: FC<MultiSelectFieldProps>;
387
+ declare const SelectListOption: <T>({ value, isSelected, label, rightLabel, startIcon, endIcon, disabled, ...props }: SelectListOptionProps<T>) => react_jsx_runtime.JSX.Element;
409
388
 
410
389
  type DropdownProps = {
411
390
  triggerComponent: React.ReactNode;
@@ -419,24 +398,48 @@ type DropdownProps = {
419
398
  };
420
399
  declare const Dropdown: FC<DropdownProps>;
421
400
 
422
- type SingleSelectFieldProps = {
423
- options: (SelectListOptionProps | SelectListOptionPropsWithCategory)[];
401
+ type SelectOptionValue = string | number | boolean;
402
+ type SingleSelectFieldProps<T extends SelectOptionValue> = {
403
+ options: SelectListOptionProps<T>[];
424
404
  startIcon?: React.ComponentType<IconProps>;
425
- value?: string;
405
+ value?: T | null;
426
406
  disabled?: boolean;
427
407
  placeholder?: string;
428
408
  searchable?: boolean;
429
409
  clearable?: boolean;
430
410
  isLoading?: boolean;
431
411
  noOptionsMessage?: string;
432
- onChange: (value: string) => void;
412
+ onChange: (value: T | null) => void;
433
413
  onSearch?: (search: string) => void;
434
414
  error?: boolean;
435
415
  errorMessage?: string;
436
416
  avoidCollisions?: boolean;
437
417
  variant?: 'default' | 'ghost';
418
+ triggerComponent?: React.ReactNode;
438
419
  } & FieldHeaderProps & Pick<DropdownProps, 'side' | 'align'>;
439
- declare const SingleSelectField: FC<SingleSelectFieldProps>;
420
+ declare function SingleSelectField<T extends SelectOptionValue>({ label, required, value, startIcon, options, disabled, placeholder, searchable, clearable, isLoading, avoidCollisions, noOptionsMessage, onChange, onSearch, error, errorMessage, side, align, variant, triggerComponent, }: SingleSelectFieldProps<T>): react_jsx_runtime.JSX.Element;
421
+
422
+ type MultiSelectFieldProps<T extends SelectOptionValue> = {
423
+ startIcon?: React.ComponentType<IconProps>;
424
+ disabled?: boolean;
425
+ disableApplyButton?: boolean;
426
+ isClearable?: boolean;
427
+ isLoading?: boolean;
428
+ isSearchable?: boolean;
429
+ noOptionsMessage?: string;
430
+ options: (SelectListOptionProps<T> | SelectListOptionPropsWithCategory<T>)[];
431
+ placeholder?: string;
432
+ submitLabel?: string;
433
+ values?: T[];
434
+ avoidCollisions?: boolean;
435
+ onChange: (value: T[]) => void;
436
+ onPendingChange?: (values: T[]) => void;
437
+ onSearch?: (search: string) => void;
438
+ error?: boolean;
439
+ errorMessage?: string;
440
+ triggerComponent?: React.ReactNode;
441
+ } & FieldHeaderProps;
442
+ declare function MultiSelectField<T extends SelectOptionValue>({ startIcon, label, required, disabled, disableApplyButton, isClearable, isLoading, isSearchable, noOptionsMessage, options, placeholder, submitLabel, values, avoidCollisions, onChange, onPendingChange, onSearch, error, errorMessage, triggerComponent, }: MultiSelectFieldProps<T>): react_jsx_runtime.JSX.Element;
440
443
 
441
444
  type SelectFieldContentProps = {
442
445
  children: ReactNode;
@@ -602,4 +605,4 @@ declare const endOfDayUTC: (date: Date) => Date;
602
605
 
603
606
  declare const shallowEqual: (object1: any, object2: any) => boolean;
604
607
 
605
- export { ActionIcon, BarChart, type BarChartProps, Button, ButtonIcon, Card, CardContent, CardFeedback, CardHeader, type CssSize, DateRangePicker, DateRangePickerField, type DateRangePickerProps, Divider, DonutChart, type DonutLabelChartProps, Dropdown, type DropdownProps, FieldFeedback, type FieldFeedbackProps, FieldHeader, type FieldHeaderProps, GhostButton, GhostButtonIcon, HeatMap, type HeatMapProps, type HeatMapPropsDimension, type HeatMapPropsMeasure, type HeatMapPropsThreshold, KpiChart, LineChart, type LineChartProps, Markdown, MarkdownEditor, MultiSelectField, type MultiSelectFieldProps, NumberField, Overlay, PieChart, type PieChartProps, PivotTable, type PivotTableProps, type PivotTablePropsColumnDimension, type PivotTablePropsMeasure, type PivotTablePropsRowDimension, SelectFieldCategory, SelectFieldContent, SelectFieldContentList, SelectFieldTrigger, SelectListOption, type SelectListOptionProps, type SelectListOptionPropsWithCategory, SingleSelectField, type SingleSelectFieldProps, Skeleton, StylesKeys, Switch, TableBody, TableBodyCellWithCopy, type TableBodyProps, TableHeader, TableHeaderAlign, type TableHeaderCell, type TableHeaderCellStyle, type TableHeaderItem, type TableHeaderItemAlign, type TableHeaderProps, TablePaginated, type TablePaginatedProps, TablePagination, type TablePaginationProps, TableScrollable, type TableScrollableHandle, type TableScrollableProps, type TableSort, TableSortDirection, TextField, Tooltip, Typography, chartjsAxisOptionsLayoutPadding, chartjsAxisOptionsLayoutPaddingLarge, endOfDayUTC, getBarChartData, getBarChartOptions, getChartColors, getChartjsAxisOptions, getChartjsAxisOptionsPlugins, getChartjsAxisOptionsScales, getChartjsAxisOptionsScalesGrid, getChartjsAxisOptionsScalesGridColor, getChartjsAxisOptionsScalesTicksDefault, getChartjsAxisOptionsScalesTicksMuted, getChartjsAxisOptionsScalesTitle, getDonutChartOptions, getKpiDisplayValue, getLineChartData, getLineChartOptions, getPieChartData, getPieChartOptions, getStyle, getStyleNumber, getTableTotalPages, isSameDate, isSameDateRange, shallowEqual, useDebounce, useResizeObserver, useTableGetRowsPerPage };
608
+ export { ActionIcon, BarChart, type BarChartProps, Button, ButtonIcon, Card, CardContent, CardFeedback, CardHeader, type CssSize, DateRangePicker, DateRangePickerField, type DateRangePickerProps, Divider, DonutChart, type DonutLabelChartProps, Dropdown, type DropdownProps, FieldFeedback, type FieldFeedbackProps, FieldHeader, type FieldHeaderProps, GhostButton, GhostButtonIcon, HeatMap, type HeatMapProps, type HeatMapPropsDimension, type HeatMapPropsMeasure, type HeatMapPropsThreshold, KpiChart, LineChart, type LineChartProps, Markdown, MarkdownEditor, MultiSelectField, type MultiSelectFieldProps, NumberField, Overlay, PieChart, type PieChartProps, PivotTable, type PivotTableProps, type PivotTablePropsColumnDimension, type PivotTablePropsMeasure, type PivotTablePropsRowDimension, SelectFieldCategory, SelectFieldContent, SelectFieldContentList, SelectFieldTrigger, SelectListOption, type SelectListOptionProps, type SelectListOptionPropsWithCategory, type SelectOptionValue, SingleSelectField, type SingleSelectFieldProps, Skeleton, StylesKeys, Switch, TableBody, TableBodyCellWithCopy, type TableBodyProps, TableHeader, TableHeaderAlign, type TableHeaderCell, type TableHeaderCellStyle, type TableHeaderItem, type TableHeaderItemAlign, type TableHeaderProps, TablePaginated, type TablePaginatedProps, TablePagination, type TablePaginationProps, TableScrollable, type TableScrollableHandle, type TableScrollableProps, type TableSort, TableSortDirection, TextField, Tooltip, Typography, chartjsAxisOptionsLayoutPadding, chartjsAxisOptionsLayoutPaddingLarge, endOfDayUTC, getBarChartData, getBarChartOptions, getChartColors, getChartjsAxisOptions, getChartjsAxisOptionsPlugins, getChartjsAxisOptionsScales, getChartjsAxisOptionsScalesGrid, getChartjsAxisOptionsScalesGridColor, getChartjsAxisOptionsScalesTicksDefault, getChartjsAxisOptionsScalesTicksMuted, getChartjsAxisOptionsScalesTitle, getDonutChartOptions, getKpiDisplayValue, getLineChartData, getLineChartOptions, getPieChartData, getPieChartOptions, getStyle, getStyleNumber, getTableTotalPages, isSameDate, isSameDateRange, shallowEqual, useDebounce, useResizeObserver, useTableGetRowsPerPage };
package/dist/index.js CHANGED
@@ -2727,7 +2727,7 @@ var SelectListOption = ({
2727
2727
  disabled && styles21.disabled,
2728
2728
  isSelected && styles21.selected
2729
2729
  ),
2730
- "data-value": value,
2730
+ "data-value": String(value),
2731
2731
  ...props,
2732
2732
  children: [
2733
2733
  /* @__PURE__ */ jsxs18("span", { className: styles21.leftContent, children: [
@@ -2746,7 +2746,7 @@ var SelectListOption = ({
2746
2746
  // src/components/editors/selects/shared/SelectFieldContent/SelectFieldContent.utils.ts
2747
2747
  var groupOptionsByCategory = (options) => {
2748
2748
  const result = options.reduce((acc, option) => {
2749
- if ("category" in option && option.category) {
2749
+ if (option.category) {
2750
2750
  const category = option.category;
2751
2751
  if (!acc[category]) {
2752
2752
  acc[category] = [];
@@ -2794,7 +2794,7 @@ function debounce(fn, delay = 300) {
2794
2794
 
2795
2795
  // src/components/editors/selects/MultiSelectField/MultiSelectField.tsx
2796
2796
  import { jsx as jsx31, jsxs as jsxs19 } from "react/jsx-runtime";
2797
- var MultiSelectField = ({
2797
+ function MultiSelectField({
2798
2798
  startIcon,
2799
2799
  label,
2800
2800
  required,
@@ -2813,8 +2813,9 @@ var MultiSelectField = ({
2813
2813
  onPendingChange,
2814
2814
  onSearch,
2815
2815
  error = false,
2816
- errorMessage
2817
- }) => {
2816
+ errorMessage,
2817
+ triggerComponent
2818
+ }) {
2818
2819
  const [isOpen, setIsOpen] = useState8(false);
2819
2820
  const [searchValue, setSearchValue] = useState8("");
2820
2821
  const [preValues, setPreValues] = useState8(values);
@@ -2847,7 +2848,7 @@ var MultiSelectField = ({
2847
2848
  const isSubmitDisabled = preValues.every((preValue) => values.includes(preValue)) && values.every((value) => preValues.includes(value));
2848
2849
  const handleSelectOption = (e, newValue) => {
2849
2850
  e.preventDefault();
2850
- if (!newValue) return;
2851
+ if (newValue === void 0) return;
2851
2852
  if (preValues.includes(newValue)) {
2852
2853
  const next = preValues.filter((v) => v !== newValue);
2853
2854
  setPreValues(next);
@@ -2874,6 +2875,19 @@ var MultiSelectField = ({
2874
2875
  onPendingChange?.([]);
2875
2876
  onChange([]);
2876
2877
  };
2878
+ const renderOption = (option) => {
2879
+ const { value: optionValue, category: _category, ...optionRest } = option;
2880
+ return /* @__PURE__ */ jsx31(
2881
+ SelectListOption,
2882
+ {
2883
+ value: optionValue,
2884
+ onClick: (e) => handleSelectOption(e, optionValue),
2885
+ startIcon: optionValue !== void 0 && preValues.includes(optionValue) ? /* @__PURE__ */ jsx31(IconSquareCheckFilled, {}) : /* @__PURE__ */ jsx31(IconSquare, {}),
2886
+ ...optionRest
2887
+ },
2888
+ String(optionValue)
2889
+ );
2890
+ };
2877
2891
  const hasError = error || !!errorMessage;
2878
2892
  return /* @__PURE__ */ jsxs19("div", { children: [
2879
2893
  /* @__PURE__ */ jsx31(FieldHeader, { label, required }),
@@ -2884,7 +2898,7 @@ var MultiSelectField = ({
2884
2898
  onOpenChange: setIsOpen,
2885
2899
  disabled,
2886
2900
  avoidCollisions,
2887
- triggerComponent: /* @__PURE__ */ jsx31(
2901
+ triggerComponent: triggerComponent ?? /* @__PURE__ */ jsx31(
2888
2902
  SelectFieldTrigger,
2889
2903
  {
2890
2904
  startIcon,
@@ -2916,24 +2930,8 @@ var MultiSelectField = ({
2916
2930
  /* @__PURE__ */ jsxs19(SelectFieldContentList, { disabled: isLoading, children: [
2917
2931
  groupedOptions ? Object.entries(groupedOptions).map(([category, categoryOptions]) => /* @__PURE__ */ jsxs19(Fragment6, { children: [
2918
2932
  /* @__PURE__ */ jsx31(SelectFieldCategory, { label: category }),
2919
- categoryOptions.map((option) => /* @__PURE__ */ jsx31(
2920
- SelectListOption,
2921
- {
2922
- onClick: (e) => handleSelectOption(e, option.value),
2923
- startIcon: preValues.includes(option.value) ? /* @__PURE__ */ jsx31(IconSquareCheckFilled, {}) : /* @__PURE__ */ jsx31(IconSquare, {}),
2924
- ...option
2925
- },
2926
- option?.value ?? option.label
2927
- ))
2928
- ] }, category)) : displayOptions.map((option) => /* @__PURE__ */ jsx31(
2929
- SelectListOption,
2930
- {
2931
- onClick: (e) => handleSelectOption(e, option.value),
2932
- startIcon: preValues.includes(option.value) ? /* @__PURE__ */ jsx31(IconSquareCheckFilled, {}) : /* @__PURE__ */ jsx31(IconSquare, {}),
2933
- ...option
2934
- },
2935
- option?.value ?? option.label
2936
- )),
2933
+ categoryOptions.map(renderOption)
2934
+ ] }, category)) : displayOptions.map(renderOption),
2937
2935
  noOptionsMessage && displayOptions.length === 0 && /* @__PURE__ */ jsx31(SelectListOption, { disabled: true, value: "empty", label: noOptionsMessage })
2938
2936
  ] }),
2939
2937
  /* @__PURE__ */ jsx31(
@@ -2953,17 +2951,17 @@ var MultiSelectField = ({
2953
2951
  ),
2954
2952
  errorMessage && /* @__PURE__ */ jsx31(FieldFeedback, { message: errorMessage, variant: "error" })
2955
2953
  ] });
2956
- };
2954
+ }
2957
2955
 
2958
2956
  // src/components/editors/selects/SingleSelectField/SingleSelectField.tsx
2959
2957
  import { Fragment as Fragment7, useEffect as useEffect9, useMemo as useMemo6, useRef as useRef11, useState as useState9 } from "react";
2960
2958
  import { IconSearch as IconSearch2 } from "@tabler/icons-react";
2961
2959
  import styles24 from "./selects.module-MRJADSDF.module.css";
2962
2960
  import { jsx as jsx32, jsxs as jsxs20 } from "react/jsx-runtime";
2963
- var SingleSelectField = ({
2961
+ function SingleSelectField({
2964
2962
  label,
2965
2963
  required,
2966
- value = "",
2964
+ value = null,
2967
2965
  startIcon,
2968
2966
  options,
2969
2967
  disabled,
@@ -2979,15 +2977,16 @@ var SingleSelectField = ({
2979
2977
  errorMessage,
2980
2978
  side,
2981
2979
  align,
2982
- variant
2983
- }) => {
2980
+ variant,
2981
+ triggerComponent
2982
+ }) {
2984
2983
  const [isOpen, setIsOpen] = useState9(false);
2985
2984
  const [searchValue, setSearchValue] = useState9("");
2986
- const [selectedLabel, setSelectedLabel] = useState9(value);
2985
+ const [selectedLabel, setSelectedLabel] = useState9("");
2987
2986
  const searchFieldRef = useRef11(null);
2988
2987
  useSelectSearchFocus(isOpen, searchFieldRef);
2989
2988
  useEffect9(() => {
2990
- if (!value) {
2989
+ if (value === null) {
2991
2990
  setSelectedLabel("");
2992
2991
  return;
2993
2992
  }
@@ -3001,9 +3000,9 @@ var SingleSelectField = ({
3001
3000
  const groupedOptions = useMemo6(() => groupOptionsByCategory(displayOptions), [displayOptions]);
3002
3001
  const handleChange = (newValue) => {
3003
3002
  setSearchValue("");
3004
- onChange(newValue ?? "");
3003
+ onChange(newValue);
3005
3004
  onSearch?.("");
3006
- if (newValue === "") {
3005
+ if (newValue === null) {
3007
3006
  setSelectedLabel("");
3008
3007
  } else {
3009
3008
  const option = options.find((opt) => opt.value === newValue);
@@ -3014,6 +3013,19 @@ var SingleSelectField = ({
3014
3013
  setSearchValue(newSearch);
3015
3014
  debouncedSearch?.(newSearch);
3016
3015
  };
3016
+ const renderOption = (option) => {
3017
+ const { value: optionValue, category: _category, ...optionRest } = option;
3018
+ return /* @__PURE__ */ jsx32(
3019
+ SelectListOption,
3020
+ {
3021
+ value: optionValue,
3022
+ onClick: () => handleChange(optionValue ?? null),
3023
+ isSelected: optionValue === value,
3024
+ ...optionRest
3025
+ },
3026
+ String(optionValue)
3027
+ );
3028
+ };
3017
3029
  const hasError = error || !!errorMessage;
3018
3030
  return /* @__PURE__ */ jsxs20("div", { children: [
3019
3031
  /* @__PURE__ */ jsx32(FieldHeader, { label, required }),
@@ -3026,7 +3038,7 @@ var SingleSelectField = ({
3026
3038
  avoidCollisions,
3027
3039
  side,
3028
3040
  align,
3029
- triggerComponent: /* @__PURE__ */ jsx32(
3041
+ triggerComponent: triggerComponent ?? /* @__PURE__ */ jsx32(
3030
3042
  SelectFieldTrigger,
3031
3043
  {
3032
3044
  startIcon,
@@ -3034,7 +3046,7 @@ var SingleSelectField = ({
3034
3046
  placeholder,
3035
3047
  disabled,
3036
3048
  valueLabel: selectedLabel,
3037
- onClear: () => handleChange(""),
3049
+ onClear: () => handleChange(null),
3038
3050
  isClearable: clearable,
3039
3051
  isLoading,
3040
3052
  error: hasError,
@@ -3059,32 +3071,16 @@ var SingleSelectField = ({
3059
3071
  /* @__PURE__ */ jsxs20(SelectFieldContentList, { disabled: isLoading, children: [
3060
3072
  groupedOptions ? Object.entries(groupedOptions).map(([category, categoryOptions]) => /* @__PURE__ */ jsxs20(Fragment7, { children: [
3061
3073
  /* @__PURE__ */ jsx32(SelectFieldCategory, { label: category }),
3062
- categoryOptions.map((option) => /* @__PURE__ */ jsx32(
3063
- SelectListOption,
3064
- {
3065
- onClick: () => handleChange(option?.value),
3066
- isSelected: option.value === value,
3067
- ...option
3068
- },
3069
- option?.value ?? option.label
3070
- ))
3071
- ] }, category)) : displayOptions.map((option) => /* @__PURE__ */ jsx32(
3072
- SelectListOption,
3073
- {
3074
- onClick: () => handleChange(option?.value),
3075
- isSelected: option.value === value,
3076
- ...option
3077
- },
3078
- option?.value ?? option.label
3079
- )),
3080
- options.length === 0 && /* @__PURE__ */ jsx32(SelectListOption, { disabled: true, value: "empty", label: noOptionsMessage })
3074
+ categoryOptions.map(renderOption)
3075
+ ] }, category)) : displayOptions.map(renderOption),
3076
+ noOptionsMessage && displayOptions.length === 0 && /* @__PURE__ */ jsx32(SelectListOption, { disabled: true, value: "empty", label: noOptionsMessage })
3081
3077
  ] })
3082
3078
  ] })
3083
3079
  }
3084
3080
  ),
3085
3081
  errorMessage && /* @__PURE__ */ jsx32(FieldFeedback, { message: errorMessage, variant: "error" })
3086
3082
  ] });
3087
- };
3083
+ }
3088
3084
 
3089
3085
  // src/components/editors/Switch/Switch.tsx
3090
3086
  import clsx18 from "clsx";