sales-frontend-components 0.1.3 → 1.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.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
  }
@@ -3992,41 +4047,52 @@ HookFormSelect.Option = HookFormSelectOption;
3992
4047
  HookFormSelect.Group = HookFormSelectGroup;
3993
4048
 
3994
4049
  const HookFormTextField = ({
3995
- name,
3996
- control,
3997
- size = "medium",
3998
- disabled,
3999
- error,
4000
- onBlur,
4001
- onChange,
4002
- rootProps,
4003
- ...props
4050
+ useControllerProps,
4051
+ textFieldProps
4004
4052
  }) => {
4005
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled });
4053
+ const { field, fieldState } = reactHookForm.useController(useControllerProps);
4054
+ const {
4055
+ onChange: fieldOnChange,
4056
+ onBlur: fieldOnBlur,
4057
+ value: fieldValue,
4058
+ name: fieldName,
4059
+ disabled: fieldDisabled,
4060
+ ...restField
4061
+ } = field;
4062
+ const {
4063
+ onChange: propsOnChange,
4064
+ onBlur: propsOnBlur,
4065
+ id: propsId,
4066
+ error: propsError,
4067
+ size = "medium",
4068
+ rootProps: propsRootProps,
4069
+ ...restProps
4070
+ } = textFieldProps;
4006
4071
  return /* @__PURE__ */ jsxRuntime.jsx(
4007
4072
  salesFrontendDesignSystem.FormField.TextField,
4008
4073
  {
4009
- ...props,
4010
- id: field.name,
4074
+ ...restProps,
4075
+ ...restField,
4076
+ id: propsId ?? fieldName,
4011
4077
  size,
4012
4078
  autoComplete: "off",
4013
- name: field.name,
4014
- value: field.value ?? "",
4015
- disabled: field.disabled,
4016
- error: fieldState.invalid || error,
4079
+ name: fieldName,
4080
+ value: fieldValue ?? "",
4081
+ disabled: fieldDisabled,
4082
+ error: fieldState.invalid || propsError,
4017
4083
  onChange: (e) => {
4018
- field.onChange(e);
4019
- onChange?.(e);
4084
+ propsOnChange?.(e);
4085
+ fieldOnChange?.(e);
4020
4086
  },
4021
4087
  onBlur: (e) => {
4022
- field.onBlur();
4023
- onBlur?.(e);
4088
+ propsOnBlur?.(e);
4089
+ fieldOnBlur?.();
4024
4090
  },
4025
4091
  rootProps: {
4026
- ...rootProps,
4092
+ ...propsRootProps,
4027
4093
  onClear: () => {
4028
- field.onChange("");
4029
- rootProps?.onClear?.();
4094
+ fieldOnChange?.("");
4095
+ propsRootProps?.onClear?.();
4030
4096
  }
4031
4097
  }
4032
4098
  }
@@ -4034,55 +4100,59 @@ const HookFormTextField = ({
4034
4100
  };
4035
4101
 
4036
4102
  const HookFormDatePickerRenew = ({
4037
- name,
4038
- control,
4039
- disabled,
4040
- defaultValue,
4103
+ useControllerProps,
4041
4104
  datepickerProps
4042
4105
  }) => {
4043
- const { field, fieldState } = reactHookForm.useController({ name, control, disabled, defaultValue });
4106
+ const controllerDefaultValue = datepickerProps.defaultValue ? dayjs(datepickerProps.defaultValue).toDate() : void 0;
4107
+ const { field, fieldState } = reactHookForm.useController({
4108
+ defaultValue: controllerDefaultValue,
4109
+ ...useControllerProps
4110
+ });
4044
4111
  return /* @__PURE__ */ jsxRuntime.jsx(
4045
4112
  salesFrontendDesignSystem.DatePickerSingleRenew,
4046
4113
  {
4114
+ ...datepickerProps,
4047
4115
  defaultValue: field.value ? dayjs(field.value) : void 0,
4048
4116
  onValueChange: (value) => {
4117
+ datepickerProps.onValueChange?.(value);
4049
4118
  field.onChange(dayjs(value).toDate());
4050
4119
  },
4051
4120
  inputProps: {
4121
+ ...datepickerProps.inputProps,
4052
4122
  comboBoxItemProps: {
4053
- error: fieldState.invalid,
4054
4123
  ...datepickerProps.inputProps?.comboBoxItemProps,
4124
+ error: fieldState.invalid,
4055
4125
  ...field
4056
- },
4057
- ...datepickerProps.inputProps
4058
- },
4059
- ...datepickerProps
4126
+ }
4127
+ }
4060
4128
  }
4061
4129
  );
4062
4130
  };
4063
4131
 
4064
4132
  const HookFormDateRangePickerRenew = ({
4065
- name,
4066
- control,
4067
- disabled,
4068
- defaultValue,
4133
+ useControllerProps,
4069
4134
  startDateProps,
4070
4135
  endDateProps
4071
4136
  }) => {
4137
+ const controllerDefaultValue = {
4138
+ startDate: startDateProps.defaultValue ? dayjs(startDateProps.defaultValue) : void 0,
4139
+ endDate: endDateProps.defaultValue ? dayjs(endDateProps.defaultValue) : void 0
4140
+ };
4072
4141
  const { field, fieldState } = reactHookForm.useController({
4073
- name,
4074
- control,
4075
- disabled,
4076
- defaultValue
4142
+ defaultValue: controllerDefaultValue,
4143
+ ...useControllerProps
4077
4144
  });
4078
4145
  const { name: fieldName, onChange, ...restField } = field;
4079
4146
  const startDateMergedProps = {
4147
+ ...startDateProps,
4148
+ inputFormat: startDateProps.inputFormat || "YY.MM.DD",
4080
4149
  defaultValue: field.value?.startDate ? dayjs(field.value?.startDate) : void 0,
4081
4150
  calendarProps: {
4082
4151
  max: field.value?.endDate ? dayjs(field.value?.endDate) : void 0,
4083
- ...startDateProps?.calendarProps
4152
+ ...startDateProps.calendarProps
4084
4153
  },
4085
4154
  onValueChange: (value) => {
4155
+ startDateProps.onValueChange?.(value);
4086
4156
  if (field.value) {
4087
4157
  onChange({
4088
4158
  startDate: value.toDate(),
@@ -4090,26 +4160,27 @@ const HookFormDateRangePickerRenew = ({
4090
4160
  });
4091
4161
  }
4092
4162
  },
4093
- inputFormat: "YY.MM.DD",
4094
4163
  inputProps: {
4164
+ ...startDateProps.inputProps,
4095
4165
  comboBoxItemProps: {
4166
+ ...startDateProps.inputProps?.comboBoxItemProps,
4096
4167
  name: `${fieldName}.startDate`,
4097
- size: "small",
4168
+ size: startDateProps.inputProps?.comboBoxItemProps?.size || "small",
4098
4169
  error: fieldState.invalid,
4099
- ...startDateProps?.inputProps?.comboBoxItemProps,
4100
4170
  ...restField
4101
- },
4102
- ...startDateProps?.inputProps
4103
- },
4104
- ...startDateProps
4171
+ }
4172
+ }
4105
4173
  };
4106
4174
  const endDateMergedProps = {
4175
+ ...endDateProps,
4176
+ inputFormat: endDateProps.inputFormat || "YY.MM.DD",
4107
4177
  defaultValue: field.value?.endDate ? dayjs(field.value?.endDate) : void 0,
4108
4178
  calendarProps: {
4109
4179
  min: field.value?.startDate ? dayjs(field.value?.startDate) : void 0,
4110
- ...endDateProps?.calendarProps
4180
+ ...endDateProps.calendarProps
4111
4181
  },
4112
4182
  onValueChange: (value) => {
4183
+ endDateProps.onValueChange?.(value);
4113
4184
  if (field.value) {
4114
4185
  onChange({
4115
4186
  startDate: field.value?.startDate,
@@ -4117,18 +4188,16 @@ const HookFormDateRangePickerRenew = ({
4117
4188
  });
4118
4189
  }
4119
4190
  },
4120
- inputFormat: "YY.MM.DD",
4121
4191
  inputProps: {
4192
+ ...endDateProps.inputProps,
4122
4193
  comboBoxItemProps: {
4194
+ ...endDateProps.inputProps?.comboBoxItemProps,
4123
4195
  name: `${fieldName}.endDate`,
4124
- size: "small",
4196
+ size: endDateProps.inputProps?.comboBoxItemProps?.size || "small",
4125
4197
  error: fieldState.invalid,
4126
- ...endDateProps?.inputProps?.comboBoxItemProps,
4127
4198
  ...restField
4128
- },
4129
- ...endDateProps?.inputProps
4130
- },
4131
- ...endDateProps
4199
+ }
4200
+ }
4132
4201
  };
4133
4202
  return /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.DatePickerRangeRenew, { startDateProps: startDateMergedProps, endDateProps: endDateMergedProps });
4134
4203
  };