@primer/components 0.0.0-2021111193153 → 0.0.0-202111121740
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.
- package/CHANGELOG.md +2 -12
- package/dist/browser.esm.js +605 -587
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +222 -204
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Divider.d.ts +2 -3
- package/lib/ActionList2/Divider.js +5 -10
- package/lib/ActionList2/Item.js +5 -21
- package/lib/ActionList2/List.js +1 -11
- package/lib/ActionList2/Selection.js +0 -11
- package/lib/ActionList2/index.d.ts +2 -1
- package/lib/Autocomplete/AutocompleteMenu.js +6 -13
- package/lib/Avatar.d.ts +2 -1
- package/lib/Avatar.js +1 -1
- package/lib/BranchName.d.ts +2 -1
- package/lib/BranchName.js +1 -1
- package/lib/Checkbox.d.ts +1 -1
- package/lib/CheckboxInputField.d.ts +11 -0
- package/lib/CheckboxInputField.js +73 -0
- package/lib/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
- package/lib/ChoiceFieldset/ChoiceFieldCaption.js +35 -0
- package/lib/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
- package/lib/ChoiceFieldset/ChoiceFieldLabel.js +35 -0
- package/lib/ChoiceFieldset/ChoiceFieldset.d.ts +63 -0
- package/lib/ChoiceFieldset/ChoiceFieldset.js +95 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetDescription.js +29 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetLegend.js +44 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetList.js +80 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +18 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetListContext.js +15 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetListItem.js +74 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
- package/lib/ChoiceFieldset/ChoiceFieldsetValidation.js +17 -0
- package/lib/ChoiceFieldset/index.d.ts +3 -0
- package/lib/ChoiceFieldset/index.js +23 -0
- package/lib/Details.d.ts +2 -1
- package/lib/Details.js +3 -1
- package/lib/Dropdown.d.ts +66 -2
- package/lib/Heading.d.ts +2 -1
- package/lib/Heading.js +6 -1
- package/lib/ProgressBar.d.ts +11 -16
- package/lib/ProgressBar.js +10 -6
- package/lib/RadioInputField.d.ts +9 -0
- package/lib/RadioInputField.js +82 -0
- package/lib/Spinner.d.ts +2 -1
- package/lib/Spinner.js +3 -1
- package/lib/TextInputField.d.ts +581 -0
- package/lib/TextInputField.js +66 -0
- package/lib/_InputCaption.d.ts +13 -0
- package/lib/_InputCaption.js +27 -0
- package/lib/_InputField/InputField.d.ts +39 -0
- package/lib/_InputField/InputField.js +90 -0
- package/lib/_InputField/InputFieldCaption.d.ts +3 -0
- package/lib/_InputField/InputFieldCaption.js +30 -0
- package/lib/_InputField/InputFieldLabel.d.ts +9 -0
- package/lib/_InputField/InputFieldLabel.js +34 -0
- package/lib/_InputField/InputFieldValidation.d.ts +6 -0
- package/lib/{ActionList2/MenuContext.js → _InputField/InputFieldValidation.js} +6 -4
- package/lib/_InputField/ToggleInputField.d.ts +13 -0
- package/lib/_InputField/ToggleInputField.js +71 -0
- package/lib/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
- package/lib/_InputField/ToggleInputLeadingVisual.js +22 -0
- package/lib/_InputField/ValidationAnimationContainer.d.ts +6 -0
- package/lib/_InputField/ValidationAnimationContainer.js +48 -0
- package/lib/_InputField/index.d.ts +1 -0
- package/lib/_InputField/index.js +15 -0
- package/lib/_InputField/slots.d.ts +13 -0
- package/lib/_InputField/slots.js +17 -0
- package/lib/_InputLabel.d.ts +8 -0
- package/lib/_InputLabel.js +44 -0
- package/lib/_InputValidation.d.ts +8 -0
- package/lib/_InputValidation.js +56 -0
- package/lib/_VisuallyHidden.d.ts +6 -0
- package/lib/_VisuallyHidden.js +39 -0
- package/lib/drafts.d.ts +0 -1
- package/lib/drafts.js +0 -13
- package/lib/index.d.ts +4 -0
- package/lib/index.js +38 -0
- package/lib/utils/types/FormValidationStatus.d.ts +1 -0
- package/lib/utils/types/FormValidationStatus.js +1 -0
- package/lib-esm/ActionList2/Divider.d.ts +2 -3
- package/lib-esm/ActionList2/Divider.js +5 -8
- package/lib-esm/ActionList2/Item.js +5 -19
- package/lib-esm/ActionList2/List.js +1 -9
- package/lib-esm/ActionList2/Selection.js +0 -9
- package/lib-esm/ActionList2/index.d.ts +2 -1
- package/lib-esm/Autocomplete/AutocompleteMenu.js +3 -13
- package/lib-esm/Avatar.d.ts +2 -1
- package/lib-esm/Avatar.js +2 -2
- package/lib-esm/BranchName.d.ts +2 -1
- package/lib-esm/BranchName.js +2 -2
- package/lib-esm/Checkbox.d.ts +1 -1
- package/lib-esm/CheckboxInputField.d.ts +11 -0
- package/lib-esm/CheckboxInputField.js +56 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.d.ts +3 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.js +20 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.d.ts +3 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.js +20 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldset.d.ts +63 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldset.js +72 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +3 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.js +17 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +6 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.js +31 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.d.ts +6 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.js +63 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +18 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.js +5 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +25 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.js +50 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +6 -0
- package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.js +7 -0
- package/lib-esm/ChoiceFieldset/index.d.ts +3 -0
- package/lib-esm/ChoiceFieldset/index.js +2 -0
- package/lib-esm/Details.d.ts +2 -1
- package/lib-esm/Details.js +2 -1
- package/lib-esm/Dropdown.d.ts +66 -2
- package/lib-esm/Heading.d.ts +2 -1
- package/lib-esm/Heading.js +6 -2
- package/lib-esm/ProgressBar.d.ts +11 -16
- package/lib-esm/ProgressBar.js +11 -7
- package/lib-esm/RadioInputField.d.ts +9 -0
- package/lib-esm/RadioInputField.js +65 -0
- package/lib-esm/Spinner.d.ts +2 -1
- package/lib-esm/Spinner.js +2 -1
- package/lib-esm/TextInputField.d.ts +581 -0
- package/lib-esm/TextInputField.js +50 -0
- package/lib-esm/_InputCaption.d.ts +13 -0
- package/lib-esm/_InputCaption.js +16 -0
- package/lib-esm/_InputField/InputField.d.ts +39 -0
- package/lib-esm/_InputField/InputField.js +70 -0
- package/lib-esm/_InputField/InputFieldCaption.d.ts +3 -0
- package/lib-esm/_InputField/InputFieldCaption.js +18 -0
- package/lib-esm/_InputField/InputFieldLabel.d.ts +9 -0
- package/lib-esm/_InputField/InputFieldLabel.js +22 -0
- package/lib-esm/_InputField/InputFieldValidation.d.ts +6 -0
- package/lib-esm/_InputField/InputFieldValidation.js +7 -0
- package/lib-esm/_InputField/ToggleInputField.d.ts +13 -0
- package/lib-esm/_InputField/ToggleInputField.js +54 -0
- package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +3 -0
- package/lib-esm/_InputField/ToggleInputLeadingVisual.js +11 -0
- package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +6 -0
- package/lib-esm/_InputField/ValidationAnimationContainer.js +33 -0
- package/lib-esm/_InputField/index.d.ts +1 -0
- package/lib-esm/_InputField/index.js +1 -0
- package/lib-esm/_InputField/slots.d.ts +13 -0
- package/lib-esm/_InputField/slots.js +5 -0
- package/lib-esm/_InputLabel.d.ts +8 -0
- package/lib-esm/_InputLabel.js +32 -0
- package/lib-esm/_InputValidation.d.ts +8 -0
- package/lib-esm/_InputValidation.js +43 -0
- package/lib-esm/_VisuallyHidden.d.ts +6 -0
- package/lib-esm/_VisuallyHidden.js +26 -0
- package/lib-esm/drafts.d.ts +0 -1
- package/lib-esm/drafts.js +1 -2
- package/lib-esm/index.d.ts +4 -0
- package/lib-esm/index.js +4 -0
- package/lib-esm/utils/types/FormValidationStatus.d.ts +1 -0
- package/lib-esm/utils/types/FormValidationStatus.js +1 -0
- package/package.json +2 -2
- package/lib/ActionList2/MenuContext.d.ts +0 -10
- package/lib/ActionMenu2.d.ts +0 -310
- package/lib/ActionMenu2.js +0 -91
- package/lib-esm/ActionList2/MenuContext.d.ts +0 -10
- package/lib-esm/ActionList2/MenuContext.js +0 -3
- package/lib-esm/ActionMenu2.d.ts +0 -310
- package/lib-esm/ActionMenu2.js +0 -67
@@ -0,0 +1,63 @@
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
2
|
+
import { FormValidationStatus } from '../utils/types/FormValidationStatus';
|
3
|
+
export interface ChoiceFieldsetProps<T = Record<string, FormValidationStatus>> {
|
4
|
+
children?: React.ReactNode;
|
5
|
+
/**
|
6
|
+
* Whether the fieldset is ready for user input
|
7
|
+
*/
|
8
|
+
disabled?: boolean;
|
9
|
+
/**
|
10
|
+
* The unique identifier for this fieldset. Used to associate the validation text and caption text with the fieldset
|
11
|
+
*/
|
12
|
+
id?: string;
|
13
|
+
/**
|
14
|
+
* The unique identifier used to associate the inputs with eachother
|
15
|
+
*/
|
16
|
+
name?: string;
|
17
|
+
/**
|
18
|
+
* The callback that is called when a user toggles a choice on or off
|
19
|
+
*/
|
20
|
+
onSelect?: (selectedValues?: string[]) => void;
|
21
|
+
/**
|
22
|
+
* The selected values
|
23
|
+
*/
|
24
|
+
selected?: string[];
|
25
|
+
/**
|
26
|
+
* Whether this field must have a value for the user to complete their task
|
27
|
+
*/
|
28
|
+
required?: boolean;
|
29
|
+
/**
|
30
|
+
* A map of validation statuses and their associated validation keys. When one of the validation keys is passed to the `validationResult` prop,
|
31
|
+
* the associated validation message will be rendered in the correct style
|
32
|
+
*/
|
33
|
+
validationMap?: T;
|
34
|
+
/**
|
35
|
+
* The key of the validation message to show
|
36
|
+
*/
|
37
|
+
validationResult?: keyof T;
|
38
|
+
}
|
39
|
+
export interface ChoiceFieldsetContext extends ChoiceFieldsetProps {
|
40
|
+
validationMessageId: string;
|
41
|
+
}
|
42
|
+
declare const Slot: React.FC<{
|
43
|
+
name: "Description" | "ChoiceList" | "Legend" | "Validation";
|
44
|
+
children: React.ReactNode;
|
45
|
+
}>;
|
46
|
+
export { Slot };
|
47
|
+
declare const ChoiceFieldset: <T extends Record<string, FormValidationStatus>>({ children, disabled, id, name, onSelect, required, selected, validationMap, validationResult }: ChoiceFieldsetProps<T>) => JSX.Element;
|
48
|
+
export declare type InputFieldComponentProps = ComponentProps<typeof ChoiceFieldset>;
|
49
|
+
export type { ChoiceFieldsetListProps } from './ChoiceFieldsetList';
|
50
|
+
export type { ChoiceFieldsetLegendProps } from './ChoiceFieldsetLegend';
|
51
|
+
export type { ChoiceFieldProps } from './ChoiceFieldsetListItem';
|
52
|
+
declare const _default: (<T extends Record<string, FormValidationStatus>>({ children, disabled, id, name, onSelect, required, selected, validationMap, validationResult }: ChoiceFieldsetProps<T>) => JSX.Element) & {
|
53
|
+
Description: React.FC<{}>;
|
54
|
+
Item: React.FC<import("./ChoiceFieldsetListItem").ChoiceFieldProps> & {
|
55
|
+
Caption: React.FC<{}>;
|
56
|
+
Label: React.FC<{}>;
|
57
|
+
LeadingVisual: React.FC<{}>;
|
58
|
+
};
|
59
|
+
Legend: React.FC<import("./ChoiceFieldsetLegend").ChoiceFieldsetLegendProps>;
|
60
|
+
List: React.FC<import("./ChoiceFieldsetList").ChoiceFieldsetListProps>;
|
61
|
+
Validation: React.FC<import("./ChoiceFieldsetValidation").ChoiceFieldsetValidationProps>;
|
62
|
+
};
|
63
|
+
export default _default;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Box } from '..';
|
3
|
+
import createSlots from '../utils/create-slots';
|
4
|
+
import { uniqueId } from '../utils/uniqueId';
|
5
|
+
import ValidationAnimationContainer from '../_InputField/ValidationAnimationContainer';
|
6
|
+
import InputValidation from '../_InputValidation';
|
7
|
+
import ChoiceFieldsetListItem from './ChoiceFieldsetListItem';
|
8
|
+
import ChoiceFieldsetDescription from './ChoiceFieldsetDescription';
|
9
|
+
import ChoiceFieldsetLegend from './ChoiceFieldsetLegend';
|
10
|
+
import ChoiceFieldsetList from './ChoiceFieldsetList';
|
11
|
+
import ChoiceFieldsetValidation from './ChoiceFieldsetValidation';
|
12
|
+
const {
|
13
|
+
Slots,
|
14
|
+
Slot
|
15
|
+
} = createSlots(['Description', 'ChoiceList', 'Legend', 'Validation']);
|
16
|
+
export { Slot };
|
17
|
+
|
18
|
+
const ChoiceFieldset = ({
|
19
|
+
children,
|
20
|
+
disabled,
|
21
|
+
id,
|
22
|
+
name,
|
23
|
+
onSelect,
|
24
|
+
required,
|
25
|
+
selected,
|
26
|
+
validationMap,
|
27
|
+
validationResult
|
28
|
+
}) => {
|
29
|
+
var _React$Children$map;
|
30
|
+
|
31
|
+
const fieldsetId = id || uniqueId();
|
32
|
+
const validationChildren = (_React$Children$map = React.Children.map(children, child => /*#__PURE__*/React.isValidElement(child) && child.type === ChoiceFieldsetValidation ? child : null)) === null || _React$Children$map === void 0 ? void 0 : _React$Children$map.filter(Boolean);
|
33
|
+
const validationChildToRender = validationChildren === null || validationChildren === void 0 ? void 0 : validationChildren.find(child => child.props.validationKey === validationResult);
|
34
|
+
const validationMessageId = validationChildToRender ? `${fieldsetId}-validationMsg` : undefined;
|
35
|
+
return /*#__PURE__*/React.createElement(Slots, {
|
36
|
+
context: {
|
37
|
+
disabled,
|
38
|
+
name,
|
39
|
+
onSelect,
|
40
|
+
required,
|
41
|
+
selected,
|
42
|
+
validationMessageId
|
43
|
+
}
|
44
|
+
}, slots => {
|
45
|
+
const isLegendVisible = /*#__PURE__*/React.isValidElement(slots.Legend) && slots.Legend.props.isVisible;
|
46
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Box, {
|
47
|
+
as: "fieldset",
|
48
|
+
border: "none",
|
49
|
+
margin: 0,
|
50
|
+
padding: 0,
|
51
|
+
"aria-describedby": [validationMessageId].filter(Boolean).join(' ')
|
52
|
+
}, React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type !== ChoiceFieldsetValidation), /*#__PURE__*/React.createElement(Box, {
|
53
|
+
mb: isLegendVisible ? 3 : undefined
|
54
|
+
}, slots.Legend, slots.Description), slots.ChoiceList), validationChildToRender && /*#__PURE__*/React.createElement(Box, {
|
55
|
+
mt: 3
|
56
|
+
}, validationMap && validationResult && validationMessageId && /*#__PURE__*/React.createElement(ValidationAnimationContainer, {
|
57
|
+
show: true
|
58
|
+
}, /*#__PURE__*/React.createElement(InputValidation, {
|
59
|
+
validationStatus: validationMap[validationResult],
|
60
|
+
id: validationMessageId
|
61
|
+
}, validationChildToRender))));
|
62
|
+
});
|
63
|
+
};
|
64
|
+
|
65
|
+
ChoiceFieldset.displayName = "ChoiceFieldset";
|
66
|
+
export default Object.assign(ChoiceFieldset, {
|
67
|
+
Description: ChoiceFieldsetDescription,
|
68
|
+
Item: ChoiceFieldsetListItem,
|
69
|
+
Legend: ChoiceFieldsetLegend,
|
70
|
+
List: ChoiceFieldsetList,
|
71
|
+
Validation: ChoiceFieldsetValidation
|
72
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Text } from '..';
|
3
|
+
import { Slot } from './ChoiceFieldset';
|
4
|
+
|
5
|
+
const ChoiceFieldsetDescription = ({
|
6
|
+
children
|
7
|
+
}) => /*#__PURE__*/React.createElement(Slot, {
|
8
|
+
name: "Description"
|
9
|
+
}, ({
|
10
|
+
disabled
|
11
|
+
}) => /*#__PURE__*/React.createElement(Text, {
|
12
|
+
color: disabled ? 'fg.muted' : 'fg.default',
|
13
|
+
fontSize: 1
|
14
|
+
}, children));
|
15
|
+
|
16
|
+
ChoiceFieldsetDescription.displayName = "ChoiceFieldsetDescription";
|
17
|
+
export default ChoiceFieldsetDescription;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Box } from '..';
|
3
|
+
import VisuallyHidden from '../_VisuallyHidden';
|
4
|
+
import { Slot } from './ChoiceFieldset';
|
5
|
+
|
6
|
+
const ChoiceFieldsetLegend = ({
|
7
|
+
children,
|
8
|
+
visuallyHidden
|
9
|
+
}) => /*#__PURE__*/React.createElement(Slot, {
|
10
|
+
name: "Legend"
|
11
|
+
}, ({
|
12
|
+
required,
|
13
|
+
disabled
|
14
|
+
}) => /*#__PURE__*/React.createElement(VisuallyHidden, {
|
15
|
+
as: "legend",
|
16
|
+
isVisible: !visuallyHidden,
|
17
|
+
title: required ? 'required field' : undefined,
|
18
|
+
sx: {
|
19
|
+
color: disabled ? 'fg.muted' : undefined,
|
20
|
+
fontSize: 2,
|
21
|
+
padding: 0
|
22
|
+
}
|
23
|
+
}, required ? /*#__PURE__*/React.createElement(Box, {
|
24
|
+
display: "flex",
|
25
|
+
as: "span"
|
26
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
27
|
+
mr: 1
|
28
|
+
}, children), /*#__PURE__*/React.createElement("span", null, "*")) : children));
|
29
|
+
|
30
|
+
ChoiceFieldsetLegend.displayName = "ChoiceFieldsetLegend";
|
31
|
+
export default ChoiceFieldsetLegend;
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import styled from 'styled-components';
|
3
|
+
import { CheckboxInputField, RadioInputField } from '..';
|
4
|
+
import { get } from '../constants';
|
5
|
+
import { uniqueId } from '../utils/uniqueId';
|
6
|
+
import { Slot } from './ChoiceFieldset';
|
7
|
+
import ChoiceFieldsetListContext from './ChoiceFieldsetListContext';
|
8
|
+
const List = styled.ul.withConfig({
|
9
|
+
displayName: "ChoiceFieldsetList__List",
|
10
|
+
componentId: "sc-16da7ba-0"
|
11
|
+
})(["display:flex;flex-direction:column;list-style:none;margin:0;padding:0;> li + li{margin-top:", ";}"], get('space.2'));
|
12
|
+
|
13
|
+
const ChoiceFieldsetList = ({
|
14
|
+
selectionVariant,
|
15
|
+
children
|
16
|
+
}) => {
|
17
|
+
// generates a name to pass to radio inputs if one was not passed in ChoiceFieldset props
|
18
|
+
const getRadioGroupName = nameFromContext => {
|
19
|
+
if (nameFromContext || selectionVariant !== 'multiple') {
|
20
|
+
return nameFromContext;
|
21
|
+
}
|
22
|
+
|
23
|
+
const generatedName = uniqueId();
|
24
|
+
return generatedName;
|
25
|
+
};
|
26
|
+
|
27
|
+
return /*#__PURE__*/React.createElement(Slot, {
|
28
|
+
name: "ChoiceList"
|
29
|
+
}, ({
|
30
|
+
name,
|
31
|
+
onSelect,
|
32
|
+
disabled,
|
33
|
+
selected = []
|
34
|
+
}) => {
|
35
|
+
const getSelectedCheckboxes = (value, checked) => {
|
36
|
+
if (checked) {
|
37
|
+
return selectionVariant === 'multiple' ? [...selected, value] : [value];
|
38
|
+
}
|
39
|
+
|
40
|
+
return selected.filter(selectedValue => selectedValue !== value);
|
41
|
+
};
|
42
|
+
|
43
|
+
return /*#__PURE__*/React.createElement(ChoiceFieldsetListContext.Provider, {
|
44
|
+
value: {
|
45
|
+
disabled,
|
46
|
+
selected,
|
47
|
+
name: getRadioGroupName(name),
|
48
|
+
fieldComponent: selectionVariant === 'multiple' ? CheckboxInputField : RadioInputField,
|
49
|
+
onChange: e => {
|
50
|
+
onSelect && onSelect(getSelectedCheckboxes(e.currentTarget.value, e.currentTarget.checked));
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}, /*#__PURE__*/React.createElement(List, null, React.Children.map(children, (child, i) => /*#__PURE__*/React.createElement("li", {
|
54
|
+
key: i
|
55
|
+
}, child))));
|
56
|
+
});
|
57
|
+
};
|
58
|
+
|
59
|
+
ChoiceFieldsetList.displayName = "ChoiceFieldsetList";
|
60
|
+
ChoiceFieldsetList.defaultProps = {
|
61
|
+
selectionVariant: 'single'
|
62
|
+
};
|
63
|
+
export default ChoiceFieldsetList;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { ChangeEventHandler } from 'react';
|
2
|
+
import { CheckboxInputField, RadioInputField } from '..';
|
3
|
+
import { ComponentProps } from '../utils/types';
|
4
|
+
import InputField from '../_InputField';
|
5
|
+
import ToggleInputField, { ToggleInputFieldProps } from '../_InputField/ToggleInputField';
|
6
|
+
declare const ChoiceFieldsetListContext: import("react").Context<{
|
7
|
+
disabled?: boolean | undefined;
|
8
|
+
name?: string | undefined;
|
9
|
+
onChange: ChangeEventHandler<HTMLInputElement>;
|
10
|
+
fieldComponent: React.FC<ToggleInputFieldProps> & {
|
11
|
+
Input: React.FC<ComponentProps<typeof RadioInputField.Input>> | React.FC<ComponentProps<typeof CheckboxInputField.Input>>;
|
12
|
+
Caption: React.FC<ComponentProps<typeof InputField.Caption>>;
|
13
|
+
Label: React.FC<ComponentProps<typeof InputField.Label>>;
|
14
|
+
LeadingVisual: React.FC<ComponentProps<typeof ToggleInputField.LeadingVisual>>;
|
15
|
+
};
|
16
|
+
selected?: string[] | undefined;
|
17
|
+
} | null>;
|
18
|
+
export default ChoiceFieldsetListContext;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ComponentProps } from '../utils/types';
|
3
|
+
export interface ChoiceFieldProps {
|
4
|
+
/**
|
5
|
+
* Whether the field is ready for user input
|
6
|
+
*/
|
7
|
+
disabled?: boolean;
|
8
|
+
/**
|
9
|
+
* The unique identifier for this field. Used to associate the label, validation text, and caption text.
|
10
|
+
* If an ID is not provided, one will be automatically generated.
|
11
|
+
*/
|
12
|
+
id?: string;
|
13
|
+
/**
|
14
|
+
* The value that is being selected
|
15
|
+
*/
|
16
|
+
value: string;
|
17
|
+
}
|
18
|
+
declare const ChoiceFieldsetListItem: React.FC<ChoiceFieldProps>;
|
19
|
+
export declare type ChoiceFieldComponentProps = ComponentProps<typeof ChoiceFieldsetListItem>;
|
20
|
+
declare const _default: React.FC<ChoiceFieldProps> & {
|
21
|
+
Caption: React.FC<{}>;
|
22
|
+
Label: React.FC<{}>;
|
23
|
+
LeadingVisual: React.FC<{}>;
|
24
|
+
};
|
25
|
+
export default _default;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import React, { useContext } from 'react';
|
2
|
+
import { uniqueId } from '../utils/uniqueId';
|
3
|
+
import ToggleInputLeadingVisual from '../_InputField/ToggleInputLeadingVisual';
|
4
|
+
import ChoiceFieldCaption from './ChoiceFieldCaption';
|
5
|
+
import ChoiceFieldLabel from './ChoiceFieldLabel';
|
6
|
+
import ChoiceFieldsetListContext from './ChoiceFieldsetListContext';
|
7
|
+
|
8
|
+
const ChoiceFieldsetListItem = ({
|
9
|
+
children,
|
10
|
+
id,
|
11
|
+
disabled: disabledProp,
|
12
|
+
value
|
13
|
+
}) => {
|
14
|
+
const choiceFieldsetListContext = useContext(ChoiceFieldsetListContext);
|
15
|
+
|
16
|
+
if (choiceFieldsetListContext === null) {
|
17
|
+
throw new Error('ChoiceFieldsetListContext returned null');
|
18
|
+
}
|
19
|
+
|
20
|
+
const {
|
21
|
+
name,
|
22
|
+
onChange,
|
23
|
+
fieldComponent: FieldComponent,
|
24
|
+
selected,
|
25
|
+
disabled
|
26
|
+
} = choiceFieldsetListContext;
|
27
|
+
const fieldId = id || uniqueId();
|
28
|
+
const labelChild = React.Children.toArray(children).find(child => /*#__PURE__*/React.isValidElement(child) && child.type === ChoiceFieldLabel);
|
29
|
+
const otherValidChildren = React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && (child.type === ChoiceFieldCaption || child.type === ToggleInputLeadingVisual));
|
30
|
+
return /*#__PURE__*/React.createElement(FieldComponent, {
|
31
|
+
id: fieldId,
|
32
|
+
disabled: disabledProp || disabled
|
33
|
+
}, /*#__PURE__*/React.createElement(FieldComponent.Input, {
|
34
|
+
checked: selected === null || selected === void 0 ? void 0 : selected.includes(value),
|
35
|
+
value: value,
|
36
|
+
name: name,
|
37
|
+
onChange: onChange
|
38
|
+
}), labelChild ? // if <Item.Label> was passed, we can just render the children as-is
|
39
|
+
children :
|
40
|
+
/*#__PURE__*/
|
41
|
+
// if <Item.Label> was NOT passed, treat all the children except <Item.Caption> and <Item.LeadingVisual> as the label
|
42
|
+
React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FieldComponent.Label, null, children), otherValidChildren));
|
43
|
+
};
|
44
|
+
|
45
|
+
ChoiceFieldsetListItem.displayName = "ChoiceFieldsetListItem";
|
46
|
+
export default Object.assign(ChoiceFieldsetListItem, {
|
47
|
+
Caption: ChoiceFieldCaption,
|
48
|
+
Label: ChoiceFieldLabel,
|
49
|
+
LeadingVisual: ToggleInputLeadingVisual
|
50
|
+
});
|
package/lib-esm/Details.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
import { SystemCommonProps } from './constants';
|
1
2
|
import { SxProp } from './sx';
|
2
3
|
import { ComponentProps } from './utils/types';
|
3
|
-
declare const Details: import("styled-components").StyledComponent<"details", any, SxProp, never>;
|
4
|
+
declare const Details: import("styled-components").StyledComponent<"details", any, SystemCommonProps & SxProp, never>;
|
4
5
|
export declare type DetailsProps = ComponentProps<typeof Details>;
|
5
6
|
export default Details;
|
package/lib-esm/Details.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import styled from 'styled-components';
|
2
|
+
import { COMMON } from './constants';
|
2
3
|
import sx from './sx';
|
3
4
|
const Details = styled.details.withConfig({
|
4
5
|
displayName: "Details",
|
5
6
|
componentId: "ssy9qz-0"
|
6
|
-
})(["& > summary{list-style:none;}& > summary::-webkit-details-marker{display:none;}", ";"], sx);
|
7
|
+
})(["& > summary{list-style:none;}& > summary::-webkit-details-marker{display:none;}", " ", ";"], COMMON, sx);
|
7
8
|
Details.displayName = 'Details';
|
8
9
|
export default Details;
|
package/lib-esm/Dropdown.d.ts
CHANGED
@@ -15,14 +15,46 @@ export declare type DropdownMenuProps = ComponentProps<typeof DropdownMenu>;
|
|
15
15
|
export declare type DropdownItemProps = ComponentProps<typeof DropdownItem>;
|
16
16
|
declare const _default: {
|
17
17
|
({ children, className, ...rest }: {
|
18
|
-
|
18
|
+
backgroundColor?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
19
|
+
color?: (string & import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>) | undefined;
|
20
|
+
display?: import("styled-system").ResponsiveValue<import("csstype").Property.Display, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
21
|
+
marginBottom?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
22
|
+
marginLeft?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
23
|
+
marginRight?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
24
|
+
marginTop?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
25
|
+
opacity?: import("styled-system").ResponsiveValue<import("csstype").Property.Opacity, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
26
|
+
paddingBottom?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
27
|
+
paddingLeft?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
28
|
+
paddingRight?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
29
|
+
paddingTop?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
19
30
|
translate?: "yes" | "no" | undefined;
|
31
|
+
margin?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
32
|
+
padding?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
20
33
|
hidden?: boolean | undefined;
|
21
34
|
children?: React.ReactNode;
|
22
35
|
ref?: ((instance: HTMLElement | null) => void) | React.RefObject<HTMLElement> | null | undefined;
|
36
|
+
p?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
23
37
|
slot?: string | undefined;
|
24
38
|
style?: React.CSSProperties | undefined;
|
25
39
|
title?: string | undefined;
|
40
|
+
bg?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
41
|
+
m?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
42
|
+
mt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
43
|
+
mr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
44
|
+
mb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
45
|
+
ml?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
46
|
+
mx?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
47
|
+
marginX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
48
|
+
my?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
49
|
+
marginY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
50
|
+
pt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
51
|
+
pr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
52
|
+
pb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
53
|
+
pl?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
54
|
+
px?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
55
|
+
paddingX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
56
|
+
py?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
57
|
+
paddingY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
26
58
|
open?: boolean | undefined;
|
27
59
|
role?: React.AriaRole | undefined;
|
28
60
|
sx?: import("./sx").BetterSystemStyleObject | undefined;
|
@@ -281,14 +313,46 @@ declare const _default: {
|
|
281
313
|
theme?: any;
|
282
314
|
}): JSX.Element;
|
283
315
|
defaultProps: Partial<{
|
284
|
-
|
316
|
+
backgroundColor?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
317
|
+
color?: (string & import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>) | undefined;
|
318
|
+
display?: import("styled-system").ResponsiveValue<import("csstype").Property.Display, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
319
|
+
marginBottom?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
320
|
+
marginLeft?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
321
|
+
marginRight?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
322
|
+
marginTop?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
323
|
+
opacity?: import("styled-system").ResponsiveValue<import("csstype").Property.Opacity, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
324
|
+
paddingBottom?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
325
|
+
paddingLeft?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
326
|
+
paddingRight?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
327
|
+
paddingTop?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
285
328
|
translate?: "yes" | "no" | undefined;
|
329
|
+
margin?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
330
|
+
padding?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
286
331
|
hidden?: boolean | undefined;
|
287
332
|
children?: React.ReactNode;
|
288
333
|
ref?: ((instance: HTMLElement | null) => void) | React.RefObject<HTMLElement> | null | undefined;
|
334
|
+
p?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
289
335
|
slot?: string | undefined;
|
290
336
|
style?: React.CSSProperties | undefined;
|
291
337
|
title?: string | undefined;
|
338
|
+
bg?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
339
|
+
m?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
340
|
+
mt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
341
|
+
mr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
342
|
+
mb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
343
|
+
ml?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
344
|
+
mx?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
345
|
+
marginX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
346
|
+
my?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
347
|
+
marginY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
348
|
+
pt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
349
|
+
pr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
350
|
+
pb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
351
|
+
pl?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
352
|
+
px?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
353
|
+
paddingX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
354
|
+
py?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
355
|
+
paddingY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
292
356
|
open?: boolean | undefined;
|
293
357
|
role?: React.AriaRole | undefined;
|
294
358
|
sx?: import("./sx").BetterSystemStyleObject | undefined;
|
package/lib-esm/Heading.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
import { SystemCommonProps, SystemTypographyProps } from './constants';
|
1
2
|
import { SxProp } from './sx';
|
2
3
|
import { ComponentProps } from './utils/types';
|
3
|
-
declare const Heading: import("styled-components").StyledComponent<"h2", any, SxProp, never>;
|
4
|
+
declare const Heading: import("styled-components").StyledComponent<"h2", any, SystemTypographyProps & SystemCommonProps & SxProp, never>;
|
4
5
|
export declare type HeadingProps = ComponentProps<typeof Heading>;
|
5
6
|
export default Heading;
|
package/lib-esm/Heading.js
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
import styled from 'styled-components';
|
2
|
-
import { get } from './constants';
|
2
|
+
import { COMMON, get, TYPOGRAPHY } from './constants';
|
3
3
|
import sx from './sx';
|
4
|
+
import theme from './theme';
|
4
5
|
const Heading = styled.h2.withConfig({
|
5
6
|
displayName: "Heading",
|
6
7
|
componentId: "sc-1cjoo9h-0"
|
7
|
-
})(["font-weight:", ";font-size:", ";margin:0;", ";"], get('fontWeights.bold'), get('fontSizes.5'), sx);
|
8
|
+
})(["font-weight:", ";font-size:", ";margin:0;", ";", ";", ";"], get('fontWeights.bold'), get('fontSizes.5'), TYPOGRAPHY, COMMON, sx);
|
9
|
+
Heading.defaultProps = {
|
10
|
+
theme
|
11
|
+
};
|
8
12
|
export default Heading;
|
package/lib-esm/ProgressBar.d.ts
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { WidthProps } from 'styled-system';
|
3
|
+
import { SystemCommonProps } from './constants';
|
3
4
|
import { SxProp } from './sx';
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
default
|
11
|
-
}
|
12
|
-
declare type
|
13
|
-
|
14
|
-
barSize?: keyof typeof sizeMap;
|
15
|
-
} & WidthProps & SxProp;
|
16
|
-
export declare type ProgressBarProps = {
|
17
|
-
bg: string;
|
18
|
-
} & StyledProgressContainerProps & ProgressProp;
|
19
|
-
declare function ProgressBar({ progress, bg, ...rest }: ProgressBarProps): JSX.Element;
|
5
|
+
import { ComponentProps } from './utils/types';
|
6
|
+
declare const Bar: import("styled-components").StyledComponent<"span", any, {
|
7
|
+
progress?: string | number | undefined;
|
8
|
+
} & SystemCommonProps, never>;
|
9
|
+
declare const ProgressContainer: import("styled-components").StyledComponent<"span", any, {
|
10
|
+
inline?: boolean | undefined;
|
11
|
+
barSize?: "small" | "default" | "large" | undefined;
|
12
|
+
} & WidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Width<import("styled-system").TLengthStyledSystem>> & SystemCommonProps & SxProp, never>;
|
13
|
+
export declare type ProgressBarProps = ComponentProps<typeof ProgressContainer> & ComponentProps<typeof Bar>;
|
14
|
+
declare function ProgressBar({ progress, bg, theme, ...rest }: ProgressBarProps): JSX.Element;
|
20
15
|
declare namespace ProgressBar {
|
21
16
|
var defaultProps: {
|
22
17
|
bg: string;
|
package/lib-esm/ProgressBar.js
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
1
3
|
import React from 'react';
|
2
4
|
import styled from 'styled-components';
|
3
5
|
import { width } from 'styled-system';
|
4
|
-
import { get } from './constants';
|
6
|
+
import { COMMON, get } from './constants';
|
5
7
|
import sx from './sx';
|
6
8
|
const Bar = styled.span.withConfig({
|
7
9
|
displayName: "ProgressBar__Bar",
|
8
10
|
componentId: "sc-1tiva13-0"
|
9
|
-
})(["width:", ";", "
|
11
|
+
})(["width:", ";", ""], props => props.progress ? `${props.progress}%` : 0, COMMON);
|
10
12
|
const sizeMap = {
|
11
13
|
small: '5px',
|
12
14
|
large: '10px',
|
@@ -15,18 +17,20 @@ const sizeMap = {
|
|
15
17
|
const ProgressContainer = styled.span.withConfig({
|
16
18
|
displayName: "ProgressBar__ProgressContainer",
|
17
19
|
componentId: "sc-1tiva13-1"
|
18
|
-
})(["display:", ";overflow:hidden;background-color:", ";border-radius:", ";height:", ";", " ", ";"], props => props.inline ? 'inline-flex' : 'flex', get('colors.border.default'), get('radii.1'), props => sizeMap[props.barSize || 'default'], width, sx);
|
20
|
+
})(["display:", ";overflow:hidden;background-color:", ";border-radius:", ";height:", ";", " ", " ", ";"], props => props.inline ? 'inline-flex' : 'flex', get('colors.border.default'), get('radii.1'), props => sizeMap[props.barSize || 'default'], COMMON, width, sx);
|
19
21
|
|
20
22
|
function ProgressBar({
|
21
23
|
progress,
|
22
24
|
bg,
|
25
|
+
theme,
|
23
26
|
...rest
|
24
27
|
}) {
|
25
|
-
return /*#__PURE__*/React.createElement(ProgressContainer,
|
28
|
+
return /*#__PURE__*/React.createElement(ProgressContainer, _extends({
|
29
|
+
theme: theme
|
30
|
+
}, rest), /*#__PURE__*/React.createElement(Bar, {
|
26
31
|
progress: progress,
|
27
|
-
|
28
|
-
|
29
|
-
}
|
32
|
+
bg: bg,
|
33
|
+
theme: theme
|
30
34
|
}));
|
31
35
|
}
|
32
36
|
|