@indico-data/design-system 2.5.0 → 2.6.0

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,26 +1,14 @@
1
1
  import type { Preview, ReactRenderer } from '@storybook/react';
2
2
  import { withThemeByDataAttribute } from '@storybook/addon-themes';
3
- // import { withThemeFromJSXProvider } from '@storybook/addon-themes';
4
- // import { GlobalStyles } from '../src/legacy/styles/globals'; // TODO -- replace
5
3
  import '@/styles/index.scss';
6
-
7
- // export const decorators = [
8
- // withThemeFromJSXProvider({
9
- // GlobalStyles, // Adds your GlobalStyle component to all stories
10
- // }),
11
- // ];
4
+ import '@/styles/storybook.scss';
12
5
 
13
6
  import React from 'react';
14
7
 
15
8
  const preview: Preview = {
16
9
  decorators: [
17
10
  (Story: React.ComponentType) =>
18
- React.createElement(
19
- 'div',
20
- { style: { padding: '1em' } },
21
- // 👇 Decorators in Storybook also accept a function. Replace <Story/> with Story() to enable it
22
- React.createElement(Story),
23
- ),
11
+ React.createElement('div', { style: { padding: '1em' } }, React.createElement(Story)),
24
12
  withThemeByDataAttribute({
25
13
  themes: {
26
14
  light: 'light',
@@ -30,6 +18,8 @@ const preview: Preview = {
30
18
  attributeName: 'data-theme',
31
19
  parentSelector: 'body',
32
20
  }),
21
+ (Story: React.ComponentType) =>
22
+ React.createElement('div', { className: 'sb__story' }, React.createElement(Story)),
33
23
  ],
34
24
  parameters: {
35
25
  backgrounds: { disable: true },
package/lib/index.css CHANGED
@@ -965,6 +965,95 @@
965
965
  margin-bottom: var(--pf-margin-2);
966
966
  }
967
967
 
968
+ :root,
969
+ :root [data-theme=light],
970
+ :root [data-theme=dark] {
971
+ --pf-radio-background-color: var(--pf-white-color);
972
+ --pf-radio-check-color: var(--pf-primary-color);
973
+ --pf-radio-border-color: var(--pf-gray-color);
974
+ --pf-radio-disabled-color: var(--pf-gray-color-400);
975
+ }
976
+
977
+ :root [data-theme=dark] {
978
+ --pf-radio-background-color: transparent;
979
+ --pf-radio-check-color: var(--pf-white-color);
980
+ --pf-radio-border-color: var(--pf-white-color);
981
+ --pf-radio-disabled-color: var(--pf-gray-color-300);
982
+ }
983
+
984
+ .form-control .radio-wrapper {
985
+ display: flex;
986
+ margin-bottom: var(--pf-margin-2);
987
+ align-items: center;
988
+ }
989
+ .form-control .radio-input {
990
+ margin: 0;
991
+ margin-right: var(--pf-margin-2);
992
+ cursor: pointer;
993
+ }
994
+ .form-control .radio-input-label {
995
+ cursor: pointer;
996
+ }
997
+ .form-control [type=radio]:checked,
998
+ .form-control [type=radio]:not(:checked) {
999
+ position: absolute;
1000
+ left: -9999px;
1001
+ }
1002
+ .form-control [type=radio]:checked + label,
1003
+ .form-control [type=radio]:not(:checked) + label {
1004
+ position: relative;
1005
+ padding-left: var(--pf-padding-7);
1006
+ cursor: pointer;
1007
+ line-height: 20px;
1008
+ display: inline-block;
1009
+ }
1010
+ .form-control [type=radio]:checked + label:before,
1011
+ .form-control [type=radio]:not(:checked) + label:before {
1012
+ content: "";
1013
+ position: absolute;
1014
+ left: 0;
1015
+ top: 0;
1016
+ width: 18px;
1017
+ height: 18px;
1018
+ border: 1px solid var(--pf-radio-border-color);
1019
+ border-radius: 100%;
1020
+ background: var(--pf-radio-background-color);
1021
+ }
1022
+ .form-control [type=radio]:checked + label:after,
1023
+ .form-control [type=radio]:not(:checked) + label:after {
1024
+ content: "";
1025
+ width: 12px;
1026
+ height: 12px;
1027
+ background: var(--pf-radio-check-color);
1028
+ position: absolute;
1029
+ top: 4px;
1030
+ left: 4px;
1031
+ border-radius: 100%;
1032
+ transition: all 0.2s ease;
1033
+ }
1034
+ .form-control [type=radio]:not(:checked) + label:after {
1035
+ opacity: 0;
1036
+ transform: scale(0);
1037
+ }
1038
+ .form-control [type=radio]:checked + label:after {
1039
+ opacity: 1;
1040
+ transform: scale(1);
1041
+ }
1042
+ .form-control [type=radio]:disabled,
1043
+ .form-control [type=radio]:disabled + label {
1044
+ cursor: not-allowed;
1045
+ }
1046
+ .form-control [type=radio]:disabled + label {
1047
+ color: var(--pf-radio-disabled-color);
1048
+ opacity: 0.5;
1049
+ }
1050
+ .form-control [type=radio]:disabled + label:before {
1051
+ border-color: var(--pf-radio-disabled-color);
1052
+ }
1053
+ .form-control [type=radio]:disabled + label:after {
1054
+ background: var(--pf-radio-disabled-color);
1055
+ }
1056
+
968
1057
  :root {
969
1058
  --pf-font-family-base: "Mulish", sans-serif;
970
1059
  --pf-font-size-base: 1rem;
package/lib/index.d.ts CHANGED
@@ -525,7 +525,7 @@ declare function RadioGroup$1({ children, ...props }: Props$d): react_jsx_runtim
525
525
  /**
526
526
  * A single radio button and its label.
527
527
  */
528
- declare function Radio$1({ children, ...props }: AriaRadioProps): react_jsx_runtime.JSX.Element;
528
+ declare function Radio$2({ children, ...props }: AriaRadioProps): react_jsx_runtime.JSX.Element;
529
529
 
530
530
  type RadioGroupProps = PermafrostComponent$1 & {
531
531
  value?: string;
@@ -545,7 +545,7 @@ declare function RadioGroup(props: RadioGroupProps): react_jsx_runtime.JSX.Eleme
545
545
  * A single radio button and its label; no styling is applied, and the native
546
546
  * radio button is visually hidden.
547
547
  */
548
- declare function Radio(props: AriaRadioProps & {
548
+ declare function Radio$1(props: AriaRadioProps & {
549
549
  className?: string;
550
550
  isVisuallySelected?: (selectedValue: string) => void;
551
551
  }): react_jsx_runtime.JSX.Element;
@@ -922,4 +922,32 @@ type TableProps<T> = Omit<TableProps$1<T>, 'disabled' | 'progressPending' | 'dir
922
922
  };
923
923
  declare const Table: <T>(props: TableProps<T>) => react_jsx_runtime.JSX.Element;
924
924
 
925
- export { animation as ANIMATION, Radio as AbstractRadio, RadioGroup as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button, allColors as COLORS, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, GlobalStyles, Icon, IconButton, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RandomLoadingMessage, Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, typography as TYPOGRAPHY, Table, TextInput, TextTruncate, Toggle, Tooltip, color as colorUtils, number as numberUtils, string as stringUtils };
925
+ interface InputProps {
926
+ ref?: React$1.LegacyRef<HTMLInputElement>;
927
+ label: string;
928
+ name: string;
929
+ placeholder: string;
930
+ value: string;
931
+ onChange: (e: React$1.ChangeEvent<HTMLInputElement>) => void;
932
+ isRequired?: boolean;
933
+ isDisabled?: boolean;
934
+ errorList?: string[];
935
+ helpText?: string;
936
+ hasHiddenLabel?: boolean;
937
+ iconName?: IconName$1;
938
+ isClearable?: boolean;
939
+ }
940
+ declare const Input: ({ ref, label, name, placeholder, value, onChange, isRequired, isDisabled, errorList, helpText, iconName, hasHiddenLabel, isClearable, ...rest }: InputProps) => react_jsx_runtime.JSX.Element;
941
+
942
+ interface RadioProps {
943
+ ref?: React$1.LegacyRef<HTMLInputElement>;
944
+ id: string;
945
+ label: string;
946
+ name: string;
947
+ value?: string;
948
+ onChange: (e: React$1.ChangeEvent<HTMLInputElement>) => void;
949
+ isDisabled?: boolean;
950
+ }
951
+ declare const Radio: ({ ref, id, label, name, value, onChange, isDisabled, ...rest }: RadioProps) => react_jsx_runtime.JSX.Element;
952
+
953
+ export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button, allColors as COLORS, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, GlobalStyles, Icon, IconButton, Input, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio$2 as Radio, RadioGroup$1 as RadioGroup, Radio as RadioInput, RandomLoadingMessage, Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, typography as TYPOGRAPHY, Table, TextInput, TextTruncate, Toggle, Tooltip, color as colorUtils, number as numberUtils, string as stringUtils };
package/lib/index.esm.css CHANGED
@@ -965,6 +965,95 @@
965
965
  margin-bottom: var(--pf-margin-2);
966
966
  }
967
967
 
968
+ :root,
969
+ :root [data-theme=light],
970
+ :root [data-theme=dark] {
971
+ --pf-radio-background-color: var(--pf-white-color);
972
+ --pf-radio-check-color: var(--pf-primary-color);
973
+ --pf-radio-border-color: var(--pf-gray-color);
974
+ --pf-radio-disabled-color: var(--pf-gray-color-400);
975
+ }
976
+
977
+ :root [data-theme=dark] {
978
+ --pf-radio-background-color: transparent;
979
+ --pf-radio-check-color: var(--pf-white-color);
980
+ --pf-radio-border-color: var(--pf-white-color);
981
+ --pf-radio-disabled-color: var(--pf-gray-color-300);
982
+ }
983
+
984
+ .form-control .radio-wrapper {
985
+ display: flex;
986
+ margin-bottom: var(--pf-margin-2);
987
+ align-items: center;
988
+ }
989
+ .form-control .radio-input {
990
+ margin: 0;
991
+ margin-right: var(--pf-margin-2);
992
+ cursor: pointer;
993
+ }
994
+ .form-control .radio-input-label {
995
+ cursor: pointer;
996
+ }
997
+ .form-control [type=radio]:checked,
998
+ .form-control [type=radio]:not(:checked) {
999
+ position: absolute;
1000
+ left: -9999px;
1001
+ }
1002
+ .form-control [type=radio]:checked + label,
1003
+ .form-control [type=radio]:not(:checked) + label {
1004
+ position: relative;
1005
+ padding-left: var(--pf-padding-7);
1006
+ cursor: pointer;
1007
+ line-height: 20px;
1008
+ display: inline-block;
1009
+ }
1010
+ .form-control [type=radio]:checked + label:before,
1011
+ .form-control [type=radio]:not(:checked) + label:before {
1012
+ content: "";
1013
+ position: absolute;
1014
+ left: 0;
1015
+ top: 0;
1016
+ width: 18px;
1017
+ height: 18px;
1018
+ border: 1px solid var(--pf-radio-border-color);
1019
+ border-radius: 100%;
1020
+ background: var(--pf-radio-background-color);
1021
+ }
1022
+ .form-control [type=radio]:checked + label:after,
1023
+ .form-control [type=radio]:not(:checked) + label:after {
1024
+ content: "";
1025
+ width: 12px;
1026
+ height: 12px;
1027
+ background: var(--pf-radio-check-color);
1028
+ position: absolute;
1029
+ top: 4px;
1030
+ left: 4px;
1031
+ border-radius: 100%;
1032
+ transition: all 0.2s ease;
1033
+ }
1034
+ .form-control [type=radio]:not(:checked) + label:after {
1035
+ opacity: 0;
1036
+ transform: scale(0);
1037
+ }
1038
+ .form-control [type=radio]:checked + label:after {
1039
+ opacity: 1;
1040
+ transform: scale(1);
1041
+ }
1042
+ .form-control [type=radio]:disabled,
1043
+ .form-control [type=radio]:disabled + label {
1044
+ cursor: not-allowed;
1045
+ }
1046
+ .form-control [type=radio]:disabled + label {
1047
+ color: var(--pf-radio-disabled-color);
1048
+ opacity: 0.5;
1049
+ }
1050
+ .form-control [type=radio]:disabled + label:before {
1051
+ border-color: var(--pf-radio-disabled-color);
1052
+ }
1053
+ .form-control [type=radio]:disabled + label:after {
1054
+ background: var(--pf-radio-disabled-color);
1055
+ }
1056
+
968
1057
  :root {
969
1058
  --pf-font-family-base: "Mulish", sans-serif;
970
1059
  --pf-font-size-base: 1rem;
package/lib/index.esm.js CHANGED
@@ -18632,6 +18632,28 @@ const Table$1 = (props) => {
18632
18632
  return (jsx("div", { className: "table-wrapper", children: jsx(Xe, Object.assign({ responsive: responsive, direction: direction, subHeaderAlign: subHeaderAlign, keyField: keyField, striped: striped, className: `${striped ? 'pf__table--striped' : ''}`, disabled: isDisabled, noDataComponent: noDataComponent, progressPending: isLoading, progressComponent: jsx(LoadingComponent, {}) }, rest)) }));
18633
18633
  };
18634
18634
 
18635
+ const Label = ({ label, name, isRequired, hasHiddenLabel }) => {
18636
+ return (jsx("div", { "data-testid": `${name}-testId`, className: `form-label ${hasHiddenLabel ? 'is-visually-hidden' : ''}`, children: jsxs("label", { htmlFor: `${name}`, children: [label, isRequired ? jsx("span", { className: "text-error", children: " *" }) : ''] }) }));
18637
+ };
18638
+
18639
+ const ErrorList = ({ errorList, name }) => {
18640
+ return (jsx("ul", { className: "error-list", id: `${name}-helper`, children: (errorList !== null && errorList !== void 0 ? errorList : []).map((error, index) => (jsx("li", { children: error }, index))) }));
18641
+ };
18642
+
18643
+ const Input = (_a) => {
18644
+ var { ref, label, name, placeholder, value, onChange, isRequired, isDisabled, errorList, helpText, iconName, hasHiddenLabel, isClearable } = _a, rest = __rest$1(_a, ["ref", "label", "name", "placeholder", "value", "onChange", "isRequired", "isDisabled", "errorList", "helpText", "iconName", "hasHiddenLabel", "isClearable"]);
18645
+ const hasErrors = errorList && errorList.length > 0;
18646
+ const handleClear = () => {
18647
+ onChange({ target: { value: '' } });
18648
+ };
18649
+ return (jsxs("div", { className: "form-control", children: [jsx(Label, { label: label, name: name, isRequired: isRequired, hasHiddenLabel: hasHiddenLabel }), jsxs("div", { className: "input-wrapper", children: [iconName && (jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsx("input", Object.assign({ ref: ref, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled, required: isRequired, placeholder: placeholder, value: value, onChange: onChange, className: `input ${hasErrors ? 'error' : ''} ${iconName ? 'input--has-icon' : ''}`, "aria-invalid": hasErrors, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired, "aria-label": label }, rest)), isClearable && (jsx(Icon, { name: "x-close", "data-testid": `${name}-clearable-icon`, size: "sm", onClick: handleClear, className: "clearable-icon" }))] }), hasErrors && jsx(ErrorList, { errorList: errorList, name: name }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
18650
+ };
18651
+
18652
+ const Radio$2 = (_a) => {
18653
+ var { ref, id, label, name, value, onChange, isDisabled } = _a, rest = __rest$1(_a, ["ref", "id", "label", "name", "value", "onChange", "isDisabled"]);
18654
+ return (jsx("div", { className: "form-control", children: jsxs("div", { className: "radio-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-radio-input-${name}` }, rest, { className: "radio-input", type: "radio", id: id, name: name, value: value, disabled: isDisabled, ref: ref, onChange: onChange, tabIndex: 0, "aria-describedby": id, "aria-label": label })), jsx("label", { htmlFor: id, className: "radio-input-label", "data-testid": `label-radio-input-${name}`, children: label })] }) }));
18655
+ };
18656
+
18635
18657
  const StyledAccordion = styled.details `
18636
18658
  summary {
18637
18659
  display: inherit;
@@ -41453,5 +41475,5 @@ const Tooltip = (props) => {
41453
41475
  openOnClick: props.clickToShow, id: props.for, delayShow: props.delayShow, delayHide: props.delayHide, children: props.children })] }));
41454
41476
  };
41455
41477
 
41456
- export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$2 as Button, allColors as COLORS, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, GlobalStyles, Icon, IconButton, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio, RadioGroup, RandomLoadingMessage, Row$1 as Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, typography as TYPOGRAPHY, Table$1 as Table, TextInput, TextTruncate, Toggle, Tooltip, color as colorUtils, number as numberUtils, string as stringUtils };
41478
+ export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$2 as Button, allColors as COLORS, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, GlobalStyles, Icon, IconButton, Input, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PercentageRing, Radio, RadioGroup, Radio$2 as RadioInput, RandomLoadingMessage, Row$1 as Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, typography as TYPOGRAPHY, Table$1 as Table, TextInput, TextTruncate, Toggle, Tooltip, color as colorUtils, number as numberUtils, string as stringUtils };
41457
41479
  //# sourceMappingURL=index.esm.js.map