sales-frontend-components 0.1.4 → 1.0.1

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.js CHANGED
@@ -30,24 +30,28 @@ var styles$g = require('./terms/components/unit/terms-mobile-card.module.scss');
30
30
  var styles$h = require('./terms/components/_shared/terms.module.scss');
31
31
 
32
32
  const HookFormCheckboxButton = ({
33
- name,
34
- control,
35
- disabled,
36
- children,
37
- ...props
33
+ useControllerProps,
34
+ checkboxButtonProps,
35
+ children
38
36
  }) => {
39
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled });
37
+ const { field, fieldState } = reactHookForm.useController(useControllerProps);
38
+ const { onChange: fieldOnChange, onBlur: fieldOnBlur, ...restField } = field;
39
+ const { onChange: propsOnChange, id: propsId, onBlur: propsOnBlur, ...restProps } = checkboxButtonProps;
40
40
  return /* @__PURE__ */ jsxRuntime.jsx(
41
41
  salesFrontendDesignSystem.CheckboxButton,
42
42
  {
43
- ...props,
44
- ...field,
45
- id: field.name,
43
+ ...restProps,
44
+ ...restField,
45
+ id: propsId ?? field.name,
46
46
  checked: field.value ?? false,
47
47
  error: fieldState.invalid,
48
48
  onChange: (checked) => {
49
- field.onChange(checked);
50
- props.onChange?.(checked);
49
+ propsOnChange?.(checked);
50
+ fieldOnChange?.(checked);
51
+ },
52
+ onBlur: (e) => {
53
+ propsOnBlur?.(e);
54
+ fieldOnBlur?.();
51
55
  },
52
56
  children
53
57
  }
@@ -55,14 +59,31 @@ const HookFormCheckboxButton = ({
55
59
  };
56
60
 
57
61
  const HookFormCheckbox = ({
58
- name,
59
- control,
60
- disabled,
61
- children,
62
- ...props
62
+ useControllerProps,
63
+ checkboxProps,
64
+ children
63
65
  }) => {
64
- const { field } = reactHookForm.useController({ name, control, disabled });
65
- return /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Checkbox, { ...props, ...field, id: field.name, checked: field.value, onChange: field.onChange, children });
66
+ const { field } = reactHookForm.useController(useControllerProps);
67
+ const { onChange: fieldOnChange, onBlur: fieldOnBlur, ...restField } = field;
68
+ const { onChange: propsOnChange, onBlur: propsOnBlur, id: propsId, ...restProps } = checkboxProps;
69
+ return /* @__PURE__ */ jsxRuntime.jsx(
70
+ salesFrontendDesignSystem.Checkbox,
71
+ {
72
+ ...restProps,
73
+ ...restField,
74
+ id: propsId ?? field.name,
75
+ checked: field.value ?? false,
76
+ onChange: (checked) => {
77
+ propsOnChange?.(checked);
78
+ fieldOnChange?.(checked);
79
+ },
80
+ onBlur: (e) => {
81
+ propsOnBlur?.(e);
82
+ fieldOnBlur?.();
83
+ },
84
+ children
85
+ }
86
+ );
66
87
  };
67
88
 
68
89
  function getDefaultExportFromCjs (x) {
@@ -3876,40 +3897,56 @@ function JobVehicleSearchModal({ onClose }) {
3876
3897
  }
3877
3898
 
3878
3899
  const HookFormSearchJobField = ({
3879
- name,
3880
- control,
3881
- disabled,
3882
- error,
3883
- size = "medium",
3884
- placeholder = "\uC9C1\uC885 \uAC80\uC0C9",
3885
- onValueChange,
3886
- defaultValue,
3887
- ...props
3900
+ useControllerProps,
3901
+ searchJobFieldProps
3888
3902
  }) => {
3903
+ const {
3904
+ error: propsError,
3905
+ size = "medium",
3906
+ placeholder = "\uC9C1\uC885 \uAC80\uC0C9",
3907
+ onValueChange: propsOnValueChange,
3908
+ defaultValue,
3909
+ onClick: propsOnClick,
3910
+ onBlur: propsOnBlur,
3911
+ id: propsId,
3912
+ ...restProps
3913
+ } = searchJobFieldProps;
3889
3914
  const [selected, setSelected] = React9.useState(defaultValue);
3890
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled });
3915
+ const { field, fieldState } = reactHookForm.useController(useControllerProps);
3916
+ const { onChange: fieldOnChange, onBlur: fieldOnBlur, ...restField } = field;
3891
3917
  const { JobSearchModal, openJobSearchModal, selectedJob } = useJobSearchModal();
3892
3918
  React9.useEffect(() => {
3893
3919
  if (selectedJob) {
3894
- field.onChange(selectedJob.occupationIndustryName);
3895
- setSelected({ label: selectedJob.occupationIndustryName, value: selectedJob.occupationIndustryCode });
3896
- onValueChange?.({ label: selectedJob.occupationIndustryName, value: selectedJob.occupationIndustryCode });
3920
+ const nextSelected = {
3921
+ label: selectedJob.occupationIndustryName,
3922
+ value: selectedJob.occupationIndustryCode
3923
+ };
3924
+ fieldOnChange?.(nextSelected.label);
3925
+ setSelected(nextSelected);
3926
+ propsOnValueChange?.(nextSelected);
3897
3927
  }
3898
- }, [selectedJob]);
3928
+ }, [fieldOnChange, propsOnValueChange, selectedJob]);
3899
3929
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3900
3930
  /* @__PURE__ */ jsxRuntime.jsx(
3901
3931
  salesFrontendDesignSystem.FormField.ComboBox,
3902
3932
  {
3903
- ...props,
3904
- ...field,
3905
- id: field.name,
3906
- error: fieldState.invalid || error,
3933
+ ...restProps,
3934
+ ...restField,
3935
+ id: propsId ?? field.name,
3936
+ error: fieldState.invalid || propsError,
3907
3937
  value: selected?.label ?? "",
3908
3938
  icon: "search",
3909
3939
  size,
3910
3940
  placeholder,
3911
3941
  autoComplete: "off",
3912
- onClick: openJobSearchModal
3942
+ onClick: (e) => {
3943
+ propsOnClick?.(e);
3944
+ openJobSearchModal();
3945
+ },
3946
+ onBlur: (e) => {
3947
+ propsOnBlur?.(e);
3948
+ fieldOnBlur?.();
3949
+ }
3913
3950
  }
3914
3951
  ),
3915
3952
  JobSearchModal
@@ -3917,15 +3954,27 @@ const HookFormSearchJobField = ({
3917
3954
  };
3918
3955
 
3919
3956
  const HookFormSegmentGroup = ({
3920
- name,
3921
- control,
3922
- disabled,
3923
- disabledItems,
3924
- defaultValue,
3925
- items,
3926
- ...props
3957
+ useControllerProps,
3958
+ segmentGroupProps
3927
3959
  }) => {
3928
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled, defaultValue });
3960
+ const { field, fieldState } = reactHookForm.useController(useControllerProps);
3961
+ const {
3962
+ onChange: fieldOnChange,
3963
+ onBlur: fieldOnBlur,
3964
+ ref: fieldRef,
3965
+ value: fieldValue,
3966
+ disabled: fieldDisabled,
3967
+ name: fieldName
3968
+ } = field;
3969
+ const {
3970
+ items,
3971
+ disabledItems,
3972
+ onValueChange: propsOnValueChange,
3973
+ onBlur: propsOnBlur,
3974
+ id: propsId,
3975
+ error: propsError,
3976
+ ...restProps
3977
+ } = segmentGroupProps;
3929
3978
  const itemList = items.map((item) => {
3930
3979
  return {
3931
3980
  ...item,
@@ -3935,42 +3984,48 @@ const HookFormSegmentGroup = ({
3935
3984
  return /* @__PURE__ */ jsxRuntime.jsx(
3936
3985
  salesFrontendDesignSystem.SegmentGroup,
3937
3986
  {
3938
- ...props,
3939
- id: field.name,
3940
- ref: field.ref,
3941
- defaultValue: field.value,
3942
- disabled: field.disabled,
3943
- error: fieldState.invalid,
3944
- onBlur: field.onBlur,
3987
+ ...restProps,
3988
+ id: propsId ?? fieldName,
3989
+ ref: fieldRef,
3990
+ defaultValue: fieldValue,
3991
+ disabled: fieldDisabled,
3992
+ error: fieldState.invalid || propsError,
3993
+ onBlur: (e) => {
3994
+ propsOnBlur?.(e);
3995
+ fieldOnBlur?.();
3996
+ },
3945
3997
  items: itemList,
3946
3998
  onValueChange: (selected) => {
3947
- field.onChange(selected);
3948
- props.onValueChange?.(selected);
3999
+ propsOnValueChange?.(selected);
4000
+ fieldOnChange?.(selected);
3949
4001
  }
3950
4002
  }
3951
4003
  );
3952
4004
  };
3953
4005
 
3954
4006
  const HookFormSelect = ({
3955
- name,
3956
- control,
3957
- disabled,
3958
- error,
3959
- children,
3960
- ...props
4007
+ useControllerProps,
4008
+ selectProps,
4009
+ children
3961
4010
  }) => {
3962
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled });
4011
+ const { field, fieldState } = reactHookForm.useController(useControllerProps);
4012
+ const { onChange: fieldOnChange, onBlur: fieldOnBlur, ...restField } = field;
4013
+ const { onChange: propsOnChange, onBlur: propsOnBlur, id: propsId, error: propsError, ...restProps } = selectProps;
3963
4014
  return /* @__PURE__ */ jsxRuntime.jsx(
3964
4015
  salesFrontendDesignSystem.Select,
3965
4016
  {
3966
- ...props,
3967
- id: field.name,
4017
+ ...restProps,
4018
+ ...restField,
4019
+ id: propsId ?? field.name,
3968
4020
  disabled: field.disabled,
3969
- error: fieldState.invalid || error,
3970
- onBlur: field.onBlur,
3971
- value: field.value,
4021
+ error: fieldState.invalid || propsError,
4022
+ onBlur: (e) => {
4023
+ propsOnBlur?.(e);
4024
+ fieldOnBlur?.();
4025
+ },
3972
4026
  onChange: (selected) => {
3973
- field.onChange(selected);
4027
+ propsOnChange?.(selected);
4028
+ fieldOnChange?.(selected);
3974
4029
  },
3975
4030
  children
3976
4031
  }
@@ -3982,9 +4037,10 @@ const HookFormSelectOption = ({ children, value, ...rest }) => {
3982
4037
  const HookFormSelectGroup = ({
3983
4038
  options,
3984
4039
  optionsProps,
3985
- ...props
4040
+ selectProps,
4041
+ useControllerProps
3986
4042
  }) => {
3987
- return /* @__PURE__ */ jsxRuntime.jsx(HookFormSelect, { ...props, children: options.map(
4043
+ return /* @__PURE__ */ jsxRuntime.jsx(HookFormSelect, { selectProps, useControllerProps, children: options.map(
3988
4044
  (option) => option.label && /* @__PURE__ */ jsxRuntime.jsx(HookFormSelectOption, { value: option.value, ...optionsProps, children: option.label }, option.value)
3989
4045
  ) });
3990
4046
  };
@@ -3992,41 +4048,52 @@ HookFormSelect.Option = HookFormSelectOption;
3992
4048
  HookFormSelect.Group = HookFormSelectGroup;
3993
4049
 
3994
4050
  const HookFormTextField = ({
3995
- name,
3996
- control,
3997
- size = "medium",
3998
- disabled,
3999
- error,
4000
- onBlur,
4001
- onChange,
4002
- rootProps,
4003
- ...props
4051
+ useControllerProps,
4052
+ textFieldProps
4004
4053
  }) => {
4005
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled });
4054
+ const { field, fieldState } = reactHookForm.useController(useControllerProps);
4055
+ const {
4056
+ onChange: fieldOnChange,
4057
+ onBlur: fieldOnBlur,
4058
+ value: fieldValue,
4059
+ name: fieldName,
4060
+ disabled: fieldDisabled,
4061
+ ...restField
4062
+ } = field;
4063
+ const {
4064
+ onChange: propsOnChange,
4065
+ onBlur: propsOnBlur,
4066
+ id: propsId,
4067
+ error: propsError,
4068
+ size = "medium",
4069
+ rootProps: propsRootProps,
4070
+ ...restProps
4071
+ } = textFieldProps;
4006
4072
  return /* @__PURE__ */ jsxRuntime.jsx(
4007
4073
  salesFrontendDesignSystem.FormField.TextField,
4008
4074
  {
4009
- ...props,
4010
- id: field.name,
4075
+ ...restProps,
4076
+ ...restField,
4077
+ id: propsId ?? fieldName,
4011
4078
  size,
4012
4079
  autoComplete: "off",
4013
- name: field.name,
4014
- value: field.value ?? "",
4015
- disabled: field.disabled,
4016
- error: fieldState.invalid || error,
4080
+ name: fieldName,
4081
+ value: fieldValue ?? "",
4082
+ disabled: fieldDisabled,
4083
+ error: fieldState.invalid || propsError,
4017
4084
  onChange: (e) => {
4018
- field.onChange(e);
4019
- onChange?.(e);
4085
+ propsOnChange?.(e);
4086
+ fieldOnChange?.(e);
4020
4087
  },
4021
4088
  onBlur: (e) => {
4022
- field.onBlur();
4023
- onBlur?.(e);
4089
+ propsOnBlur?.(e);
4090
+ fieldOnBlur?.();
4024
4091
  },
4025
4092
  rootProps: {
4026
- ...rootProps,
4093
+ ...propsRootProps,
4027
4094
  onClear: () => {
4028
- field.onChange("");
4029
- rootProps?.onClear?.();
4095
+ fieldOnChange?.("");
4096
+ propsRootProps?.onClear?.();
4030
4097
  }
4031
4098
  }
4032
4099
  }
@@ -4034,55 +4101,59 @@ const HookFormTextField = ({
4034
4101
  };
4035
4102
 
4036
4103
  const HookFormDatePickerRenew = ({
4037
- name,
4038
- control,
4039
- disabled,
4040
- defaultValue,
4104
+ useControllerProps,
4041
4105
  datepickerProps
4042
4106
  }) => {
4043
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled, defaultValue });
4107
+ const controllerDefaultValue = datepickerProps.defaultValue ? dayjs(datepickerProps.defaultValue).toDate() : void 0;
4108
+ const { field, fieldState } = reactHookForm.useController({
4109
+ defaultValue: controllerDefaultValue,
4110
+ ...useControllerProps
4111
+ });
4044
4112
  return /* @__PURE__ */ jsxRuntime.jsx(
4045
4113
  salesFrontendDesignSystem.DatePickerSingleRenew,
4046
4114
  {
4115
+ ...datepickerProps,
4047
4116
  defaultValue: field.value ? dayjs(field.value) : void 0,
4048
4117
  onValueChange: (value) => {
4118
+ datepickerProps.onValueChange?.(value);
4049
4119
  field.onChange(dayjs(value).toDate());
4050
4120
  },
4051
4121
  inputProps: {
4122
+ ...datepickerProps.inputProps,
4052
4123
  comboBoxItemProps: {
4053
- error: fieldState.invalid,
4054
4124
  ...datepickerProps.inputProps?.comboBoxItemProps,
4125
+ error: fieldState.invalid,
4055
4126
  ...field
4056
- },
4057
- ...datepickerProps.inputProps
4058
- },
4059
- ...datepickerProps
4127
+ }
4128
+ }
4060
4129
  }
4061
4130
  );
4062
4131
  };
4063
4132
 
4064
4133
  const HookFormDateRangePickerRenew = ({
4065
- name,
4066
- control,
4067
- disabled,
4068
- defaultValue,
4134
+ useControllerProps,
4069
4135
  startDateProps,
4070
4136
  endDateProps
4071
4137
  }) => {
4138
+ const controllerDefaultValue = {
4139
+ startDate: startDateProps.defaultValue ? dayjs(startDateProps.defaultValue) : void 0,
4140
+ endDate: endDateProps.defaultValue ? dayjs(endDateProps.defaultValue) : void 0
4141
+ };
4072
4142
  const { field, fieldState } = reactHookForm.useController({
4073
- name,
4074
- control,
4075
- disabled,
4076
- defaultValue
4143
+ defaultValue: controllerDefaultValue,
4144
+ ...useControllerProps
4077
4145
  });
4078
4146
  const { name: fieldName, onChange, ...restField } = field;
4079
4147
  const startDateMergedProps = {
4148
+ ...startDateProps,
4149
+ inputFormat: startDateProps.inputFormat || "YY.MM.DD",
4080
4150
  defaultValue: field.value?.startDate ? dayjs(field.value?.startDate) : void 0,
4081
4151
  calendarProps: {
4082
4152
  max: field.value?.endDate ? dayjs(field.value?.endDate) : void 0,
4083
- ...startDateProps?.calendarProps
4153
+ ...startDateProps.calendarProps
4084
4154
  },
4085
4155
  onValueChange: (value) => {
4156
+ startDateProps.onValueChange?.(value);
4086
4157
  if (field.value) {
4087
4158
  onChange({
4088
4159
  startDate: value.toDate(),
@@ -4090,26 +4161,27 @@ const HookFormDateRangePickerRenew = ({
4090
4161
  });
4091
4162
  }
4092
4163
  },
4093
- inputFormat: "YY.MM.DD",
4094
4164
  inputProps: {
4165
+ ...startDateProps.inputProps,
4095
4166
  comboBoxItemProps: {
4167
+ ...startDateProps.inputProps?.comboBoxItemProps,
4096
4168
  name: `${fieldName}.startDate`,
4097
- size: "small",
4169
+ size: startDateProps.inputProps?.comboBoxItemProps?.size || "small",
4098
4170
  error: fieldState.invalid,
4099
- ...startDateProps?.inputProps?.comboBoxItemProps,
4100
4171
  ...restField
4101
- },
4102
- ...startDateProps?.inputProps
4103
- },
4104
- ...startDateProps
4172
+ }
4173
+ }
4105
4174
  };
4106
4175
  const endDateMergedProps = {
4176
+ ...endDateProps,
4177
+ inputFormat: endDateProps.inputFormat || "YY.MM.DD",
4107
4178
  defaultValue: field.value?.endDate ? dayjs(field.value?.endDate) : void 0,
4108
4179
  calendarProps: {
4109
4180
  min: field.value?.startDate ? dayjs(field.value?.startDate) : void 0,
4110
- ...endDateProps?.calendarProps
4181
+ ...endDateProps.calendarProps
4111
4182
  },
4112
4183
  onValueChange: (value) => {
4184
+ endDateProps.onValueChange?.(value);
4113
4185
  if (field.value) {
4114
4186
  onChange({
4115
4187
  startDate: field.value?.startDate,
@@ -4117,18 +4189,16 @@ const HookFormDateRangePickerRenew = ({
4117
4189
  });
4118
4190
  }
4119
4191
  },
4120
- inputFormat: "YY.MM.DD",
4121
4192
  inputProps: {
4193
+ ...endDateProps.inputProps,
4122
4194
  comboBoxItemProps: {
4195
+ ...endDateProps.inputProps?.comboBoxItemProps,
4123
4196
  name: `${fieldName}.endDate`,
4124
- size: "small",
4197
+ size: endDateProps.inputProps?.comboBoxItemProps?.size || "small",
4125
4198
  error: fieldState.invalid,
4126
- ...endDateProps?.inputProps?.comboBoxItemProps,
4127
4199
  ...restField
4128
- },
4129
- ...endDateProps?.inputProps
4130
- },
4131
- ...endDateProps
4200
+ }
4201
+ }
4132
4202
  };
4133
4203
  return /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.DatePickerRangeRenew, { startDateProps: startDateMergedProps, endDateProps: endDateMergedProps });
4134
4204
  };