@indico-data/design-system 1.0.53 → 1.0.55
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/lib/components/Icon/Icon.d.ts +1 -0
- package/lib/components/Icon/Icon.stories.d.ts +2 -0
- package/lib/components/Toggle/Toggle.d.ts +12 -0
- package/lib/components/Toggle/Toggle.stories.d.ts +21 -0
- package/lib/components/Toggle/Toggle.styles.d.ts +2 -0
- package/lib/components/Toggle/index.d.ts +1 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/inputs/NoInputDatePicker/NoInputDatePicker.d.ts +2 -0
- package/lib/index.d.ts +69 -55
- package/lib/index.esm.js +129 -11
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +129 -10
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Icon/Icon.tsx +2 -0
- package/src/components/Toggle/Toggle.stories.tsx +56 -0
- package/src/components/Toggle/Toggle.styles.ts +86 -0
- package/src/components/Toggle/Toggle.tsx +57 -0
- package/src/components/Toggle/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/components/inputs/NoInputDatePicker/NoInputDatePicker.stories.tsx +1 -0
- package/src/components/inputs/NoInputDatePicker/NoInputDatePicker.tsx +51 -9
- package/src/index.ts +1 -0
- package/lib/components/Navigation/Drawer/constants.d.ts +0 -3
package/lib/index.esm.js
CHANGED
|
@@ -1594,7 +1594,7 @@ function Icon(_a) {
|
|
|
1594
1594
|
console.error(`${props.name} is not a valid icon name.`);
|
|
1595
1595
|
return null;
|
|
1596
1596
|
}
|
|
1597
|
-
return (jsx("svg", Object.assign({}, iconComponentProps, ariaLabel, dimensions, { role: "img", className: props.className, "data-cy": props['data-cy'], "data-testid": props['data-testid'], fill: props.fill || 'currentColor', id: props.id, style: style, onClick: props.onClick })));
|
|
1597
|
+
return (jsx("svg", Object.assign({}, iconComponentProps, ariaLabel, dimensions, { ref: props.ref, role: "img", className: props.className, "data-cy": props['data-cy'], "data-testid": props['data-testid'], fill: props.fill || 'currentColor', id: props.id, style: style, onClick: props.onClick })));
|
|
1598
1598
|
}
|
|
1599
1599
|
function returnDimensions(sizeProp) {
|
|
1600
1600
|
if (sizeProp.length > 1) {
|
|
@@ -23090,12 +23090,22 @@ const StyledNoInputDatePicker = styled.div `
|
|
|
23090
23090
|
|
|
23091
23091
|
function CustomCaption(props) {
|
|
23092
23092
|
const { goToMonth, nextMonth, previousMonth } = useNavigation();
|
|
23093
|
-
return (jsxs("div", { className: "custom__caption", children: [jsx("button", { className: "custom__caption__action__button", disabled: !previousMonth, onClick: () =>
|
|
23093
|
+
return (jsxs("div", { className: "custom__caption", children: [jsx("button", { className: "custom__caption__action__button", disabled: !previousMonth, onClick: (event) => {
|
|
23094
|
+
event.preventDefault();
|
|
23095
|
+
if (previousMonth) {
|
|
23096
|
+
goToMonth(previousMonth);
|
|
23097
|
+
}
|
|
23098
|
+
}, children: jsx(Icon, { size: [10], ariaLabel: "Previous Month", name: "chevron-left" }) }), jsx("h2", { className: "custom__caption__text", children: format(props.displayMonth, 'MMM yyyy') }), jsx("button", { className: "custom__caption__action__button", disabled: !nextMonth, onClick: (event) => {
|
|
23099
|
+
event.preventDefault();
|
|
23100
|
+
if (nextMonth) {
|
|
23101
|
+
goToMonth(nextMonth);
|
|
23102
|
+
}
|
|
23103
|
+
}, children: jsx(Icon, { size: [10], ariaLabel: "Next Month", name: "chevron-right" }) })] }));
|
|
23094
23104
|
}
|
|
23095
23105
|
const NoInputDatePicker = (props) => {
|
|
23096
|
-
const { ariaLabel, className, disabled, disableBeforeDate, disableAfterDate, id, label, onChange, selected, triggerIcon, triggerIconSize, isRangePicker, isOpen, } = props;
|
|
23106
|
+
const { ariaLabel, className, disabled, disableBeforeDate, disableAfterDate, id, label, onChange, selected, triggerIcon, triggerIconSize, isRangePicker, selectedRange, isOpen, clearOnClose, } = props;
|
|
23097
23107
|
const [localSelected, setLocalSelected] = useState(selected || undefined);
|
|
23098
|
-
const [
|
|
23108
|
+
const [localSelectedRange, setLocalSelectedRange] = useState(selectedRange || undefined);
|
|
23099
23109
|
const [isPopperOpen, setIsPopperOpen] = useState(isOpen || false);
|
|
23100
23110
|
const [popperElement, setPopperElement] = useState(null);
|
|
23101
23111
|
const popperRef = useRef(null);
|
|
@@ -23111,17 +23121,34 @@ const NoInputDatePicker = (props) => {
|
|
|
23111
23121
|
],
|
|
23112
23122
|
});
|
|
23113
23123
|
const [isTrapActive, setIsTrapActive] = useState(false);
|
|
23124
|
+
const datePickerRef = useRef(null);
|
|
23125
|
+
// Addresses clickout side bug when implementing in an application
|
|
23114
23126
|
useEffect(() => {
|
|
23127
|
+
const handleClickOutside = (event) => {
|
|
23128
|
+
// Close the date picker only when clicked outside
|
|
23129
|
+
if (datePickerRef.current &&
|
|
23130
|
+
event.target instanceof Node &&
|
|
23131
|
+
!datePickerRef.current.contains(event.target)) {
|
|
23132
|
+
closePopper();
|
|
23133
|
+
}
|
|
23134
|
+
};
|
|
23135
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
23136
|
+
return () => {
|
|
23137
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
23138
|
+
};
|
|
23139
|
+
}, []);
|
|
23140
|
+
// Allow datepicker to load before setting active trap
|
|
23141
|
+
useLayoutEffect(() => {
|
|
23115
23142
|
if (isOpen) {
|
|
23116
|
-
|
|
23117
|
-
const timeoutId = setTimeout(() => setIsTrapActive(true), 0);
|
|
23118
|
-
return () => clearTimeout(timeoutId);
|
|
23143
|
+
setIsTrapActive(true);
|
|
23119
23144
|
}
|
|
23120
23145
|
else {
|
|
23121
23146
|
setIsTrapActive(false);
|
|
23122
23147
|
}
|
|
23123
23148
|
}, [isOpen]);
|
|
23124
23149
|
const closePopper = () => {
|
|
23150
|
+
clearOnClose && setLocalSelected(undefined);
|
|
23151
|
+
clearOnClose && setLocalSelectedRange(undefined);
|
|
23125
23152
|
setIsPopperOpen(false);
|
|
23126
23153
|
};
|
|
23127
23154
|
const handleDaySelect = (date) => {
|
|
@@ -23135,7 +23162,7 @@ const NoInputDatePicker = (props) => {
|
|
|
23135
23162
|
}
|
|
23136
23163
|
};
|
|
23137
23164
|
const handleRangeSelect = (range) => {
|
|
23138
|
-
|
|
23165
|
+
setLocalSelectedRange(range);
|
|
23139
23166
|
if ((range === null || range === void 0 ? void 0 : range.from) && (range === null || range === void 0 ? void 0 : range.to)) {
|
|
23140
23167
|
onChange(range);
|
|
23141
23168
|
closePopper();
|
|
@@ -23144,14 +23171,15 @@ const NoInputDatePicker = (props) => {
|
|
|
23144
23171
|
onChange(range);
|
|
23145
23172
|
}
|
|
23146
23173
|
};
|
|
23147
|
-
return (jsxs(StyledNoInputDatePicker, { className: className, "aria-label": ariaLabel || 'date select', "aria-describedby": `picker-label--${id}`, "data-cy": props['data-cy'], "data-testid": props['data-testid'], id: id, children: [label ? (jsx("div", { id: `picker-label--${id}`, className: "visually-hidden", children: label })) : null, jsx("div", { ref: popperRef, className: "no__input__date__picker-inputParent", children: jsx(Icon, { "aria-label": "Open date picker", name: triggerIcon, size: triggerIconSize, className: "date__picker__trigger", "data-testid": `datepicker-trigger-for-${id}`, onClick: () => setIsPopperOpen(!isPopperOpen) }) }), isPopperOpen && (jsx(FocusTrap$1, { active: isTrapActive, focusTrapOptions: {
|
|
23174
|
+
return (jsxs(StyledNoInputDatePicker, { className: className, "aria-label": ariaLabel || 'date select', "aria-describedby": `picker-label--${id}`, "data-cy": props['data-cy'], "data-testid": props['data-testid'], id: id, ref: datePickerRef, children: [label ? (jsx("div", { id: `picker-label--${id}`, className: "visually-hidden", children: label })) : null, jsx("div", { ref: popperRef, className: "no__input__date__picker-inputParent", children: jsx(Icon, { "aria-label": "Open date picker", name: triggerIcon, size: triggerIconSize, className: "date__picker__trigger", "data-testid": `datepicker-trigger-for-${id}`, onClick: () => setIsPopperOpen(!isPopperOpen) }) }), isPopperOpen && (jsx(FocusTrap$1, { active: isTrapActive, focusTrapOptions: {
|
|
23148
23175
|
initialFocus: false,
|
|
23149
23176
|
allowOutsideClick: true,
|
|
23150
23177
|
clickOutsideDeactivates: true,
|
|
23151
23178
|
onDeactivate: closePopper,
|
|
23179
|
+
fallbackFocus: popperRef.current || undefined,
|
|
23152
23180
|
}, children: jsx("div", Object.assign({ tabIndex: -1, style: popper.styles.popper, className: "DayPickerInput-Overlay" }, popper.attributes.popper, { ref: setPopperElement, role: "dialog", "aria-label": "DayPicker calendar", "data-testid": "datepicker-dialog", children: isRangePicker ? (jsx(DayPicker, { components: {
|
|
23153
23181
|
Caption: CustomCaption,
|
|
23154
|
-
}, disabled: disabled, mode: 'range', defaultMonth: localSelected, selected:
|
|
23182
|
+
}, disabled: disabled, mode: 'range', defaultMonth: localSelected, selected: localSelectedRange, onSelect: handleRangeSelect, fromDate: disableBeforeDate, toDate: disableAfterDate, "data-testid": "range-datepicker" })) : (jsx(DayPicker, { components: {
|
|
23155
23183
|
Caption: CustomCaption,
|
|
23156
23184
|
}, disabled: disabled, mode: 'single', defaultMonth: localSelected, selected: localSelected, onSelect: handleDaySelect, fromDate: disableBeforeDate, toDate: disableAfterDate, "data-testid": "single-datepicker" })) })) }))] }));
|
|
23157
23185
|
};
|
|
@@ -25762,5 +25790,95 @@ function TextTruncate({ string, maxChars, children }) {
|
|
|
25762
25790
|
return string.length > maxChars ? (jsxs(StyledTextTruncate, { title: string, children: [`${string.substring(0, maxChars)}...`, children] })) : (jsxs(StyledTextTruncate, { children: [string, children] }));
|
|
25763
25791
|
}
|
|
25764
25792
|
|
|
25765
|
-
|
|
25793
|
+
const StyledToggle = styled.label `
|
|
25794
|
+
position: relative;
|
|
25795
|
+
display: inline-block;
|
|
25796
|
+
width: 28px;
|
|
25797
|
+
height: 18px;
|
|
25798
|
+
border: 2px solid ${allColors.defaultFontColor};
|
|
25799
|
+
border-radius: 34px;
|
|
25800
|
+
margin-bottom: 0;
|
|
25801
|
+
cursor: pointer;
|
|
25802
|
+
|
|
25803
|
+
& input {
|
|
25804
|
+
display: none;
|
|
25805
|
+
}
|
|
25806
|
+
|
|
25807
|
+
&.disabled {
|
|
25808
|
+
cursor: not-allowed;
|
|
25809
|
+
opacity: 0.5;
|
|
25810
|
+
}
|
|
25811
|
+
|
|
25812
|
+
.slider {
|
|
25813
|
+
position: absolute;
|
|
25814
|
+
top: 0;
|
|
25815
|
+
left: -1px;
|
|
25816
|
+
right: 0;
|
|
25817
|
+
bottom: 0;
|
|
25818
|
+
transition: 0.4s;
|
|
25819
|
+
border-radius: 34px;
|
|
25820
|
+
}
|
|
25821
|
+
|
|
25822
|
+
.slider:before {
|
|
25823
|
+
position: absolute;
|
|
25824
|
+
content: '';
|
|
25825
|
+
height: 17px;
|
|
25826
|
+
width: 17px;
|
|
25827
|
+
left: -1px;
|
|
25828
|
+
bottom: -1px;
|
|
25829
|
+
background-color: ${allColors.clay};
|
|
25830
|
+
transition: 0.4s;
|
|
25831
|
+
border: 2px solid ${allColors.defaultFontColor};
|
|
25832
|
+
border-radius: 50%;
|
|
25833
|
+
}
|
|
25834
|
+
|
|
25835
|
+
input:checked + .slider {
|
|
25836
|
+
background-color: ${allColors.defaultFontColor};
|
|
25837
|
+
width: 100%;
|
|
25838
|
+
}
|
|
25839
|
+
|
|
25840
|
+
input:checked + .slider:before {
|
|
25841
|
+
transform: translateX(12px);
|
|
25842
|
+
}
|
|
25843
|
+
|
|
25844
|
+
p {
|
|
25845
|
+
position: relative;
|
|
25846
|
+
left: 35px;
|
|
25847
|
+
bottom: 2px;
|
|
25848
|
+
}
|
|
25849
|
+
|
|
25850
|
+
.checked-icon,
|
|
25851
|
+
.not-checked-icon {
|
|
25852
|
+
position: absolute;
|
|
25853
|
+
pointer-events: none;
|
|
25854
|
+
top: 50%;
|
|
25855
|
+
transform: translateY(-50%);
|
|
25856
|
+
}
|
|
25857
|
+
|
|
25858
|
+
.checked-icon {
|
|
25859
|
+
fill: #fff;
|
|
25860
|
+
display: none;
|
|
25861
|
+
left: 3px;
|
|
25862
|
+
}
|
|
25863
|
+
|
|
25864
|
+
.not-checked-icon {
|
|
25865
|
+
right: 3px;
|
|
25866
|
+
}
|
|
25867
|
+
|
|
25868
|
+
input:checked ~ .not-checked-icon {
|
|
25869
|
+
display: none;
|
|
25870
|
+
}
|
|
25871
|
+
input:checked ~ .checked-icon {
|
|
25872
|
+
display: block;
|
|
25873
|
+
}
|
|
25874
|
+
`;
|
|
25875
|
+
|
|
25876
|
+
const Toggle = (props) => {
|
|
25877
|
+
const { disabled, onChange, value, className, id, checkedIconName, notCheckedIconName, iconSize, } = props;
|
|
25878
|
+
return (jsxs(StyledToggle, { className: classNames(className, {
|
|
25879
|
+
disabled,
|
|
25880
|
+
}), "data-cy": props['data-cy'], id: id, children: [jsx("input", { "aria-label": props['aria-label'], type: "checkbox", disabled: disabled, checked: value, onChange: onChange }), jsx("span", { className: "slider round" }), checkedIconName && (jsx(Icon, { name: checkedIconName, size: [iconSize || 5], className: "checked-icon" })), notCheckedIconName && (jsx(Icon, { name: notCheckedIconName, size: [iconSize || 5], className: "not-checked-icon" }))] }));
|
|
25881
|
+
};
|
|
25882
|
+
|
|
25883
|
+
export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$1 as Button, allColors as COLORS, CirclePulse, CircleSpinner, ConfirmModal, DatePicker, Drawer, EditableInput, GlobalStyles, Icon, IconButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio, RadioGroup, RandomLoadingMessage, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, StyledWizard, typography as TYPOGRAPHY, TextInput, TextTruncate, Toggle, Wizard, WizardCard, WizardSection, WizardWithSidebar, faIcons, indicons };
|
|
25766
25884
|
//# sourceMappingURL=index.esm.js.map
|