reactive-bulma 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/dist/cjs/index.js +71 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/atoms/DropdownItem/index.d.ts +4 -0
- package/dist/cjs/types/components/atoms/DropdownTrigger/index.d.ts +4 -0
- package/dist/cjs/types/components/atoms/index.d.ts +2 -0
- package/dist/cjs/types/components/molecules/Dropdown/index.d.ts +4 -0
- package/dist/cjs/types/components/molecules/index.d.ts +1 -0
- package/dist/cjs/types/interfaces/atomProps.d.ts +21 -17
- package/dist/cjs/types/interfaces/commonProps.d.ts +4 -0
- package/dist/cjs/types/interfaces/moleculeProps.d.ts +9 -1
- package/dist/cjs/types/types/domTypes.d.ts +1 -0
- package/dist/esm/index.js +69 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/atoms/DropdownItem/index.d.ts +4 -0
- package/dist/esm/types/components/atoms/DropdownTrigger/index.d.ts +4 -0
- package/dist/esm/types/components/atoms/index.d.ts +2 -0
- package/dist/esm/types/components/molecules/Dropdown/index.d.ts +4 -0
- package/dist/esm/types/components/molecules/index.d.ts +1 -0
- package/dist/esm/types/interfaces/atomProps.d.ts +21 -17
- package/dist/esm/types/interfaces/commonProps.d.ts +4 -0
- package/dist/esm/types/interfaces/moleculeProps.d.ts +9 -1
- package/dist/esm/types/types/domTypes.d.ts +1 -0
- package/dist/index.d.ts +39 -16
- package/package.json +17 -16
@@ -14,3 +14,5 @@ export { default as File } from './File';
|
|
14
14
|
export { default as Checkbox } from './Checkbox';
|
15
15
|
export { default as RadioButton } from './RadioButton';
|
16
16
|
export { default as BreadcrumbItem } from './BreadcrumbItem';
|
17
|
+
export { default as DropdownTrigger } from './DropdownTrigger';
|
18
|
+
export { default as DropdownItem } from './DropdownItem';
|
@@ -2,3 +2,4 @@ export { default as ButtonGroup } from './ButtonGroup';
|
|
2
2
|
export { default as ColumnGroup } from './ColumnGroup';
|
3
3
|
export { default as Notification } from './Notification';
|
4
4
|
export { default as Breadcrumbs } from './Breadcrumbs';
|
5
|
+
export { default as Dropdown } from './Dropdown';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { ElementProps, ComposedElementProps } from './commonProps';
|
2
|
+
import { ElementProps, ComposedElementProps, ClickeableProps } from './commonProps';
|
3
3
|
import { basicColorType, columnOffsetType, columnSizeType, fixedImageSizeType, iconColorModeType, basicSizeType, textColorType, titleSizeType } from '../types/styleTypes';
|
4
|
-
import { inputTypes } from '../types/domTypes';
|
4
|
+
import { DropdownItemType, inputTypes } from '../types/domTypes';
|
5
5
|
export interface ColumnProps extends ElementProps, React.ComponentPropsWithoutRef<'section'> {
|
6
6
|
/** `Attribute` Reffers to the component or array of components that will be shown inside the column */
|
7
7
|
children?: string | React.ReactElement | React.ReactElement[];
|
@@ -118,7 +118,7 @@ export interface IconProps extends ComposedElementProps {
|
|
118
118
|
/** `Styling` Animates the icon spinning 360° */
|
119
119
|
isSpinning?: boolean;
|
120
120
|
}
|
121
|
-
export interface InputProps extends ElementProps {
|
121
|
+
export interface InputProps extends ElementProps, ClickeableProps {
|
122
122
|
/** `Attribute` `Required` What type of input will be used */
|
123
123
|
type: inputTypes;
|
124
124
|
/** `Attribute` The value that will be shown on the input */
|
@@ -137,8 +137,6 @@ export interface InputProps extends ElementProps {
|
|
137
137
|
isHovered?: boolean;
|
138
138
|
/** `Styling` Will add a specific border when the input is focused by the user */
|
139
139
|
isFocused?: boolean;
|
140
|
-
/** `Function` Click function. Alone does not nothing, but can be reused for other components */
|
141
|
-
onClick?: () => void;
|
142
140
|
/** `Function` Reffers to each time the user press a key. Alone does not nothing, but can be reused for other components */
|
143
141
|
onChange?: () => void;
|
144
142
|
}
|
@@ -150,18 +148,16 @@ export interface TextAreaProps extends Omit<InputProps, 'isRounded' | 'type'> {
|
|
150
148
|
/** `Styling` Will disable characteristic sizable property by removing its control on bottom-right corner */
|
151
149
|
isFixedSize?: boolean;
|
152
150
|
}
|
153
|
-
export interface DeleteProps extends ElementProps {
|
151
|
+
export interface DeleteProps extends ElementProps, ClickeableProps {
|
154
152
|
/** `Styling` Set icons's size */
|
155
153
|
size?: Exclude<basicSizeType, 'is-normal'>;
|
156
|
-
/** `Function` Click function. Alone does not nothing, but can be reused for other components */
|
157
|
-
onClick?: () => void;
|
158
154
|
}
|
159
155
|
export interface SelectOption {
|
160
156
|
id: string | number;
|
161
157
|
name: string;
|
162
158
|
selected?: boolean;
|
163
159
|
}
|
164
|
-
export interface SelectProps extends ComposedElementProps {
|
160
|
+
export interface SelectProps extends ComposedElementProps, ClickeableProps {
|
165
161
|
/** `Attribute` Indicates the options contained on the select */
|
166
162
|
options?: SelectOption[];
|
167
163
|
/** `Attribute` Indicates how many options will be shown at first glance (before looking for the whole list */
|
@@ -178,10 +174,8 @@ export interface SelectProps extends ComposedElementProps {
|
|
178
174
|
isHovered?: boolean;
|
179
175
|
/** `Styling`Will add a specific border when the input is focused by the user */
|
180
176
|
isFocused?: boolean;
|
181
|
-
/** `Function` Click function. Alone does not nothing, but can be reused for other components */
|
182
|
-
onClick?: () => void;
|
183
177
|
}
|
184
|
-
export interface FileProps extends ComposedElementProps {
|
178
|
+
export interface FileProps extends ComposedElementProps, ClickeableProps {
|
185
179
|
/** `Attribute` The name of the file to be uploaded */
|
186
180
|
fileName?: string;
|
187
181
|
/** `Attribute` The icon displayed in file's button" */
|
@@ -198,8 +192,6 @@ export interface FileProps extends ComposedElementProps {
|
|
198
192
|
color?: basicColorType;
|
199
193
|
/** `Styling` Set button's size */
|
200
194
|
size?: basicSizeType;
|
201
|
-
/** `Function` Click function, alone does not nothing, but can be reused for other components */
|
202
|
-
onClick?: () => void;
|
203
195
|
}
|
204
196
|
export interface CheckBoxProps extends ComposedElementProps {
|
205
197
|
/** `Attribute` Sets checkbox's text that will be shown next to its control */
|
@@ -229,11 +221,23 @@ export interface RadioButtonProps extends ComposedElementProps {
|
|
229
221
|
/** `Function` Click function, alone does not nothing, but can be reused for other components */
|
230
222
|
onChange?: () => void;
|
231
223
|
}
|
232
|
-
export interface BreadcrumbItemProps extends ComposedElementProps {
|
224
|
+
export interface BreadcrumbItemProps extends ComposedElementProps, ClickeableProps {
|
233
225
|
/** `Attribute` `Required` Indicates item text that will be shown */
|
234
226
|
text: string;
|
235
227
|
/** `Styling` Marks the item as the one where user is located (based on breadcrumb hierarchy) */
|
236
228
|
isActiveItem?: boolean;
|
237
|
-
|
238
|
-
|
229
|
+
}
|
230
|
+
export interface DropdownTriggerProps extends ComposedElementProps, ClickeableProps {
|
231
|
+
/** `Attribute` `Required` Sets the name will be shown on the dropdown input */
|
232
|
+
menuText: string;
|
233
|
+
/** `Attribute` Sets a relationship between trigger's button and dropdown's menu to toggle display */
|
234
|
+
dropdownPointer?: string;
|
235
|
+
}
|
236
|
+
export interface DropdownItemProps extends ElementProps, ClickeableProps {
|
237
|
+
/** `Attribute` `Required` Sets the name will be shown on the item */
|
238
|
+
itemText: string;
|
239
|
+
/** `Attribute` Changes item's composition into a `<hr>`, a `<a>` or a `<div>` depending its type */
|
240
|
+
type?: DropdownItemType;
|
241
|
+
/** `Styling` Marks the item as the one where user is located (based on dropdown hierarchy) */
|
242
|
+
isActiveItem?: boolean;
|
239
243
|
}
|
@@ -17,3 +17,7 @@ export interface ElementProps {
|
|
17
17
|
}
|
18
18
|
export interface ComposedElementProps extends ElementProps, ContainerProps {
|
19
19
|
}
|
20
|
+
export interface ClickeableProps {
|
21
|
+
/** `Function` Click function, alone does not nothing, but can be reused for other components */
|
22
|
+
onClick?: () => void;
|
23
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { ComposedElementProps, ElementProps } from './commonProps';
|
3
|
-
import { BreadcrumbItemProps, ButtonProps, ColumnProps, DeleteProps } from './atomProps';
|
3
|
+
import { BreadcrumbItemProps, ButtonProps, ColumnProps, DeleteProps, DropdownItemProps } from './atomProps';
|
4
4
|
import { basicColorType, basicSizeType, breadcrumbAlignType, breadcrumbSeparatorType, columnGapType } from '../types/styleTypes';
|
5
5
|
export interface ButtonGroupProps extends ElementProps {
|
6
6
|
/** `Atribute` `Required` Array of `Button` objects that will be shown */
|
@@ -44,3 +44,11 @@ export interface BreadcrumbsProps extends ComposedElementProps {
|
|
44
44
|
/** `Styling` Set button's size on bulma's size tokens */
|
45
45
|
size?: Exclude<basicSizeType, 'is-normal'>;
|
46
46
|
}
|
47
|
+
export interface DropdownProps extends ElementProps {
|
48
|
+
/** `Atribute` `Required` Sets the name will be shown on the dropdown input */
|
49
|
+
inputText: string;
|
50
|
+
/** `Attribute` Sets a relationship between dropdown trigger's button and dropdown's menu to toggle display */
|
51
|
+
dropdownPointer?: string;
|
52
|
+
/** `Atribute` `Required` Array of `DropdownItem` objects that will be shown on its menu */
|
53
|
+
listOfItems: DropdownItemProps[];
|
54
|
+
}
|
package/dist/esm/index.js
CHANGED
@@ -3187,6 +3187,53 @@ const BreadcrumbItem = ({ testId = null, containerTestId = null, cssClasses = nu
|
|
3187
3187
|
React.createElement("a", { "data-testid": breadcrumbItemTestId, className: breadcrumbItemClasses, style: style !== null && style !== void 0 ? style : undefined, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, text)));
|
3188
3188
|
};
|
3189
3189
|
|
3190
|
+
const DropdownTrigger = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, menuText, dropdownPointer = 'dropdown-menu', onClick = null }) => {
|
3191
|
+
const dropdownTriggerContainerClasses = parseClasses([
|
3192
|
+
'dropdown-trigger',
|
3193
|
+
containerCssClasses
|
3194
|
+
]);
|
3195
|
+
const dropdownTriggerContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
|
3196
|
+
tag: 'dropdown-trigger',
|
3197
|
+
parsedClasses: dropdownTriggerContainerClasses
|
3198
|
+
});
|
3199
|
+
const dropdownTriggerClasses = parseClasses(['button', cssClasses]);
|
3200
|
+
const dropdownTriggerTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'button', parsedClasses: dropdownTriggerClasses });
|
3201
|
+
return (React.createElement("section", { "data-testid": dropdownTriggerContainerTestId, className: dropdownTriggerContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
3202
|
+
React.createElement("button", { "data-testid": dropdownTriggerTestId, className: dropdownTriggerClasses, style: style !== null && style !== void 0 ? style : undefined, "aria-haspopup": 'true', "aria-controls": dropdownPointer, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined },
|
3203
|
+
React.createElement("span", null, menuText),
|
3204
|
+
React.createElement("span", { className: 'icon is-small' },
|
3205
|
+
React.createElement("i", { className: 'mdi mdi-chevron-down', "aria-hidden": 'true' })))));
|
3206
|
+
};
|
3207
|
+
|
3208
|
+
const DropdownItem = ({ testId = null, cssClasses = null, style = null, itemText, type = 'item', isActiveItem = false, onClick = null }) => {
|
3209
|
+
const isDivider = type === 'divider';
|
3210
|
+
const itemTypeClass = isDivider ? 'dropdown-divider' : 'dropdown-item';
|
3211
|
+
const dropdownItemClasses = parseClasses([
|
3212
|
+
itemTypeClass,
|
3213
|
+
isActiveItem && !isDivider ? 'is-active' : null,
|
3214
|
+
cssClasses
|
3215
|
+
]);
|
3216
|
+
const dropdownItemConfig = {
|
3217
|
+
'data-testid': testId !== null && testId !== void 0 ? testId : parseTestId({
|
3218
|
+
tag: itemTypeClass,
|
3219
|
+
parsedClasses: `${dropdownItemClasses}-${type}`
|
3220
|
+
}),
|
3221
|
+
'className': dropdownItemClasses,
|
3222
|
+
'style': style !== null && style !== void 0 ? style : undefined,
|
3223
|
+
'onClick': onClick !== null && onClick !== void 0 ? onClick : undefined
|
3224
|
+
};
|
3225
|
+
switch (type) {
|
3226
|
+
case 'item':
|
3227
|
+
return (React.createElement("div", Object.assign({}, dropdownItemConfig),
|
3228
|
+
React.createElement("p", null, itemText)));
|
3229
|
+
case 'divider':
|
3230
|
+
return React.createElement("hr", Object.assign({}, dropdownItemConfig));
|
3231
|
+
case 'link':
|
3232
|
+
default:
|
3233
|
+
return React.createElement("a", Object.assign({}, dropdownItemConfig), itemText);
|
3234
|
+
}
|
3235
|
+
};
|
3236
|
+
|
3190
3237
|
const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonList, isAttached = false, position = 'left' }) => {
|
3191
3238
|
const buttonGroupClasses = parseClasses([
|
3192
3239
|
'buttons',
|
@@ -3286,5 +3333,26 @@ const Breadcrumbs = ({ testId = 'breadcrumbs', containerTestId = null, cssClasse
|
|
3286
3333
|
React.createElement("ul", { "data-testid": testId, className: cssClasses !== null && cssClasses !== void 0 ? cssClasses : undefined, style: style !== null && style !== void 0 ? style : undefined }, items.map((itemConfig, i) => (React.createElement(BreadcrumbItem, Object.assign({ key: `breadcrumb-item-${i}` }, itemConfig)))))));
|
3287
3334
|
};
|
3288
3335
|
|
3289
|
-
|
3336
|
+
const renderDropdownMenu = (items) => (React.createElement("section", { className: 'dropdown-content' }, items.map((dropdownItemConfig, i) => {
|
3337
|
+
const isFirstItemInMenu = items.length > 1 && i === 0;
|
3338
|
+
return isFirstItemInMenu ? (React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${i}` }, dropdownItemConfig))) : (React.createElement(React.Fragment, null,
|
3339
|
+
React.createElement(DropdownItem, { key: `dropdown-item-${i}-divider`, type: 'divider', itemText: 'divider' }),
|
3340
|
+
React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${i}` }, dropdownItemConfig))));
|
3341
|
+
})));
|
3342
|
+
const Dropdown = ({ testId = null, cssClasses = null, style = null, inputText, dropdownPointer = 'dropdown-menu', listOfItems }) => {
|
3343
|
+
const [isMenuActive, setIsMenuActive] = reactExports.useState(false);
|
3344
|
+
const dropdownClasses = parseClasses([
|
3345
|
+
'dropdown',
|
3346
|
+
isMenuActive ? 'is-active' : null,
|
3347
|
+
cssClasses
|
3348
|
+
]);
|
3349
|
+
const dropdownTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'dropdown', parsedClasses: dropdownClasses });
|
3350
|
+
return (React.createElement("section", { "data-testid": dropdownTestId, className: dropdownClasses, style: style !== null && style !== void 0 ? style : undefined },
|
3351
|
+
React.createElement(DropdownTrigger, { menuText: inputText,
|
3352
|
+
dropdownPointer,
|
3353
|
+
onClick: () => setIsMenuActive(!isMenuActive) }),
|
3354
|
+
React.createElement("section", { className: 'dropdown-menu', id: dropdownPointer, role: 'menu' }, renderDropdownMenu(listOfItems))));
|
3355
|
+
};
|
3356
|
+
|
3357
|
+
export { Block, Box, BreadcrumbItem, Breadcrumbs, Button, ButtonGroup, CheckBox as Checkbox, Column, ColumnGroup, Delete, Dropdown, DropdownItem, DropdownTrigger, File, Icon, Input, Notification, ProgressBar, RadioButton, Select, Tag, TextArea, Title };
|
3290
3358
|
//# sourceMappingURL=index.js.map
|