@ftdata/ui 0.0.9 → 0.0.11

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.
Files changed (84) hide show
  1. package/dist/components/DoubleList/DoubleList.stories.d.ts +2 -2
  2. package/dist/components/DoubleList/DoubleList.stories.js +43 -43
  3. package/dist/components/DoubleList/Row/index.d.ts +4 -0
  4. package/dist/components/DoubleList/Row/index.js +12 -0
  5. package/dist/components/DoubleList/Row/style.d.ts +1 -0
  6. package/dist/components/DoubleList/Row/style.js +31 -0
  7. package/dist/components/DoubleList/index.js +27 -35
  8. package/dist/components/DoubleList/style.d.ts +0 -1
  9. package/dist/components/DoubleList/style.js +2 -31
  10. package/dist/components/Menu/Menu.stories.d.ts +6 -0
  11. package/dist/components/Menu/Menu.stories.js +116 -0
  12. package/dist/components/Menu/index.js +29 -14
  13. package/dist/components/Menu/styles.d.ts +1 -0
  14. package/dist/components/Menu/styles.js +44 -28
  15. package/dist/components/MultiSelect/MultiSelectList/Row/index.d.ts +7 -0
  16. package/dist/components/MultiSelect/MultiSelectList/Row/index.js +26 -0
  17. package/dist/components/MultiSelect/MultiSelectList/Row/style.d.ts +6 -0
  18. package/dist/components/MultiSelect/MultiSelectList/Row/style.js +48 -0
  19. package/dist/components/MultiSelect/MultiSelectList/index.d.ts +4 -3
  20. package/dist/components/MultiSelect/MultiSelectList/index.js +51 -41
  21. package/dist/components/MultiSelect/MultiSelectList/style.d.ts +0 -1
  22. package/dist/components/MultiSelect/MultiSelectList/style.js +2 -31
  23. package/dist/components/MultiSelect/helpers/addOption.d.ts +5 -0
  24. package/dist/components/MultiSelect/helpers/addOption.js +14 -0
  25. package/dist/components/MultiSelect/helpers/computeUnselected.d.ts +2 -0
  26. package/dist/components/MultiSelect/helpers/computeUnselected.js +2 -0
  27. package/dist/components/MultiSelect/helpers/feedbackText.d.ts +5 -0
  28. package/dist/components/MultiSelect/helpers/feedbackText.js +30 -0
  29. package/dist/components/MultiSelect/helpers/filterOptions.d.ts +2 -0
  30. package/dist/components/MultiSelect/helpers/filterOptions.js +5 -0
  31. package/dist/components/MultiSelect/helpers/removeOptions.d.ts +5 -0
  32. package/dist/components/MultiSelect/helpers/removeOptions.js +9 -0
  33. package/dist/components/MultiSelect/index.d.ts +29 -14
  34. package/dist/components/MultiSelect/index.js +149 -215
  35. package/dist/components/MultiSelect/styles.d.ts +6 -5
  36. package/dist/components/MultiSelect/styles.js +20 -66
  37. package/dist/components/Select/List/Row/index.d.ts +11 -0
  38. package/dist/components/Select/List/Row/index.js +29 -0
  39. package/dist/components/{CustomSelect/CustomSelectList → Select/List/Row}/style.d.ts +0 -2
  40. package/dist/components/{CustomSelect/CustomSelectList → Select/List/Row}/style.js +1 -54
  41. package/dist/components/Select/List/index.d.ts +12 -0
  42. package/dist/components/Select/List/index.js +63 -0
  43. package/dist/components/Select/List/style.d.ts +2 -0
  44. package/dist/components/Select/List/style.js +56 -0
  45. package/dist/components/Select/index.d.ts +34 -0
  46. package/dist/components/{CustomSelect → Select}/index.js +11 -9
  47. package/dist/components/{CustomSelect → Select}/styles.d.ts +2 -2
  48. package/dist/components/{CustomSelect → Select}/styles.js +6 -8
  49. package/dist/components/fields/components/HelpText/index.d.ts +8 -0
  50. package/dist/components/fields/components/HelpText/index.js +35 -0
  51. package/dist/components/fields/components/HelpText/modifiers/colors.d.ts +4 -0
  52. package/dist/components/fields/components/HelpText/modifiers/colors.js +9 -0
  53. package/dist/components/fields/components/HelpText/styles.d.ts +2 -0
  54. package/dist/components/fields/components/HelpText/styles.js +19 -0
  55. package/dist/components/fields/components/Label/index.d.ts +8 -0
  56. package/dist/components/fields/components/Label/index.js +22 -0
  57. package/dist/components/fields/components/Label/styles.d.ts +5 -0
  58. package/dist/components/fields/components/Label/styles.js +28 -0
  59. package/dist/components/fields/components/RotateButton/index.d.ts +6 -0
  60. package/dist/components/fields/components/RotateButton/index.js +13 -0
  61. package/dist/components/fields/components/RotateButton/styles.d.ts +5 -0
  62. package/dist/components/fields/components/RotateButton/styles.js +10 -0
  63. package/dist/components/fields/helpers/getFeedbackType.d.ts +2 -0
  64. package/dist/components/fields/helpers/getFeedbackType.js +11 -0
  65. package/dist/components/fields/modifiers/color_modifiers.d.ts +2 -0
  66. package/dist/components/fields/modifiers/color_modifiers.js +7 -0
  67. package/dist/components/fields/modifiers/inputColorModifier.d.ts +2 -0
  68. package/dist/components/fields/modifiers/inputColorModifier.js +14 -0
  69. package/dist/components/fields/modifiers/selectColorModifier.d.ts +2 -0
  70. package/dist/components/fields/modifiers/selectColorModifier.js +10 -0
  71. package/dist/index.d.ts +3 -2
  72. package/dist/index.js +2 -2
  73. package/dist/style/base.css +2 -3
  74. package/dist/types/feedback.d.ts +1 -0
  75. package/package.json +2 -2
  76. package/dist/components/CustomSelect/CustomSelect.stories.d.ts +0 -73
  77. package/dist/components/CustomSelect/CustomSelect.stories.js +0 -477
  78. package/dist/components/CustomSelect/CustomSelectList/index.d.ts +0 -10
  79. package/dist/components/CustomSelect/CustomSelectList/index.js +0 -66
  80. package/dist/components/CustomSelect/index.d.ts +0 -30
  81. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -61
  82. package/dist/components/MultiSelect/MultiSelect.stories.js +0 -336
  83. /package/dist/components/MultiSelect/{calcTextSize.d.ts → helpers/calcTextSize.d.ts} +0 -0
  84. /package/dist/components/MultiSelect/{calcTextSize.js → helpers/calcTextSize.js} +0 -0
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import EmptyState from "./components/EmptyState/index.js";
10
10
  import Tooltips from "./components/Tooltips/index.js";
11
11
  import Collapse from "./components/Collapse/index.js";
12
12
  import UserMenu from "./components/UserMenu/index.js";
13
- import CustomSelect from "./components/CustomSelect/index.js";
13
+ import Select from "./components/Select/index.js";
14
14
  import StateAlert from "./components/StateAlert/index.js";
15
15
  import MultiSelect from "./components/MultiSelect/index.js";
16
16
  import DoubleList from "./components/DoubleList/index.js";
@@ -18,4 +18,4 @@ import Menu from "./components/Menu/index.js";
18
18
  import { Input } from "./components/Input/index.js";
19
19
  export * from "./components/Grid/index.js";
20
20
  export * from "./components/Text/index.js";
21
- export { Avatar, Breadcrumb, Button, Checkbox, Collapse, CustomSelect, DoubleList, EmptyState, Input, Loading, Menu, MultiSelect, Radio, StateAlert, Switch, TextArea, Tooltips, UserMenu, useLoading };
21
+ export { Avatar, Breadcrumb, Button, Checkbox, Collapse, DoubleList, EmptyState, Input, Loading, Menu, MultiSelect, Radio, Select, StateAlert, Switch, TextArea, Tooltips, UserMenu, useLoading };
@@ -92,7 +92,7 @@ button, select {
92
92
  }
93
93
 
94
94
  button, input:where([type="button"]), input:where([type="reset"]), input:where([type="submit"]) {
95
- -webkit-appearance: button;
95
+ appearance: button;
96
96
  background-color: #0000;
97
97
  background-image: none;
98
98
  }
@@ -118,7 +118,7 @@ progress {
118
118
  }
119
119
 
120
120
  [type="search"] {
121
- -webkit-appearance: textfield;
121
+ appearance: textfield;
122
122
  outline-offset: -2px;
123
123
  }
124
124
 
@@ -186,7 +186,6 @@ button, [role="button"] {
186
186
  }
187
187
 
188
188
  img, svg, video, canvas, audio, iframe, embed, object {
189
- vertical-align: middle;
190
189
  display: block;
191
190
  }
192
191
 
@@ -1,3 +1,4 @@
1
1
  export type ColorFeedbackType = "success" | "warning" | "danger" | "info" | "neutral";
2
2
  export type StateFeedbackType = "loading" | "disabled" | "pending" | "success" | "error";
3
3
  export type FeedbackType = ColorFeedbackType | StateFeedbackType;
4
+ export type FieldFeedbackType = "danger" | "success" | "warning";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ftdata/ui",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "react-input-mask-next": "3.0.0-alpha.12",
32
32
  "react-select": "^5.10.2",
33
- "react-window": "^1.8.11",
33
+ "react-window": "^2.0.2",
34
34
  "@ftdata/f-icons": "0.0.2",
35
35
  "@ftdata/f-tokens": "0.0.1"
36
36
  },
@@ -1,73 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import CustomSelect from ".";
3
- /**
4
- * CustomSelect permite que os usuários selecionem uma opção em uma lista suspensa customizada.
5
- * O componente suporta exibição de mensagens de erro, sucesso e ajuda, além de possibilitar a customização do ícone e placeholder.
6
- */
7
- declare const meta: Meta<typeof CustomSelect>;
8
- export default meta;
9
- type Story = StoryObj<typeof meta>;
10
- /**
11
- * Variação padrão do CustomSelect com as propriedades obrigatórias.
12
- */
13
- export declare const Default: Story;
14
- /**
15
- * Variação interativa do CustomSelect.
16
- */
17
- export declare const InteractiveDemo: Story;
18
- /**
19
- * Variação padrão do CustomSelect com as opções de textos variados em tamanho.
20
- */
21
- export declare const DefaultWithBigTexts: Story;
22
- /**
23
- * Variação do CustomSelect pesquisável habilitando o onchange e a variation como "searchable".
24
- */
25
- export declare const Searchable: Story;
26
- /**
27
- * CustomSelect com texto de ajuda.
28
- */
29
- export declare const HelpText: Story;
30
- /**
31
- * CustomSelect com chips.
32
- */
33
- export declare const Chips: Story;
34
- /**
35
- * CustomSelect com Rótulo.
36
- */
37
- export declare const Label: Story;
38
- /**
39
- * CustomSelect em estado de erro, exibindo uma mensagem de validação.
40
- */
41
- export declare const Error: Story;
42
- /**
43
- * CustomSelect em estado de sucesso, exibindo uma mensagem de confirmação.
44
- */
45
- export declare const Success: Story;
46
- /**
47
- * CustomSelect desativado, onde não é possível selecionar opções.
48
- */
49
- export declare const Disabled: Story;
50
- /**
51
- * Variação do CustomSelect obrigatório.
52
- */
53
- export declare const Required: Story;
54
- /**
55
- * CustomSelect em estado de loading.
56
- */
57
- export declare const Loading: Story;
58
- /**
59
- * variação do CustomSelect quando nenhuma opção é encontrada.
60
- */
61
- export declare const Empty: Story;
62
- /**
63
- * Variação do input com readonly
64
- */
65
- export declare const Readonly: Story;
66
- /**
67
- * Variação do input com readonly
68
- */
69
- export declare const CustomAction: Story;
70
- /**
71
- * Variação do input com readonly
72
- */
73
- export declare const DemoCustomAction: Story;
@@ -1,477 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import index from "./index.js";
4
- import { Icon } from "@ftdata/f-icons";
5
- import { ChipExemple } from "./styles.js";
6
- import map_sample from "../../assets/img/map-sample.js";
7
- const meta = {
8
- title: "DESIGN COMPONENTS/CustomSelect",
9
- component: index,
10
- tags: [
11
- "autodocs"
12
- ],
13
- parameters: {
14
- layout: "centered"
15
- },
16
- decorators: [
17
- (Story)=>/*#__PURE__*/ jsx("div", {
18
- style: {
19
- width: "600px",
20
- height: "350px",
21
- display: "flex",
22
- justifyContent: "center"
23
- },
24
- children: /*#__PURE__*/ jsx(Story, {})
25
- })
26
- ],
27
- argTypes: {
28
- t: {
29
- description: "Fun\xe7\xe3o de tradu\xe7\xe3o do i18n."
30
- },
31
- helpText: {
32
- description: "Texto de ajuda exibido abaixo do CustomSelect."
33
- },
34
- isError: {
35
- description: "Define se o conte\xfado do CustomSelect possui um erro de valida\xe7\xe3o."
36
- },
37
- isSuccess: {
38
- description: "Define se o conte\xfado do CustomSelect est\xe1 em estado de sucesso."
39
- },
40
- label: {
41
- description: "R\xf3tulo exibido acima do CustomSelect."
42
- },
43
- isRequired: {
44
- description: "Define se o CustomSelect \xe9 obrigat\xf3rio."
45
- },
46
- name: {
47
- description: "Nome do campo input para formul\xe1rios."
48
- },
49
- options: {
50
- description: "Define as op\xe7\xf5es dispon\xedveis no CustomSelect.",
51
- table: {
52
- type: {
53
- summary: "Array<{ label: string, value: string, chip?: JSX.Element }>"
54
- }
55
- }
56
- },
57
- placeholder: {
58
- description: "Texto de placeholder exibido no campo input."
59
- },
60
- icon: {
61
- description: "\xcdcone exibido ao lado do campo de sele\xe7\xe3o.",
62
- options: [
63
- "none",
64
- "icon"
65
- ],
66
- mapping: {
67
- none: null,
68
- icon: /*#__PURE__*/ jsx(Icon, {
69
- name: "bld hotel-building",
70
- color: "#8E969B"
71
- })
72
- }
73
- },
74
- isLoading: {
75
- description: "Define se o CustomSelect est\xe1 em estado de carregamento."
76
- },
77
- onChange: {
78
- description: "Fun\xe7\xe3o chamada quando o valor do campo muda."
79
- },
80
- readOnly: {
81
- description: "Define se o input pode fazer pesquisa ou apenas selecionar op\xe7\xf5es"
82
- },
83
- variation: {
84
- description: "Define a varia\xe7\xe3o do select se \xe9 pesquisavel ou \xe9 padr\xe3o. por\xe9m para a pesquisa \xe9 necess\xe1rio um onChange",
85
- table: {
86
- type: {
87
- summary: '"searchable" | "default"'
88
- }
89
- }
90
- }
91
- }
92
- };
93
- const CustomSelect_stories = meta;
94
- const options = [
95
- {
96
- value: "1",
97
- label: "Op\xe7\xe3o 1"
98
- },
99
- {
100
- value: "2",
101
- label: "Op\xe7\xe3o 2"
102
- },
103
- {
104
- value: "3",
105
- label: "Op\xe7\xe3o 3"
106
- },
107
- {
108
- value: "4",
109
- label: "Op\xe7\xe3o 4"
110
- }
111
- ];
112
- const biggerOptions = [
113
- {
114
- value: "1",
115
- label: "Op\xe7\xe3o 1: Sele\xe7\xe3o padr\xe3o"
116
- },
117
- {
118
- value: "2",
119
- label: "Op\xe7\xe3o 2: Detalhes adicionais sobre esta op\xe7\xe3o"
120
- },
121
- {
122
- value: "3",
123
- label: "Op\xe7\xe3o 3: Texto m\xe9dio"
124
- },
125
- {
126
- value: "4",
127
- label: "Op\xe7\xe3o 4: Informa\xe7\xf5es extensas e abrangentes para testes"
128
- },
129
- {
130
- value: "5",
131
- label: "Op\xe7\xe3o 5: Simples"
132
- },
133
- {
134
- value: "6",
135
- label: "Op\xe7\xe3o 6: Uma descri\xe7\xe3o bem longa que pode testar a largura do componente"
136
- },
137
- {
138
- value: "7",
139
- label: "Op\xe7\xe3o 7: Informa\xe7\xe3o \xfatil"
140
- },
141
- {
142
- value: "8",
143
- label: "Op\xe7\xe3o 8: Exemplo"
144
- },
145
- {
146
- value: "9",
147
- label: "Op\xe7\xe3o 9: Outro exemplo que \xe9 um pouco mais longo do que o normal"
148
- },
149
- {
150
- value: "10",
151
- label: "Op\xe7\xe3o 10: Mais informa\xe7\xf5es sobre o que fazer"
152
- }
153
- ];
154
- const withChips = [
155
- {
156
- value: "1",
157
- label: "Op\xe7\xe3o 1: Sele\xe7\xe3o padr\xe3o",
158
- chip: /*#__PURE__*/ jsx(ChipExemple, {
159
- children: "demo"
160
- })
161
- },
162
- {
163
- value: "2",
164
- label: "Op\xe7\xe3o 2: Detalhes adicionais sobre esta op\xe7\xe3o",
165
- chip: /*#__PURE__*/ jsx(ChipExemple, {
166
- children: "demo"
167
- })
168
- },
169
- {
170
- value: "3",
171
- label: "Op\xe7\xe3o 3: Texto m\xe9dio",
172
- chip: /*#__PURE__*/ jsx(ChipExemple, {
173
- children: "demo"
174
- })
175
- },
176
- {
177
- value: "4",
178
- label: "Op\xe7\xe3o 4: Informa\xe7\xf5es extensas e abrangentes para testes",
179
- chip: /*#__PURE__*/ jsx(ChipExemple, {
180
- children: "demo"
181
- })
182
- },
183
- {
184
- value: "5",
185
- label: "Op\xe7\xe3o 5: Simples",
186
- chip: /*#__PURE__*/ jsx(ChipExemple, {
187
- children: "demo"
188
- })
189
- },
190
- {
191
- value: "6",
192
- label: "Op\xe7\xe3o 6: Uma descri\xe7\xe3o bem longa que pode testar a largura do componente",
193
- chip: /*#__PURE__*/ jsx(ChipExemple, {
194
- children: "demo"
195
- })
196
- },
197
- {
198
- value: "7",
199
- label: "Op\xe7\xe3o 7: Informa\xe7\xe3o \xfatil",
200
- chip: /*#__PURE__*/ jsx(ChipExemple, {
201
- children: "demo"
202
- })
203
- },
204
- {
205
- value: "8",
206
- label: "Op\xe7\xe3o 8: Exemplo",
207
- chip: /*#__PURE__*/ jsx(ChipExemple, {
208
- children: "demo"
209
- })
210
- },
211
- {
212
- value: "9",
213
- label: "Op\xe7\xe3o 9: Outro exemplo que \xe9 um pouco mais longo do que o normal",
214
- chip: /*#__PURE__*/ jsx(ChipExemple, {
215
- children: "demo"
216
- })
217
- }
218
- ];
219
- const enterprises = [
220
- {
221
- value: "1",
222
- label: "TechNova Ltda"
223
- },
224
- {
225
- value: "2",
226
- label: "GreenFuture Inc."
227
- },
228
- {
229
- value: "3",
230
- label: "Skyline Solutions"
231
- },
232
- {
233
- value: "4",
234
- label: "Oceanic Ventures"
235
- },
236
- {
237
- value: "5",
238
- label: "BrightWorks Co."
239
- },
240
- {
241
- value: "6",
242
- label: "UrbanCore Group"
243
- }
244
- ];
245
- const mockTranslate = (key)=>"not_found_any_data" === key ? "Nenhum dado encontrado" : key;
246
- const Default = {
247
- args: {
248
- placeholder: "Selecione ...",
249
- options: options,
250
- t: mockTranslate
251
- }
252
- };
253
- const InteractiveDemo = {
254
- render: ()=>{
255
- const [selected, setSelected] = useState(null);
256
- return /*#__PURE__*/ jsx("div", {
257
- style: {
258
- display: "flex",
259
- gap: "2rem"
260
- },
261
- children: /*#__PURE__*/ jsx("div", {
262
- style: {
263
- width: "284px"
264
- },
265
- children: /*#__PURE__*/ jsx(index, {
266
- selected: selected,
267
- setSelected: setSelected,
268
- placeholder: "Selecione ...",
269
- options: enterprises,
270
- t: mockTranslate,
271
- label: `op\xe7\xe3o selecionada: ${selected?.label}`,
272
- variation: "searchable"
273
- })
274
- })
275
- });
276
- }
277
- };
278
- const DefaultWithBigTexts = {
279
- args: {
280
- placeholder: "Selecione ...",
281
- options: biggerOptions,
282
- t: mockTranslate
283
- }
284
- };
285
- const Searchable = {
286
- render: ()=>{
287
- const [selected, setSelected] = useState(null);
288
- const [searchValue, setSearchValue] = useState("");
289
- const handleSearch = (query)=>{
290
- setSearchValue(query);
291
- };
292
- return /*#__PURE__*/ jsxs("div", {
293
- style: {
294
- display: "flex",
295
- gap: "2rem"
296
- },
297
- children: [
298
- /*#__PURE__*/ jsx("div", {
299
- style: {
300
- width: "284px"
301
- },
302
- children: /*#__PURE__*/ jsx(index, {
303
- selected: selected,
304
- setSelected: setSelected,
305
- placeholder: "Selecione ...",
306
- options: enterprises,
307
- t: mockTranslate,
308
- search: handleSearch,
309
- label: `op\xe7\xe3o selecionada: ${selected?.label}`,
310
- variation: "searchable"
311
- })
312
- }),
313
- /*#__PURE__*/ jsx("div", {
314
- style: {
315
- width: "284px"
316
- },
317
- children: /*#__PURE__*/ jsxs("span", {
318
- style: {
319
- fontFamily: "Inter",
320
- fontSize: "0.875rem",
321
- fontWeight: "500"
322
- },
323
- children: [
324
- "resultado pesquisa customizada: ",
325
- searchValue
326
- ]
327
- })
328
- })
329
- ]
330
- });
331
- }
332
- };
333
- const HelpText = {
334
- args: {
335
- placeholder: "Selecione ...",
336
- options: options,
337
- t: mockTranslate,
338
- helpText: "texto de ajuda"
339
- }
340
- };
341
- const Chips = {
342
- args: {
343
- placeholder: "Selecione ...",
344
- options: withChips,
345
- t: mockTranslate
346
- }
347
- };
348
- const Label = {
349
- args: {
350
- placeholder: "Selecione ...",
351
- options: options,
352
- t: mockTranslate,
353
- label: "Label do CustomSelect"
354
- }
355
- };
356
- const Error = {
357
- args: {
358
- placeholder: "Selecione ...",
359
- options: options,
360
- isError: true,
361
- t: mockTranslate,
362
- helpText: "Erro ao selecionar a op\xe7\xe3o."
363
- }
364
- };
365
- const Success = {
366
- args: {
367
- placeholder: "Selecione ...",
368
- options: options,
369
- isSuccess: true,
370
- t: mockTranslate,
371
- helpText: "Mensagem de Sucesso."
372
- }
373
- };
374
- const Disabled = {
375
- args: {
376
- placeholder: "Selecione ...",
377
- options: options,
378
- disabled: true,
379
- t: mockTranslate
380
- }
381
- };
382
- const Required = {
383
- args: {
384
- placeholder: "Selecione ...",
385
- options: options,
386
- isRequired: true,
387
- label: "Campo Obrigat\xf3rio",
388
- t: mockTranslate
389
- }
390
- };
391
- const Loading = {
392
- args: {
393
- placeholder: "Selecione ...",
394
- options: options,
395
- t: mockTranslate,
396
- isLoading: true
397
- }
398
- };
399
- const Empty = {
400
- args: {
401
- placeholder: "Selecione ...",
402
- options: [],
403
- t: mockTranslate
404
- }
405
- };
406
- const Readonly = {
407
- args: {
408
- placeholder: "Selecione ...",
409
- options: biggerOptions,
410
- t: mockTranslate,
411
- readOnly: true
412
- }
413
- };
414
- const CustomAction = {
415
- args: {
416
- placeholder: "Selecione ...",
417
- options: [
418
- {
419
- value: "__custom_action",
420
- label: "Clique Aqui",
421
- action: ()=>console.log("clicou")
422
- },
423
- ...options
424
- ],
425
- t: mockTranslate
426
- }
427
- };
428
- const DemoCustomAction = {
429
- render: ()=>{
430
- const [showImage, setShowImage] = useState(false);
431
- const [selected, setSelected] = useState(null);
432
- const customAction = ()=>setShowImage((prev)=>!prev);
433
- return /*#__PURE__*/ jsxs("div", {
434
- style: {
435
- display: "flex",
436
- gap: "2rem"
437
- },
438
- children: [
439
- /*#__PURE__*/ jsx("div", {
440
- style: {
441
- width: "284px"
442
- },
443
- children: /*#__PURE__*/ jsx(index, {
444
- selected: selected,
445
- setSelected: setSelected,
446
- placeholder: "Selecione ...",
447
- options: [
448
- {
449
- value: "__custom_action",
450
- label: "Toggle Mapa",
451
- action: ()=>customAction()
452
- },
453
- ...options
454
- ],
455
- t: mockTranslate,
456
- label: `Demonstra\xe7\xe3o de a\xe7\xe3o customizada`
457
- })
458
- }),
459
- /*#__PURE__*/ jsx("div", {
460
- style: {
461
- width: "284px"
462
- },
463
- children: showImage && /*#__PURE__*/ jsx("img", {
464
- src: map_sample,
465
- style: {
466
- width: "100%",
467
- height: "100%",
468
- objectFit: "cover",
469
- borderRadius: "0.5rem"
470
- }
471
- })
472
- })
473
- ]
474
- });
475
- }
476
- };
477
- export { Chips, CustomAction, Default, DefaultWithBigTexts, DemoCustomAction, Disabled, Empty, Error, HelpText, InteractiveDemo, Label, Loading, Readonly, Required, Searchable, Success, CustomSelect_stories as default };
@@ -1,10 +0,0 @@
1
- import { ICustomSelectOption } from "..";
2
- interface CustomSelectListProps {
3
- onClickOption?: (event: React.MouseEvent<HTMLDivElement>, option: ICustomSelectOption) => void;
4
- options: ICustomSelectOption[];
5
- selectedOption?: ICustomSelectOption | null;
6
- isLoading?: boolean;
7
- handleCustomAction: (action: () => void) => void;
8
- }
9
- declare const CustomSelectList: React.FC<CustomSelectListProps>;
10
- export default CustomSelectList;
@@ -1,66 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { FixedSizeList } from "react-window";
3
- import { LoadingContainer, OptionContainer, SelectDropdown } from "./style.js";
4
- import Loading from "../../Loading/Loading/index.js";
5
- import { TooltipWrapper } from "../../TooltipWrapper/index.js";
6
- const renderRow = ({ data, index, style, onClickOption, selectedOption, showTooltip, hideTooltip, handleCustomAction })=>{
7
- const option = data[index];
8
- const isSelected = selectedOption ? option.value === selectedOption.value : false;
9
- const handleShowTooltip = (event)=>{
10
- const target = event.currentTarget.querySelector("span");
11
- if (target && target.scrollWidth > target.clientWidth) return void showTooltip(event, option.label);
12
- };
13
- const handleClick = (event)=>{
14
- if (option.action) return void handleCustomAction(option.action);
15
- if (onClickOption) onClickOption(event, option);
16
- };
17
- return /*#__PURE__*/ jsxs(OptionContainer, {
18
- style: style,
19
- isSelected: isSelected,
20
- onMouseEnter: handleShowTooltip,
21
- onMouseLeave: hideTooltip,
22
- onClick: handleClick,
23
- className: option.action ? "action" : "",
24
- children: [
25
- /*#__PURE__*/ jsx("span", {
26
- children: option.label
27
- }),
28
- option.chip || null
29
- ]
30
- });
31
- };
32
- const CustomSelectList = ({ options, onClickOption, selectedOption, isLoading, handleCustomAction })=>{
33
- const OPTION_SIZE = 36;
34
- const optionLength = options.length;
35
- const height = OPTION_SIZE * (0 === optionLength ? 1 : optionLength >= 7 ? 7 : optionLength);
36
- return /*#__PURE__*/ jsx(SelectDropdown, {
37
- children: isLoading ? /*#__PURE__*/ jsx(LoadingContainer, {
38
- children: /*#__PURE__*/ jsx(Loading, {
39
- size: "lg",
40
- variant: "light"
41
- })
42
- }) : /*#__PURE__*/ jsx(TooltipWrapper, {
43
- spacing: 18,
44
- children: ({ showTooltip, hideTooltip })=>/*#__PURE__*/ jsx(FixedSizeList, {
45
- itemCount: options.length,
46
- itemData: options,
47
- itemSize: 36,
48
- height: height,
49
- width: "100%",
50
- itemKey: (index)=>options[index].value || index,
51
- children: ({ index, style, data })=>renderRow({
52
- data,
53
- index,
54
- style,
55
- onClickOption,
56
- selectedOption,
57
- showTooltip,
58
- hideTooltip,
59
- handleCustomAction
60
- })
61
- })
62
- })
63
- });
64
- };
65
- const CustomSelect_CustomSelectList = CustomSelectList;
66
- export { CustomSelect_CustomSelectList as default };