fis-component 0.0.76 → 0.0.78

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/cjs/index.js CHANGED
@@ -71091,9 +71091,23 @@ function mergeRefs(...refs) {
71091
71091
  }
71092
71092
 
71093
71093
  const FISInputDate = React.forwardRef((props, ref) => {
71094
- const { className, value, textLabel = "", iconLabel, required, message = "", disabled, negative, positive, format = "DD/MM/YYYY", onClickIconLabel, onChange, getPopupContainer, minDate, maxDate, ...restProps } = props;
71094
+ const { className, value, textLabel = "", iconLabel, required, message = "", disabled, negative, positive, format, onClickIconLabel, onChange, getPopupContainer, minDate, maxDate, picker = "date", allowClear = true, showToday = true, showTime = false, autoFocus = false, disabledDate, inputReadOnly = false, ...restProps } = props;
71095
+ const getDefaultFormat = (pickerMode) => {
71096
+ switch (pickerMode) {
71097
+ case "year":
71098
+ return "YYYY";
71099
+ case "month":
71100
+ return "MM/YYYY";
71101
+ case "quarter":
71102
+ return "YYYY-[Q]Q";
71103
+ case "date":
71104
+ default:
71105
+ return "DD/MM/YYYY";
71106
+ }
71107
+ };
71108
+ const finalFormat = format || getDefaultFormat(picker);
71095
71109
  const [open, setOpen] = React.useState(false);
71096
- const [inputValue, setInputValue] = React.useState(value ? dayjs(value).format(format) : "");
71110
+ const [inputValue, setInputValue] = React.useState(value ? dayjs(value).format(finalFormat) : "");
71097
71111
  const [dateValue, setDateValue] = React.useState(value ? dayjs(value) : null);
71098
71112
  const inputRef = React.useRef(null);
71099
71113
  const mergeRef = mergeRefs(inputRef, ref);
@@ -71102,28 +71116,30 @@ const FISInputDate = React.forwardRef((props, ref) => {
71102
71116
  if (value) {
71103
71117
  const newDayjs = dayjs(value);
71104
71118
  setDateValue(newDayjs);
71105
- setInputValue(newDayjs.format(format));
71119
+ setInputValue(newDayjs.format(finalFormat));
71106
71120
  }
71107
71121
  else {
71108
71122
  setDateValue(null);
71109
71123
  setInputValue("");
71110
71124
  }
71111
- }, [value, format]);
71125
+ }, [value, finalFormat]);
71112
71126
  const handleOpenChange = (openState) => {
71113
71127
  setOpen(openState);
71114
71128
  };
71115
71129
  const handleChange = (selectedDate) => {
71116
71130
  const newDate = selectedDate ? selectedDate.toDate() : null;
71117
71131
  setDateValue(selectedDate);
71118
- setInputValue(selectedDate ? selectedDate.format(format) : "");
71132
+ setInputValue(selectedDate ? selectedDate.format(finalFormat) : "");
71119
71133
  onChange?.(newDate);
71120
71134
  setOpen(false);
71121
71135
  };
71122
71136
  const handleInputChange = (e) => {
71137
+ if (inputReadOnly)
71138
+ return;
71123
71139
  const newInputValue = e.target.value;
71124
71140
  setInputValue(newInputValue);
71125
71141
  // Try to parse the input as a date
71126
- const parsedDate = dayjs(newInputValue, format);
71142
+ const parsedDate = dayjs(newInputValue, finalFormat);
71127
71143
  if (parsedDate.isValid()) {
71128
71144
  setDateValue(parsedDate);
71129
71145
  onChange?.(parsedDate.toDate());
@@ -71134,7 +71150,7 @@ const FISInputDate = React.forwardRef((props, ref) => {
71134
71150
  onChange?.(null);
71135
71151
  }
71136
71152
  };
71137
- return (jsxRuntime.jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsxs(DivInputWrapperSC$1, { children: [jsxRuntime.jsx(FISInputField, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: jsxRuntime.jsx(DateIcon, {}), value: inputValue, negative: negative, disabled: disabled, onFocus: () => setOpen(true), onChange: handleInputChange, onClickSuffix: () => setOpen(true) }), jsxRuntime.jsx(HiddenDatePickerSC, { open: open, value: dateValue, onChange: (value) => handleChange(value), onOpenChange: handleOpenChange, format: format, getPopupContainer: getPopupContainer, minDate: minDate, maxDate: maxDate })] }), message && (jsxRuntime.jsx(DivHintWrapperSC$1, { children: jsxRuntime.jsx(SpanHintSC$3, { className: classNames({
71153
+ return (jsxRuntime.jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsxs(DivInputWrapperSC$1, { children: [jsxRuntime.jsx(FISInputField, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: jsxRuntime.jsx(DateIcon, {}), value: inputValue, negative: negative, disabled: disabled, placeholder: restProps.placeholder, readOnly: inputReadOnly, autoFocus: autoFocus, onFocus: () => setOpen(true), onChange: handleInputChange, onClickSuffix: () => setOpen(true) }), jsxRuntime.jsx(HiddenDatePickerSC, { open: open, value: dateValue, onChange: (value) => handleChange(value), onOpenChange: handleOpenChange, format: finalFormat, getPopupContainer: getPopupContainer, minDate: minDate, maxDate: maxDate, picker: picker, allowClear: allowClear, showToday: showToday, showTime: showTime, disabledDate: disabledDate })] }), message && (jsxRuntime.jsx(DivHintWrapperSC$1, { children: jsxRuntime.jsx(SpanHintSC$3, { className: classNames({
71138
71154
  disabled,
71139
71155
  negative,
71140
71156
  positive,
@@ -71715,7 +71731,7 @@ const DivIconSC = styled.div `
71715
71731
  `;
71716
71732
 
71717
71733
  const FISTableCell = React.forwardRef(({ className, textAlign, variant = COLUMN_VARIANT.PRIMARY, content, description, icon, disabled, hasBorder, onChange, contentWrapText = false, ...rest }, ref) => {
71718
- return (jsxRuntime.jsx(DivColumnCellContainerSC, { "$hasBorder": hasBorder, "$disabled": disabled, "$variant": variant, "$textAlign": textAlign, "$contentWrapText": contentWrapText, "$hasContent": content, "$hasDescription": description, ref: ref, className: classNames("column-cell-container", className), ...rest, children: textAlign === COLUMN_TEXT_ALIGN.SINGLE_LINE ? (jsxRuntime.jsxs("div", { className: "single-line-content", children: [icon && (jsxRuntime.jsx("div", { className: "icon-box", children: jsxRuntime.jsx(DivIconSC, { "$textAlign": textAlign, "$variant": variant, "$disabled": disabled, "$hasContent": content, "$hasDescription": description, children: icon }) })), (content || description) && (jsxRuntime.jsxs("div", { className: "content-box", children: [content && jsxRuntime.jsx("div", { className: "content", children: content }), description && (jsxRuntime.jsx("div", { className: "description", children: description }))] }))] })) : (jsxRuntime.jsxs("div", { className: "left-right-content", children: [(icon || content) && (jsxRuntime.jsxs("div", { className: "content-box", children: [icon && (jsxRuntime.jsx(DivIconSC, { "$textAlign": textAlign, "$variant": variant, "$disabled": disabled, "$hasContent": content, "$hasDescription": description, children: icon })), content && jsxRuntime.jsx("div", { className: "content", children: content })] })), description && jsxRuntime.jsx("div", { className: "description", children: description })] })) }));
71734
+ return (jsxRuntime.jsx(DivColumnCellContainerSC, { "$hasBorder": hasBorder, "$disabled": disabled, "$variant": variant, "$textAlign": textAlign, "$contentWrapText": contentWrapText, "$hasContent": content ? "true" : undefined, "$hasDescription": description, ref: ref, className: classNames("column-cell-container", className), ...rest, children: textAlign === COLUMN_TEXT_ALIGN.SINGLE_LINE ? (jsxRuntime.jsxs("div", { className: "single-line-content", children: [icon && (jsxRuntime.jsx("div", { className: "icon-box", children: jsxRuntime.jsx(DivIconSC, { "$textAlign": textAlign, "$variant": variant, "$disabled": disabled, "$hasContent": content ? "true" : undefined, "$hasDescription": description, children: icon }) })), (content || description) && (jsxRuntime.jsxs("div", { className: "content-box", children: [content && jsxRuntime.jsx("div", { className: "content", children: content }), description && (jsxRuntime.jsx("div", { className: "description", children: description }))] }))] })) : (jsxRuntime.jsxs("div", { className: "left-right-content", children: [(icon || content) && (jsxRuntime.jsxs("div", { className: "content-box", children: [icon && (jsxRuntime.jsx(DivIconSC, { "$textAlign": textAlign, "$variant": variant, "$disabled": disabled, "$hasContent": content ? "true" : undefined, "$hasDescription": description, children: icon })), content && jsxRuntime.jsx("div", { className: "content", children: content })] })), description && jsxRuntime.jsx("div", { className: "description", children: description })] })) }));
71719
71735
  });
71720
71736
  FISTableCell.displayName = "FISTableCell";
71721
71737