design-system-silkhaus 3.14.0 → 3.16.0-beta.dropdown-select-all.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.
@@ -1,6 +1,7 @@
1
1
  import { default as default_2 } from 'react';
2
2
  import { FC } from 'react';
3
3
  import { HTMLAttributes } from 'react';
4
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
4
5
  import { Placement } from '@floating-ui/react';
5
6
  import { PropsWithChildren } from 'react';
6
7
  import { ReactNode } from 'react';
@@ -78,6 +79,23 @@ export declare type DropdownOption = {
78
79
  disabled?: boolean;
79
80
  };
80
81
 
82
+ export declare const DropdownOption: ({ onClick, option, isSelected, showCheckbox, }: {
83
+ onClick: () => void;
84
+ option: DropdownOption;
85
+ isSelected: boolean;
86
+ showCheckbox?: boolean;
87
+ }) => JSX_2.Element;
88
+
89
+ export declare const DropdownOptions: ({ options, isMultiSelect, value, setValue, setIsOpen, onChange, selectAllOptionLabel, }: {
90
+ options: DropdownOption[];
91
+ isMultiSelect?: boolean;
92
+ value: DropdownProps["value"];
93
+ setValue: (value: DropdownProps["value"]) => void;
94
+ setIsOpen: (isOpen: boolean) => void;
95
+ onChange?: DropdownProps["onChange"];
96
+ selectAllOptionLabel?: string;
97
+ }) => JSX_2.Element;
98
+
81
99
  export declare interface DropdownProps {
82
100
  /**
83
101
  * The options of the dropdown
@@ -94,7 +112,7 @@ export declare interface DropdownProps {
94
112
  /**
95
113
  * Callback when dropdown value is changed
96
114
  */
97
- onChange?: (selectedOption: DropdownOption | DropdownOption[]) => void;
115
+ onChange?: (selectedOption: DropdownOption | DropdownOption[], isSelectAll?: boolean) => void;
98
116
  /**
99
117
  * Pass this callback function if you want to override the default selected value display text.
100
118
  * By default the dropdown will display the label from the selected option
@@ -142,10 +160,23 @@ export declare interface DropdownProps {
142
160
  * @default 'Close'
143
161
  */
144
162
  closeButtonLabel?: string;
163
+ /**
164
+ * Pass true to disable the select all option in multi-select dropdown
165
+ * @default false
166
+ */
167
+ disableSelectAll?: boolean;
168
+ /**
169
+ * The label for Select all option
170
+ * @default 'Select all'
171
+ */
172
+ selectAllOptionLabel?: string;
173
+ /**
174
+ * The selected value label to show when 'Select All' option is checked
175
+ * @default 'All'
176
+ */
177
+ allSelectedLabel?: string;
145
178
  }
146
179
 
147
- export declare const findOptionByValue: (value: string | string[] | undefined, options: DropdownOption[]) => DropdownOption | DropdownOption[] | undefined;
148
-
149
180
  export declare const MobileDropdown: FC<PropsWithChildren<DropdownProps>>;
150
181
 
151
182
  declare type OptionType = {
package/dist/app/index.js CHANGED
@@ -1,9 +1,10 @@
1
- import { B as s, a as t, b as n, D as p, M as r, f as e } from "../index-DNx3uJWq.js";
1
+ import { B as s, a as n, b as r, D as t, d as a, c as D, M as d } from "../index-CZFridxv.js";
2
2
  export {
3
3
  s as Button,
4
- t as ButtonsGroupSelector,
5
- n as DesktopDropdown,
6
- p as Dropdown,
7
- r as MobileDropdown,
8
- e as findOptionByValue
4
+ n as ButtonsGroupSelector,
5
+ r as DesktopDropdown,
6
+ t as Dropdown,
7
+ a as DropdownOption,
8
+ D as DropdownOptions,
9
+ d as MobileDropdown
9
10
  };
@@ -0,0 +1,79 @@
1
+ export default {
2
+ meta: {
3
+ type: 'problem',
4
+ docs: {
5
+ description: 'Restrict listed names in tailwind tokens',
6
+ recommended: false,
7
+ },
8
+ messages: {
9
+ disallowedToken:
10
+ "Do not use '{{ token }}' in token names. Use a semantic design token name instead.",
11
+ },
12
+ schema: [],
13
+ },
14
+
15
+ create(context) {
16
+ const RESTRICTED_TOKENS = [
17
+ 'white',
18
+ 'black',
19
+ 'red',
20
+ 'green',
21
+ 'grey',
22
+ 'gray',
23
+ 'eggplant',
24
+ 'carrot',
25
+ 'teal',
26
+ 'mustard',
27
+ ];
28
+
29
+ const regex = new RegExp(`\\b(${RESTRICTED_TOKENS.join('|')})\\b`, 'i');
30
+
31
+ function reportIfTokenUsed(node, value) {
32
+ const match = regex.exec(value);
33
+ if (match) {
34
+ context.report({
35
+ node,
36
+ messageId: 'disallowedToken',
37
+ data: {
38
+ token: match[1],
39
+ },
40
+ });
41
+ }
42
+ }
43
+
44
+ return {
45
+ Literal(node) {
46
+ if (typeof node.value === 'string') {
47
+ reportIfTokenUsed(node, node.value);
48
+ }
49
+ },
50
+ JSXAttribute(node) {
51
+ if (
52
+ node.name &&
53
+ ['class', 'className', 'style'].includes(node.name.name) &&
54
+ node.value &&
55
+ node.value.type === 'Literal' &&
56
+ typeof node.value.value === 'string'
57
+ ) {
58
+ reportIfTokenUsed(node.value, node.value.value);
59
+ }
60
+
61
+ // Also handle JSXExpressionContainer e.g. className={"my-class red-text"}
62
+ if (
63
+ node.value &&
64
+ node.value.type === 'JSXExpressionContainer' &&
65
+ node.value.expression &&
66
+ node.value.expression.type === 'Literal' &&
67
+ typeof node.value.expression.value === 'string'
68
+ ) {
69
+ reportIfTokenUsed(node.value.expression, node.value.expression.value);
70
+ }
71
+ },
72
+ TemplateLiteral(node) {
73
+ node.quasis.forEach((quasi) => {
74
+ reportIfTokenUsed(quasi, quasi.value.cooked || '');
75
+ });
76
+ },
77
+ };
78
+ },
79
+ };