oa-componentbook 1.0.1-stage.364 → 1.0.1-stage.366

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.
@@ -10,6 +10,7 @@ require("core-js/modules/web.dom-collections.iterator.js");
10
10
  require("core-js/modules/es.symbol.description.js");
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
+ var _icons = require("@ant-design/icons");
13
14
  var _CustomButton = _interopRequireDefault(require("../../components/oa-component-button/CustomButton"));
14
15
  var _CustomInput = _interopRequireDefault(require("../../components/oa-component-input/CustomInput"));
15
16
  var _CustomUpload = _interopRequireDefault(require("../../components/oa-component-upload/CustomUpload"));
@@ -17,9 +18,8 @@ var _CustomRadio = _interopRequireDefault(require("../../components/oa-component
17
18
  var _CustomCheckBox = _interopRequireDefault(require("../../components/oa-component-checkbox/CustomCheckBox"));
18
19
  var _CustomSelect = _interopRequireDefault(require("../../components/oa-component-select/CustomSelect"));
19
20
  var _CustomTextArea = _interopRequireDefault(require("../../components/oa-component-textarea/CustomTextArea"));
20
- var _icons = require("@ant-design/icons");
21
21
  var _CustomSteps = _interopRequireDefault(require("../../components/oa-component-steps/CustomSteps"));
22
- var _Typography = require("../../components/oa-component-typography/Typography");
22
+ var _Typography = _interopRequireDefault(require("../../components/oa-component-typography/Typography"));
23
23
  var _utils = require("../../utils");
24
24
  var _styles = require("./styles");
25
25
  const _excluded = ["data", "data-test", "current", "initialAnswers", "onComplete", "onStepChange", "style", "showSubmitButton"];
@@ -44,7 +44,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
44
44
  function ProgressiveStepsWidget(_ref) {
45
45
  let {
46
46
  data,
47
- 'data-test': dataTest,
47
+ "data-test": dataTest,
48
48
  current: externalCurrent,
49
49
  initialAnswers = {},
50
50
  onComplete,
@@ -105,12 +105,10 @@ function ProgressiveStepsWidget(_ref) {
105
105
  };
106
106
 
107
107
  // Check if all steps are completed (including pre-populated ones)
108
- const isAllStepsCompleted = () => {
109
- return steps.every((step, index) => {
110
- const stepId = step.key || index;
111
- return answers[stepId] !== undefined;
112
- });
113
- };
108
+ const isAllStepsCompleted = () => steps.every((step, index) => {
109
+ const stepId = step.key || index;
110
+ return answers[stepId] !== undefined;
111
+ });
114
112
  const renderAnswerInput = (step, stepIndex) => {
115
113
  const {
116
114
  answerType,
@@ -121,24 +119,20 @@ function ProgressiveStepsWidget(_ref) {
121
119
  const stepId = step.key || stepIndex;
122
120
  const currentAnswer = answers[stepId];
123
121
  switch (answerType) {
124
- case 'singleSelect':
122
+ case "singleSelect":
125
123
  return /*#__PURE__*/_react.default.createElement("div", {
126
- style: {
127
- display: 'flex',
128
- gap: '12px',
129
- flexWrap: 'wrap'
130
- }
124
+ className: "optionBtnSec"
131
125
  }, answerOptions === null || answerOptions === void 0 ? void 0 : answerOptions.map((option, idx) => /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
132
126
  key: idx,
133
- type: currentAnswer === (option.value || option) ? 'primary' : 'secondary',
127
+ type: currentAnswer === (option.value || option) ? "primary" : "secondary",
134
128
  onClick: () => handleAnswer(stepIndex, option.value || option),
135
129
  label: option.label || option,
136
130
  "data-test": dataTest ? "".concat(dataTest, "--button-").concat(stepIndex, "-").concat(idx) : undefined
137
131
  })));
138
- case 'button':
132
+ case "button":
139
133
  return /*#__PURE__*/_react.default.createElement("div", null, answerOptions === null || answerOptions === void 0 ? void 0 : answerOptions.map((option, idx) => /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
140
134
  key: idx,
141
- type: option.type || 'primary',
135
+ type: option.type || "primary",
142
136
  onClick: () => {
143
137
  // Execute custom click function if provided
144
138
  if (option.onClick) {
@@ -150,10 +144,10 @@ function ProgressiveStepsWidget(_ref) {
150
144
  }
151
145
  },
152
146
  label: option.label || option,
153
- size: option.size || 'default',
147
+ size: option.size || "default",
154
148
  "data-test": dataTest ? "".concat(dataTest, "--button-").concat(stepIndex, "-").concat(idx) : undefined
155
149
  })));
156
- case 'custom':
150
+ case "custom":
157
151
  // Render custom component with props for integration
158
152
  if (customComponent) {
159
153
  const CustomComponent = customComponent;
@@ -165,44 +159,23 @@ function ProgressiveStepsWidget(_ref) {
165
159
  }, step.customProps));
166
160
  }
167
161
  return null;
168
- case 'paymentOptions':
169
- return /*#__PURE__*/_react.default.createElement("div", {
170
- style: {
171
- width: '100%'
172
- }
173
- }, answerOptions === null || answerOptions === void 0 ? void 0 : answerOptions.map((option, idx) => /*#__PURE__*/_react.default.createElement("div", {
174
- key: idx,
175
- style: {
176
- border: '1px solid #d9d9d9',
177
- borderRadius: '8px',
178
- padding: '16px',
179
- marginBottom: '12px',
180
- display: 'flex',
181
- justifyContent: 'space-between',
182
- alignItems: 'center',
183
- backgroundColor: currentAnswer === (option.value || option) ? '#f0f8ff' : 'white',
184
- // cursor: 'pointer',
185
- transition: 'all 0.3s ease'
186
- }
162
+ case "paymentOptions":
163
+ return /*#__PURE__*/_react.default.createElement("ul", {
164
+ className: "bankDetailSec"
165
+ }, answerOptions === null || answerOptions === void 0 ? void 0 : answerOptions.map((option, idx) => /*#__PURE__*/_react.default.createElement("li", {
166
+ key: idx
187
167
  // onClick={() => handleAnswer(stepIndex, option.value || option)}
188
168
  ,
189
169
  "data-test": dataTest ? "".concat(dataTest, "--payment-option-").concat(stepIndex, "-").concat(idx) : undefined
190
- }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
191
- style: {
192
- fontSize: '16px',
193
- fontWeight: '500',
194
- color: currentAnswer === (option.value || option) ? '#1890ff' : '#000'
195
- }
196
- }, option.label || option), option.description && /*#__PURE__*/_react.default.createElement("div", {
197
- style: {
198
- fontSize: '14px',
199
- color: '#666',
200
- marginTop: '4px'
201
- }
170
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
171
+ typography: "type-button-500"
172
+ }, option.label || option), option.description && /*#__PURE__*/_react.default.createElement(_Typography.default, {
173
+ typography: "type-b2-400",
174
+ color: "secondary-content"
202
175
  }, option.description)), /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
203
176
  type: "text-only",
204
- size: "small",
205
- label: option.detailsText || 'Enter details',
177
+ size: "medium",
178
+ label: option.detailsText || "Enter details",
206
179
  onClick: e => {
207
180
  e.stopPropagation();
208
181
  if (option.onDetailsClick) {
@@ -210,22 +183,22 @@ function ProgressiveStepsWidget(_ref) {
210
183
  }
211
184
  }
212
185
  }))));
213
- case 'text':
186
+ case "text":
214
187
  return /*#__PURE__*/_react.default.createElement(_CustomInput.default, {
215
- placeholder: placeholder || 'Enter your answer...',
216
- value: currentAnswer || '',
188
+ placeholder: placeholder || "Enter your answer...",
189
+ value: currentAnswer || "",
217
190
  onChange: e => handleAnswer(stepIndex, e.target.value),
218
191
  "data-test": dataTest ? "".concat(dataTest, "--text-input-").concat(stepIndex) : undefined
219
192
  });
220
- case 'textarea':
193
+ case "textarea":
221
194
  return /*#__PURE__*/_react.default.createElement(_CustomTextArea.default, {
222
- placeholder: placeholder || 'Enter your answer...',
223
- value: currentAnswer || '',
195
+ placeholder: placeholder || "Enter your answer...",
196
+ value: currentAnswer || "",
224
197
  onChange: e => handleAnswer(stepIndex, e.target.value),
225
198
  rows: 4,
226
199
  "data-test": dataTest ? "".concat(dataTest, "--textarea-").concat(stepIndex) : undefined
227
200
  });
228
- case 'upload':
201
+ case "upload":
229
202
  return /*#__PURE__*/_react.default.createElement(_CustomUpload.default, {
230
203
  beforeUpload: file => {
231
204
  handleAnswer(stepIndex, file);
@@ -235,11 +208,11 @@ function ProgressiveStepsWidget(_ref) {
235
208
  }, /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
236
209
  iconConfig: {
237
210
  icon: /*#__PURE__*/_react.default.createElement(_icons.UploadOutlined, null),
238
- position: 'left'
211
+ position: "left"
239
212
  },
240
213
  label: "Upload File"
241
214
  }));
242
- case 'radio':
215
+ case "radio":
243
216
  return /*#__PURE__*/_react.default.createElement(_CustomRadio.default.Group, {
244
217
  value: currentAnswer,
245
218
  onChange: e => handleAnswer(stepIndex, e.target.value),
@@ -249,7 +222,7 @@ function ProgressiveStepsWidget(_ref) {
249
222
  value: option.value || option,
250
223
  label: option.label || option
251
224
  })));
252
- case 'checkbox':
225
+ case "checkbox":
253
226
  return /*#__PURE__*/_react.default.createElement(_CustomCheckBox.default.Group, {
254
227
  value: currentAnswer || [],
255
228
  onChange: values => handleAnswer(stepIndex, values),
@@ -259,9 +232,9 @@ function ProgressiveStepsWidget(_ref) {
259
232
  value: option.value || option,
260
233
  label: option.label || option
261
234
  })));
262
- case 'select':
235
+ case "select":
263
236
  return /*#__PURE__*/_react.default.createElement(_CustomSelect.default, {
264
- placeholder: placeholder || 'Select an option...',
237
+ placeholder: placeholder || "Select an option...",
265
238
  value: currentAnswer,
266
239
  onSelectionChange: value => handleAnswer(stepIndex, value.value),
267
240
  options: answerOptions === null || answerOptions === void 0 ? void 0 : answerOptions.map((option, idx) => ({
@@ -276,68 +249,61 @@ function ProgressiveStepsWidget(_ref) {
276
249
  };
277
250
 
278
251
  // Prepare steps data for CustomSteps component
279
- const prepareStepsForCustomSteps = () => {
280
- return steps.map((step, stepIndex) => {
281
- const stepId = step.key || stepIndex;
282
- const isActive = stepIndex === currentStep;
283
- const isCompleted = stepIndex < currentStep && answers[stepId] !== undefined;
284
- const isDisabled = stepIndex > currentStep;
285
- const isVisible = stepIndex < visibleSteps;
286
- const hasAnswer = answers[stepId] !== undefined;
287
- if (!isVisible) return null;
288
-
289
- // Get dynamic content based on answer state
290
- const getDynamicContent = () => {
291
- if (!hasAnswer || !step.dynamicContent) return null;
292
- const dynamicContent = step.dynamicContent;
252
+ const prepareStepsForCustomSteps = () => steps.map((step, stepIndex) => {
253
+ const stepId = step.key || stepIndex;
254
+ const isActive = stepIndex === currentStep;
255
+ const isCompleted = stepIndex < currentStep && answers[stepId] !== undefined;
256
+ const isDisabled = stepIndex > currentStep;
257
+ const isVisible = stepIndex < visibleSteps;
258
+ const hasAnswer = answers[stepId] !== undefined;
259
+ if (!isVisible) return null;
293
260
 
294
- // Check if we should show dynamic content for this answer
295
- const shouldShowDynamic = typeof dynamicContent.showFor === 'function' ? dynamicContent.showFor(answers[stepId]) : dynamicContent.showFor === answers[stepId] || dynamicContent.showFor === true;
296
- if (!shouldShowDynamic) return null;
297
- return {
298
- title: dynamicContent.title || step.title,
299
- description: typeof dynamicContent.description === 'function' ? dynamicContent.description(answers[stepId]) : dynamicContent.description,
300
- descriptionStyle: dynamicContent.descriptionStyle,
301
- hideAnswerInput: dynamicContent.hideAnswerInput || false
302
- };
303
- };
304
- const dynamicContent = getDynamicContent();
305
- const displayTitle = (dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.title) || step.title;
306
- const displayDescription = (dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.description) || step.description;
307
- const displayDescriptionStyle = dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.descriptionStyle;
308
- const shouldHideAnswerInput = (dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.hideAnswerInput) || false;
261
+ // Get dynamic content based on answer state
262
+ const getDynamicContent = () => {
263
+ if (!hasAnswer || !step.dynamicContent) return null;
264
+ const {
265
+ dynamicContent
266
+ } = step;
309
267
 
310
- // Create the step content with question and answer
311
- const stepContent = /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
312
- style: {
313
- fontSize: '16px',
314
- fontWeight: '500',
315
- color: isActive ? '#1890ff' : isCompleted ? '#52c41a' : isDisabled ? '#d9d9d9' : '#000',
316
- marginBottom: '8px'
317
- }
318
- }, (0, _utils.isString)(displayTitle) || (0, _utils.isNumber)(displayTitle) ? /*#__PURE__*/_react.default.createElement("span", {
319
- "data-test": "".concat(dataTest, "--title-(").concat(displayTitle, ")")
320
- }, displayTitle) : displayTitle), displayDescription && /*#__PURE__*/_react.default.createElement("div", {
321
- style: _objectSpread({
322
- color: '#666',
323
- fontSize: '14px',
324
- marginBottom: '12px'
325
- }, displayDescriptionStyle)
326
- }, displayDescription), (isActive || isCompleted) && !shouldHideAnswerInput && /*#__PURE__*/_react.default.createElement("div", {
327
- style: {
328
- marginTop: '12px'
329
- }
330
- }, renderAnswerInput(step, stepIndex)));
268
+ // Check if we should show dynamic content for this answer
269
+ const shouldShowDynamic = typeof dynamicContent.showFor === "function" ? dynamicContent.showFor(answers[stepId]) : dynamicContent.showFor === answers[stepId] || dynamicContent.showFor === true;
270
+ if (!shouldShowDynamic) return null;
331
271
  return {
332
- key: step.key || stepIndex,
333
- title: stepContent,
334
- disabled: isDisabled
272
+ title: dynamicContent.title || step.title,
273
+ description: typeof dynamicContent.description === "function" ? dynamicContent.description(answers[stepId]) : dynamicContent.description,
274
+ descriptionStyle: dynamicContent.descriptionStyle,
275
+ hideAnswerInput: dynamicContent.hideAnswerInput || false
335
276
  };
336
- }).filter(Boolean); // Remove null entries
337
- };
338
- return /*#__PURE__*/_react.default.createElement(_styles.StepsContainer, {
339
- style: style
340
- }, /*#__PURE__*/_react.default.createElement(_CustomSteps.default, _extends({
277
+ };
278
+ const dynamicContent = getDynamicContent();
279
+ const displayTitle = (dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.title) || step.title;
280
+ const displayDescription = (dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.description) || step.description;
281
+ const displayDescriptionStyle = dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.descriptionStyle;
282
+ const shouldHideAnswerInput = (dynamicContent === null || dynamicContent === void 0 ? void 0 : dynamicContent.hideAnswerInput) || false;
283
+
284
+ // Create the step content with question and answer
285
+ const stepContent = /*#__PURE__*/_react.default.createElement("div", {
286
+ className: "stepQanAnsBox"
287
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
288
+ color: isActive ? "primary-content" : isCompleted ? "secondary-content" : isDisabled ? "secondary-content" : "secondary-content",
289
+ typography: isActive ? "type-button-500" : isCompleted ? "type-b2-400" : isDisabled ? "type-b2-400" : "type-b2-400"
290
+ }, (0, _utils.isString)(displayTitle) || (0, _utils.isNumber)(displayTitle) ? /*#__PURE__*/_react.default.createElement("span", {
291
+ "data-test": "".concat(dataTest, "--title-(").concat(displayTitle, ")")
292
+ }, displayTitle) : displayTitle), displayDescription && /*#__PURE__*/_react.default.createElement("div", {
293
+ className: "margin-top-4"
294
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, _extends({}, displayDescriptionStyle, {
295
+ color: "secondary-content",
296
+ typography: "type-b2-400"
297
+ }), displayDescription)), (isActive || isCompleted) && !shouldHideAnswerInput && /*#__PURE__*/_react.default.createElement("div", {
298
+ className: "margin-top-12"
299
+ }, renderAnswerInput(step, stepIndex)));
300
+ return {
301
+ key: step.key || stepIndex,
302
+ title: stepContent,
303
+ disabled: isDisabled
304
+ };
305
+ }).filter(Boolean); // Remove null entries
306
+ return /*#__PURE__*/_react.default.createElement(_styles.StepsContainer, null, /*#__PURE__*/_react.default.createElement(_CustomSteps.default, _extends({
341
307
  data: {
342
308
  steps: prepareStepsForCustomSteps()
343
309
  },
@@ -358,7 +324,7 @@ ProgressiveStepsWidget.propTypes = {
358
324
  key: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
359
325
  title: _propTypes.default.node,
360
326
  description: _propTypes.default.node,
361
- answerType: _propTypes.default.oneOf(['singleSelect', 'button', 'paymentOptions', 'text', 'textarea', 'upload', 'radio', 'checkbox', 'select', 'custom']),
327
+ answerType: _propTypes.default.oneOf(["singleSelect", "button", "paymentOptions", "text", "textarea", "upload", "radio", "checkbox", "select", "custom"]),
362
328
  answerOptions: _propTypes.default.array,
363
329
  placeholder: _propTypes.default.string,
364
330
  customComponent: _propTypes.default.elementType,
@@ -372,7 +338,7 @@ ProgressiveStepsWidget.propTypes = {
372
338
  })
373
339
  }))
374
340
  }),
375
- 'data-test': _propTypes.default.string,
341
+ "data-test": _propTypes.default.string,
376
342
  current: _propTypes.default.number,
377
343
  initialAnswers: _propTypes.default.object,
378
344
  onComplete: _propTypes.default.func,
@@ -384,7 +350,7 @@ ProgressiveStepsWidget.defaultProps = {
384
350
  data: {
385
351
  steps: []
386
352
  },
387
- 'data-test': null,
353
+ "data-test": null,
388
354
  current: 0,
389
355
  initialAnswers: {},
390
356
  onComplete: undefined,
@@ -8,5 +8,5 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
8
  var _templateObject, _templateObject2;
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
11
- const StepsContainer = exports.StepsContainer = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 20px;\n max-width: 600px;\n margin: 0 auto;\n"])));
11
+ const StepsContainer = exports.StepsContainer = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\n.stepQanAnsBox{line-height:normal; margin-bottom:24px;}\n.ant-steps.ant-steps-vertical >.ant-steps-item .ant-steps-item-icon{margin-inline-end: 12px;\n border: none; width: 28px; height: 28px; line-height: normal; display: flex; align-items: center; justify-content: center;}\n.ant-steps .ant-steps-item-process>.ant-steps-item-container>.ant-steps-item-tail::after, .ant-steps .ant-steps-item-finish>.ant-steps-item-container>.ant-steps-item-tail::after{background-color:#E0E0E0;}\n.ant-steps .ant-steps-item-finish .ant-steps-item-icon {background-color:#00875A;}\n.ant-steps .ant-steps-item-finish .ant-steps-item-icon >.ant-steps-icon{color:#fff;}\n.ant-steps .ant-steps-item-process .ant-steps-item-icon{background-color: #014FC5;}\n.ant-steps.ant-steps-vertical >.ant-steps-item .ant-steps-item-title { padding-inline-end: 0; line-height: normal;\n width: 100%;}\n\nul.bankDetailSec{display: flex;\n flex-direction: column; gap: 16px;\n padding: 0;\n margin: 0;}\nul.bankDetailSec li{display: flex;\n justify-content: space-between;\n align-items: center;\n flex-direction: row;\n border: 1px solid rgb(217, 217, 217);\n border-radius: 6px;\n padding: 12px;\n margin: 0;}\n\n .ant-steps-item-tail {\n inset-inline-start: 15px !important;\n }\n.optionBtnSec{display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 12px;}\n.optionBtnSec button{width:50%;}\n.optionBtnSec button {\n width: calc(50% - 6px);\n}\n\n\n"])));
12
12
  const SubmitButton = exports.SubmitButton = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-top: 32px;\n text-align: center;\n padding-top: 20px;\n border-top: 1px solid #f0f0f0;\n"])));