@omniumretail/component-library 1.1.94 → 1.1.95

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.
@@ -44,6 +44,6 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
44
44
  buttonActionName?: string;
45
45
  buttonActionLabel?: (record: any) => string | null;
46
46
  buttonActionMethod?: () => void;
47
- buttonActionStyle?: string;
47
+ buttonActionStyle?: string | ((record: any) => any);
48
48
  }
49
49
  export declare const ResponsiveTable: (props: ResponsiveTableCustomProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.1.94",
3
+ "version": "1.1.95",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -50,7 +50,7 @@ const Template: Story<any> = (args) => {
50
50
  "IsNumeric": false,
51
51
  "IsDate": false,
52
52
  "HasGrade": false,
53
- "IsEmphasis": false,
53
+ "IsEmphasis": true,
54
54
  "IsMultipleChoise": true,
55
55
  "State": "Finished",
56
56
  "Grade": 0,
@@ -24,10 +24,14 @@ export const SingleQuestion = ({
24
24
  const [emphasisCheckbox, setEmphasisCheckbox] = useState<boolean>(false);
25
25
  const [multipleChoiseCheckbox, setMultipleChoiseCheckbox] = useState<boolean>(false);
26
26
 
27
- const filteredIds = responseTypeOptions
27
+ const filteredResponsesMultiple = responseTypeOptions
28
28
  ?.filter((item: { IsMultipleChoise: any; }) => item.IsMultipleChoise)
29
29
  ?.map((item: { Id: any; }) => item.Id);
30
30
 
31
+ const filteredResponsesEmphasised = responseTypeOptions
32
+ ?.filter((item: { IsEmphasis: any; }) => item.IsEmphasis)
33
+ ?.map((item: { Id: any; }) => item.Id);
34
+
31
35
  const sortedAnswerTypeOptions = responseTypeOptions?.sort((a: any, b: any) => {
32
36
  return Number(a.IsMultipleChoise) - Number(b.IsMultipleChoise);
33
37
  });
@@ -180,23 +184,25 @@ export const SingleQuestion = ({
180
184
  <span>{t('components.category.mandatoryAnswer')}</span>
181
185
  </div>
182
186
 
183
- <div className={styles.checkboxContainer}>
184
- <Form.Item
185
- {...restField}
186
- name={[name, 'emphasis']}
187
- valuePropName='checked'
187
+ {filteredResponsesEmphasised?.includes(form.getFieldsValue().questions?.[name]?.responseType) &&
188
+ <div className={styles.checkboxContainer}>
189
+ <Form.Item
190
+ {...restField}
191
+ name={[name, 'emphasis']}
192
+ valuePropName='checked'
188
193
  // getValueProps={() => ({ checked: emphasisCheckbox })}
189
- >
190
- <Checkbox
191
- onChange={(e) => onCheckboxEmphasisHandler(e.target.checked)}
192
- checked={emphasisCheckbox}
193
- />
194
- </Form.Item>
194
+ >
195
+ <Checkbox
196
+ onChange={(e) => onCheckboxEmphasisHandler(e.target.checked)}
197
+ checked={emphasisCheckbox}
198
+ />
199
+ </Form.Item>
195
200
 
196
- <span>{t('components.category.emphasisAnswer')}</span>
197
- </div>
201
+ <span>{t('components.category.emphasisAnswer')}</span>
202
+ </div>
203
+ }
198
204
 
199
- {filteredIds?.includes(form.getFieldsValue().questions?.[name]?.responseType) &&
205
+ {filteredResponsesMultiple?.includes(form.getFieldsValue().questions?.[name]?.responseType) &&
200
206
  < div className={styles.checkboxContainer}>
201
207
  <Form.Item
202
208
  {...restField}
@@ -50,7 +50,7 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
50
50
  buttonActionName?: string;
51
51
  buttonActionLabel?: (record: any) => string | null;
52
52
  buttonActionMethod?: () => void;
53
- buttonActionStyle?: string;
53
+ buttonActionStyle?: string | ((record: any) => any);
54
54
  }
55
55
 
56
56
  export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
@@ -206,11 +206,14 @@ export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
206
206
  render: (_: any, record: any) => {
207
207
  if (!items?.[0]) return null;
208
208
  const buttonLabel = buttonActionLabel ? buttonActionLabel(record) : null;
209
+ const buttonClass = typeof buttonActionStyle === 'function'
210
+ ? buttonActionStyle(record) // Se for uma função, chama com o `record`
211
+ : buttonActionStyle || ''; // Se for string, usa diretamente
209
212
 
210
213
  return (
211
214
  <Space size="middle">
212
215
  {(buttonActionName || buttonLabel) &&
213
- <Button customClass={buttonActionStyle} onClick={() => buttonActionMethod?.()}>{buttonActionName || buttonLabel}</Button>
216
+ <Button customClass={buttonClass} onClick={() => buttonActionMethod?.()}>{buttonActionName || buttonLabel}</Button>
214
217
  }
215
218
 
216
219
  <Dropdown menu={{ items }}>
@@ -53,7 +53,7 @@
53
53
  "errorResponseType": "Response type missing",
54
54
  "header": "Header",
55
55
  "color": "Assigned colour",
56
- "flagged": "Flagged",
56
+ "flagged": "Emphasise",
57
57
  "multipleChoise": "Multiple selection",
58
58
  "placeholderScore": "Score",
59
59
  "answerNameIsMissing": "Missing name",
@@ -53,7 +53,7 @@
53
53
  "errorResponseType": "Tipo de respuesta faltante",
54
54
  "header": "Cabecera",
55
55
  "color": "Color asignado",
56
- "flagged": "Marcado",
56
+ "flagged": "Destacar",
57
57
  "multipleChoise": "Selección múltiple",
58
58
  "placeholderScore": "Puntuación",
59
59
  "answerNameIsMissing": "Falta el nombre",
@@ -54,7 +54,7 @@
54
54
  "answerNameIsMissing": "Nome em falta",
55
55
  "header": "Cabeçalho",
56
56
  "color": "Cor atribuída",
57
- "flagged": "Sinalizado",
57
+ "flagged": "Destacar",
58
58
  "multipleChoise": "Seleção múltipla",
59
59
  "placeholderScore": "Pontuação",
60
60
  "typeResponseNameIsMissing": "Nome do tipo de resposta em falta",