nurseitaly-components 0.0.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.
- package/README.md +93 -0
- package/dist/basic/Avatar/Avatar.d.ts +12 -0
- package/dist/basic/Avatar/Avatar.js +24 -0
- package/dist/basic/Avatar/avatar.png +0 -0
- package/dist/basic/Avatar/index.d.ts +2 -0
- package/dist/basic/Avatar/index.js +2 -0
- package/dist/basic/Avatar/styles.scss +80 -0
- package/dist/basic/Badge/Badge.d.ts +13 -0
- package/dist/basic/Badge/Badge.js +17 -0
- package/dist/basic/Badge/index.d.ts +2 -0
- package/dist/basic/Badge/index.js +2 -0
- package/dist/basic/Badge/styles.scss +68 -0
- package/dist/basic/Button/Button.d.ts +25 -0
- package/dist/basic/Button/Button.js +42 -0
- package/dist/basic/Button/index.d.ts +2 -0
- package/dist/basic/Button/index.js +2 -0
- package/dist/basic/Button/logo-ud.png +0 -0
- package/dist/basic/Button/styles.scss +248 -0
- package/dist/basic/CheckboxField/CheckboxField.d.ts +10 -0
- package/dist/basic/CheckboxField/CheckboxField.js +9 -0
- package/dist/basic/CheckboxField/index.d.ts +2 -0
- package/dist/basic/CheckboxField/index.js +2 -0
- package/dist/basic/CheckboxField/style.scss +4 -0
- package/dist/basic/DatePickerField/DatePickerField.d.ts +26 -0
- package/dist/basic/DatePickerField/DatePickerField.js +90 -0
- package/dist/basic/DatePickerField/DatePickerTheme.d.ts +2 -0
- package/dist/basic/DatePickerField/DatePickerTheme.js +59 -0
- package/dist/basic/DatePickerField/index.d.ts +1 -0
- package/dist/basic/DatePickerField/index.js +1 -0
- package/dist/basic/DatePickerField/styles.scss +26 -0
- package/dist/basic/DropdownButton/DropdownButton.d.ts +18 -0
- package/dist/basic/DropdownButton/DropdownButton.js +44 -0
- package/dist/basic/DropdownButton/index.d.ts +2 -0
- package/dist/basic/DropdownButton/index.js +2 -0
- package/dist/basic/DropdownButton/styles.scss +172 -0
- package/dist/basic/DropdownList/DropdownItemList.d.ts +16 -0
- package/dist/basic/DropdownList/DropdownItemList.js +17 -0
- package/dist/basic/DropdownList/DropdownList.d.ts +9 -0
- package/dist/basic/DropdownList/DropdownList.js +10 -0
- package/dist/basic/DropdownList/index.d.ts +2 -0
- package/dist/basic/DropdownList/index.js +2 -0
- package/dist/basic/DropdownList/styles.scss +56 -0
- package/dist/basic/DropdownMenu/DropdownMenu.d.ts +13 -0
- package/dist/basic/DropdownMenu/DropdownMenu.js +12 -0
- package/dist/basic/DropdownMenu/index.d.ts +2 -0
- package/dist/basic/DropdownMenu/index.js +2 -0
- package/dist/basic/DropdownMenu/styles.scss +54 -0
- package/dist/basic/Dummy/Dummy.d.ts +9 -0
- package/dist/basic/Dummy/Dummy.js +8 -0
- package/dist/basic/Dummy/index.d.ts +2 -0
- package/dist/basic/Dummy/index.js +2 -0
- package/dist/basic/Dummy/styles.scss +4 -0
- package/dist/basic/FilterDropdown/FilterDropdown.d.ts +16 -0
- package/dist/basic/FilterDropdown/FilterDropdown.js +56 -0
- package/dist/basic/FilterDropdown/index.d.ts +2 -0
- package/dist/basic/FilterDropdown/index.js +2 -0
- package/dist/basic/FilterDropdown/styles.scss +97 -0
- package/dist/basic/Icon/Icon.d.ts +15 -0
- package/dist/basic/Icon/Icon.js +20 -0
- package/dist/basic/Icon/IconSizes.d.ts +10 -0
- package/dist/basic/Icon/IconSizes.js +11 -0
- package/dist/basic/Icon/index.d.ts +2 -0
- package/dist/basic/Icon/index.js +2 -0
- package/dist/basic/Icon/styles.scss +249 -0
- package/dist/basic/IconButton/IconButton.d.ts +24 -0
- package/dist/basic/IconButton/IconButton.js +42 -0
- package/dist/basic/IconButton/index.d.ts +2 -0
- package/dist/basic/IconButton/index.js +2 -0
- package/dist/basic/IconButton/styles.scss +192 -0
- package/dist/basic/Pill/Pill.d.ts +17 -0
- package/dist/basic/Pill/Pill.js +22 -0
- package/dist/basic/Pill/index.d.ts +2 -0
- package/dist/basic/Pill/index.js +2 -0
- package/dist/basic/Pill/styles.scss +70 -0
- package/dist/basic/SelectField/AsyncSelectField.d.ts +21 -0
- package/dist/basic/SelectField/AsyncSelectField.js +131 -0
- package/dist/basic/SelectField/SelectAutocompleteTheme.d.ts +2 -0
- package/dist/basic/SelectField/SelectAutocompleteTheme.js +78 -0
- package/dist/basic/SelectField/SelectField.d.ts +27 -0
- package/dist/basic/SelectField/SelectField.js +81 -0
- package/dist/basic/SelectField/SelectFieldTheme.d.ts +7 -0
- package/dist/basic/SelectField/SelectFieldTheme.js +57 -0
- package/dist/basic/SelectField/SelectMultipleField.d.ts +28 -0
- package/dist/basic/SelectField/SelectMultipleField.js +98 -0
- package/dist/basic/SelectField/index.d.ts +2 -0
- package/dist/basic/SelectField/index.js +2 -0
- package/dist/basic/SelectField/styles.scss +38 -0
- package/dist/basic/Spinner/Spinner.d.ts +14 -0
- package/dist/basic/Spinner/Spinner.js +37 -0
- package/dist/basic/Spinner/index.d.ts +2 -0
- package/dist/basic/Spinner/index.js +2 -0
- package/dist/basic/Spinner/styles.scss +37 -0
- package/dist/basic/SwitchField/SwitchField.d.ts +11 -0
- package/dist/basic/SwitchField/SwitchField.js +13 -0
- package/dist/basic/SwitchField/index.d.ts +2 -0
- package/dist/basic/SwitchField/index.js +2 -0
- package/dist/basic/SwitchField/style.scss +4 -0
- package/dist/basic/Tabs/Tabs.d.ts +17 -0
- package/dist/basic/Tabs/Tabs.js +9 -0
- package/dist/basic/Tabs/index.d.ts +2 -0
- package/dist/basic/Tabs/index.js +2 -0
- package/dist/basic/Tabs/styles.scss +51 -0
- package/dist/basic/Tag/Tag.d.ts +18 -0
- package/dist/basic/Tag/Tag.js +30 -0
- package/dist/basic/Tag/index.d.ts +2 -0
- package/dist/basic/Tag/index.js +2 -0
- package/dist/basic/Tag/styles.scss +101 -0
- package/dist/basic/TextField/TextField.d.ts +34 -0
- package/dist/basic/TextField/TextField.js +164 -0
- package/dist/basic/TextField/TextFieldTheme.d.ts +6 -0
- package/dist/basic/TextField/TextFieldTheme.js +70 -0
- package/dist/basic/TextField/index.d.ts +2 -0
- package/dist/basic/TextField/index.js +2 -0
- package/dist/basic/TextField/inputRefManager.d.ts +4 -0
- package/dist/basic/TextField/inputRefManager.js +18 -0
- package/dist/basic/TextField/styles.scss +44 -0
- package/dist/basic/Tooltip/Tooltip.d.ts +26 -0
- package/dist/basic/Tooltip/Tooltip.js +37 -0
- package/dist/basic/Tooltip/index.d.ts +2 -0
- package/dist/basic/Tooltip/index.js +2 -0
- package/dist/basic/Tooltip/styles.scss +73 -0
- package/dist/basic/VerticalButton/VerticalButton.d.ts +6 -0
- package/dist/basic/VerticalButton/VerticalButton.js +8 -0
- package/dist/basic/VerticalButton/index.d.ts +2 -0
- package/dist/basic/VerticalButton/index.js +2 -0
- package/dist/basic/VerticalButton/styles.scss +24 -0
- package/dist/basic/fonts/material-symbols-outlined.woff2 +0 -0
- package/dist/basic/fonts/work-sans-latin-ext.woff2 +0 -0
- package/dist/basic/fonts/work-sans-latin.woff2 +0 -0
- package/dist/basic/fonts/work-sans-vietnamese.woff2 +0 -0
- package/dist/basic/fonts.d.ts +1 -0
- package/dist/basic/fonts.js +111 -0
- package/dist/basic/index.d.ts +33 -0
- package/dist/basic/index.js +29 -0
- package/dist/common/AppAnalytics/AppAnalytics.d.ts +1 -0
- package/dist/common/AppAnalytics/AppAnalytics.js +25 -0
- package/dist/common/AppAnalytics/index.d.ts +2 -0
- package/dist/common/AppAnalytics/index.js +2 -0
- package/dist/common/AppCard/AppCard.d.ts +13 -0
- package/dist/common/AppCard/AppCard.js +7 -0
- package/dist/common/AppCard/index.d.ts +2 -0
- package/dist/common/AppCard/index.js +2 -0
- package/dist/common/AppCard/style.scss +33 -0
- package/dist/common/AppClipboard/AppClipboard.d.ts +7 -0
- package/dist/common/AppClipboard/AppClipboard.js +23 -0
- package/dist/common/AppClipboard/index.d.ts +2 -0
- package/dist/common/AppClipboard/index.js +2 -0
- package/dist/common/AppColorpicker/AppColorpicker.d.ts +9 -0
- package/dist/common/AppColorpicker/AppColorpicker.js +22 -0
- package/dist/common/AppColorpicker/index.d.ts +2 -0
- package/dist/common/AppColorpicker/index.js +2 -0
- package/dist/common/AppColorpicker/style.scss +26 -0
- package/dist/common/AppCopyText/AppCopyText.d.ts +11 -0
- package/dist/common/AppCopyText/AppCopyText.js +35 -0
- package/dist/common/AppCopyText/index.d.ts +2 -0
- package/dist/common/AppCopyText/index.js +2 -0
- package/dist/common/AppCopyText/styles.scss +55 -0
- package/dist/common/AppDropzone/AppDropzone.d.ts +19 -0
- package/dist/common/AppDropzone/AppDropzone.js +13 -0
- package/dist/common/AppDropzone/AppDropzoneBody.d.ts +22 -0
- package/dist/common/AppDropzone/AppDropzoneBody.js +74 -0
- package/dist/common/AppDropzone/UploadService.d.ts +6 -0
- package/dist/common/AppDropzone/UploadService.js +18 -0
- package/dist/common/AppDropzone/UploadedFile.d.ts +14 -0
- package/dist/common/AppDropzone/UploadedFile.js +1 -0
- package/dist/common/AppDropzone/index.d.ts +4 -0
- package/dist/common/AppDropzone/index.js +4 -0
- package/dist/common/AppDropzone/style.scss +42 -0
- package/dist/common/AppDropzoneLocal/AppDropzoneBodyLocal.d.ts +15 -0
- package/dist/common/AppDropzoneLocal/AppDropzoneBodyLocal.js +55 -0
- package/dist/common/AppDropzoneLocal/AppDropzoneLocal.d.ts +15 -0
- package/dist/common/AppDropzoneLocal/AppDropzoneLocal.js +13 -0
- package/dist/common/AppDropzoneLocal/UploadedFileLocal.d.ts +5 -0
- package/dist/common/AppDropzoneLocal/UploadedFileLocal.js +1 -0
- package/dist/common/AppDropzoneLocal/index.d.ts +5 -0
- package/dist/common/AppDropzoneLocal/index.js +4 -0
- package/dist/common/AppDropzoneLocal/style.scss +75 -0
- package/dist/common/AppForm/AppForm.d.ts +16 -0
- package/dist/common/AppForm/AppForm.js +67 -0
- package/dist/common/AppForm/AppFormField.d.ts +37 -0
- package/dist/common/AppForm/AppFormField.js +10 -0
- package/dist/common/AppForm/AppFormInfo.d.ts +9 -0
- package/dist/common/AppForm/AppFormInfo.js +45 -0
- package/dist/common/AppForm/FormColorField.d.ts +12 -0
- package/dist/common/AppForm/FormColorField.js +23 -0
- package/dist/common/AppForm/index.d.ts +2 -0
- package/dist/common/AppForm/index.js +2 -0
- package/dist/common/AppForm/style.scss +60 -0
- package/dist/common/AppLoading/AppLoading.d.ts +7 -0
- package/dist/common/AppLoading/AppLoading.js +8 -0
- package/dist/common/AppLoading/index.d.ts +2 -0
- package/dist/common/AppLoading/index.js +2 -0
- package/dist/common/AppLoading/style.scss +5 -0
- package/dist/common/AppModal/AppModal.d.ts +27 -0
- package/dist/common/AppModal/AppModal.js +42 -0
- package/dist/common/AppModal/AppModalConfirm.d.ts +15 -0
- package/dist/common/AppModal/AppModalConfirm.js +37 -0
- package/dist/common/AppModal/AppModalRemove.d.ts +22 -0
- package/dist/common/AppModal/AppModalRemove.js +35 -0
- package/dist/common/AppModal/AppModalUtils.d.ts +2 -0
- package/dist/common/AppModal/AppModalUtils.js +17 -0
- package/dist/common/AppModal/index.d.ts +2 -0
- package/dist/common/AppModal/index.js +2 -0
- package/dist/common/AppModal/style.scss +100 -0
- package/dist/common/AppPagination/AppPagination.d.ts +12 -0
- package/dist/common/AppPagination/AppPagination.js +212 -0
- package/dist/common/AppPagination/index.d.ts +2 -0
- package/dist/common/AppPagination/index.js +2 -0
- package/dist/common/AppPagination/styles.scss +230 -0
- package/dist/common/AppPicture/AppPicture.d.ts +10 -0
- package/dist/common/AppPicture/AppPicture.js +18 -0
- package/dist/common/AppPicture/index.d.ts +2 -0
- package/dist/common/AppPicture/index.js +2 -0
- package/dist/common/AppPicture/style.scss +0 -0
- package/dist/common/AppPlaceholder/AppPlaceholder.d.ts +12 -0
- package/dist/common/AppPlaceholder/AppPlaceholder.js +7 -0
- package/dist/common/AppPlaceholder/index.d.ts +2 -0
- package/dist/common/AppPlaceholder/index.js +2 -0
- package/dist/common/AppPlaceholder/style.scss +25 -0
- package/dist/common/AppSwitchGroup/AppSwitchGroup.d.ts +12 -0
- package/dist/common/AppSwitchGroup/AppSwitchGroup.js +8 -0
- package/dist/common/AppSwitchGroup/index.d.ts +2 -0
- package/dist/common/AppSwitchGroup/index.js +2 -0
- package/dist/common/AppSwitchGroup/style.scss +18 -0
- package/dist/common/AppTable/AppTable.d.ts +19 -0
- package/dist/common/AppTable/AppTable.js +62 -0
- package/dist/common/AppTable/AppTableList.d.ts +14 -0
- package/dist/common/AppTable/AppTableList.js +48 -0
- package/dist/common/AppTable/AppTableTheme.d.ts +1 -0
- package/dist/common/AppTable/AppTableTheme.js +45 -0
- package/dist/common/AppTable/AppTableUtils.d.ts +8 -0
- package/dist/common/AppTable/AppTableUtils.js +24 -0
- package/dist/common/AppTable/index.d.ts +2 -0
- package/dist/common/AppTable/index.js +2 -0
- package/dist/common/AppTable/styles.scss +65 -0
- package/dist/common/AppTable/types/AppPage.d.ts +29 -0
- package/dist/common/AppTable/types/AppPage.js +18 -0
- package/dist/common/AppTable/types/AppPageable.d.ts +15 -0
- package/dist/common/AppTable/types/AppPageable.js +19 -0
- package/dist/common/AppTextArea/AppTextArea.d.ts +11 -0
- package/dist/common/AppTextArea/AppTextArea.js +29 -0
- package/dist/common/AppTextArea/index.d.ts +1 -0
- package/dist/common/AppTextArea/index.js +1 -0
- package/dist/common/AppTextArea/style.scss +47 -0
- package/dist/common/AppToast/AppToast.d.ts +2 -0
- package/dist/common/AppToast/AppToast.js +81 -0
- package/dist/common/AppToast/ToastMessage.d.ts +8 -0
- package/dist/common/AppToast/ToastMessage.js +4 -0
- package/dist/common/AppToast/index.d.ts +2 -0
- package/dist/common/AppToast/index.js +2 -0
- package/dist/common/AppToast/style.scss +0 -0
- package/dist/common/index.d.ts +27 -0
- package/dist/common/index.js +23 -0
- package/dist/configs/CommonContext.d.ts +10 -0
- package/dist/configs/CommonContext.js +9 -0
- package/dist/configs/CookieStorage.d.ts +15 -0
- package/dist/configs/CookieStorage.js +45 -0
- package/dist/configs/Localization.d.ts +28 -0
- package/dist/configs/Localization.js +63 -0
- package/dist/configs/Storage.d.ts +9 -0
- package/dist/configs/Storage.js +16 -0
- package/dist/configs/api.d.ts +10 -0
- package/dist/configs/api.js +52 -0
- package/dist/configs/index.d.ts +8 -0
- package/dist/configs/index.js +7 -0
- package/dist/configs/localization/BaseTexts.d.ts +44 -0
- package/dist/configs/localization/BaseTexts.js +44 -0
- package/dist/configs/localization/CommentsTexts.d.ts +95 -0
- package/dist/configs/localization/CommentsTexts.js +95 -0
- package/dist/configs/localization/CommonTexts.d.ts +239 -0
- package/dist/configs/localization/CommonTexts.js +239 -0
- package/dist/configs/localization/ConsentTexts.d.ts +116 -0
- package/dist/configs/localization/ConsentTexts.js +203 -0
- package/dist/configs/localization/HeaderAppTexts.d.ts +106 -0
- package/dist/configs/localization/HeaderAppTexts.js +106 -0
- package/dist/configs/localization/HeaderTexts.d.ts +68 -0
- package/dist/configs/localization/HeaderTexts.js +68 -0
- package/dist/configs/localization/HelpTexts.d.ts +38 -0
- package/dist/configs/localization/HelpTexts.js +38 -0
- package/dist/configs/localization/HistoryTexts.d.ts +428 -0
- package/dist/configs/localization/HistoryTexts.js +428 -0
- package/dist/configs/localization/ParametersTexts.d.ts +137 -0
- package/dist/configs/localization/ParametersTexts.js +137 -0
- package/dist/configs/localization/SentenceTexts.d.ts +56 -0
- package/dist/configs/localization/SentenceTexts.js +56 -0
- package/dist/configs/localization/TreeTexts.d.ts +46 -0
- package/dist/configs/localization/TreeTexts.js +46 -0
- package/dist/configs/localization/UploadTexts.d.ts +23 -0
- package/dist/configs/localization/UploadTexts.js +23 -0
- package/dist/configs/services/ProfileService.d.ts +5 -0
- package/dist/configs/services/ProfileService.js +8 -0
- package/dist/configs/sessionTypes.d.ts +42 -0
- package/dist/configs/sessionTypes.js +63 -0
- package/dist/configs/useLoggedUtils.d.ts +7 -0
- package/dist/configs/useLoggedUtils.js +24 -0
- package/dist/configs/useMessageUtils.d.ts +22 -0
- package/dist/configs/useMessageUtils.js +71 -0
- package/dist/fonts/material-symbols-outlined.woff2 +0 -0
- package/dist/fonts/work-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/work-sans-latin.woff2 +0 -0
- package/dist/fonts/work-sans-vietnamese.woff2 +0 -0
- package/dist/functions/DateUtils.d.ts +15 -0
- package/dist/functions/DateUtils.js +52 -0
- package/dist/functions/FilterUtils.d.ts +13 -0
- package/dist/functions/FilterUtils.js +56 -0
- package/dist/functions/FormUtils.d.ts +13 -0
- package/dist/functions/FormUtils.js +58 -0
- package/dist/functions/ImageUtils.d.ts +5 -0
- package/dist/functions/ImageUtils.js +13 -0
- package/dist/functions/SecurityUtils.d.ts +6 -0
- package/dist/functions/SecurityUtils.js +28 -0
- package/dist/functions/UsabilityUtils.d.ts +10 -0
- package/dist/functions/UsabilityUtils.js +47 -0
- package/dist/functions/index.d.ts +6 -0
- package/dist/functions/index.js +6 -0
- package/dist/functions/logo-ud.png +0 -0
- package/dist/functions/placeholder-image.png +0 -0
- package/dist/functions/placeholder-person.png +0 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/styles/base/_borders.scss +30 -0
- package/dist/styles/base/_colors.scss +100 -0
- package/dist/styles/base/_displays.scss +207 -0
- package/dist/styles/base/_margins.css +174 -0
- package/dist/styles/base/_spacing.scss +26 -0
- package/dist/styles/base/_tokens.scss +330 -0
- package/dist/styles/base/_typographs.scss +376 -0
- package/dist/styles/font-googleapis.scss +222 -0
- package/dist/styles/main.scss +112 -0
- package/dist/vendor/index.d.ts +5 -0
- package/dist/vendor/index.js +4 -0
- package/package.json +118 -0
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./style.scss";
|
|
2
|
+
type Props = {
|
|
3
|
+
icon?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
desc?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
useMarginTop?: boolean;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
export default function AppPlaceholder({ text, desc, children, icon, useMarginTop, onClick, className, }: Props): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import { Icon } from '../../basic';
|
|
4
|
+
import "./style.scss";
|
|
5
|
+
export default function AppPlaceholder({ text, desc, children, icon = "contract_delete", useMarginTop = false, onClick, className, }) {
|
|
6
|
+
return (_jsxs("div", { className: cx("ds-placeholder", { "with-margin-top": useMarginTop }, className), onClick: () => onClick && onClick(), onKeyDown: () => onClick && onClick(), children: [_jsx(Icon, { name: icon, weight: "heavy", size: "x-large", filled: true }), text && _jsx("span", { className: "title", children: text }), desc && _jsx("span", { className: "desc", children: desc }), children && children] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.ds-placeholder {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
text-align: center;
|
|
5
|
+
|
|
6
|
+
&.with-margin-top {
|
|
7
|
+
margin-top: 5%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
> .ds-icon {
|
|
11
|
+
color: var(--icon-on-disabled);
|
|
12
|
+
margin-bottom: 8px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
> .title {
|
|
16
|
+
@include label-large-2;
|
|
17
|
+
color: var(--text-primary);
|
|
18
|
+
margin-bottom: 4px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
> .desc {
|
|
22
|
+
@include label-medium-1;
|
|
23
|
+
color: var(--text-secondary);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { AppFormField } from '../AppForm/AppFormField';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
type Props<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> = {
|
|
5
|
+
fields: AppFormField[];
|
|
6
|
+
form: UseFormReturn<TFieldValues, TContext, TTransformedValues>;
|
|
7
|
+
onToggle: (attr: string, value: boolean) => void;
|
|
8
|
+
hasRole?: (role: string) => boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
export default function AppSwitchGroup<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>({ fields, form, onToggle, hasRole, className, }: Props<TFieldValues, TContext, TTransformedValues>): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, SwitchField, Tooltip } from '../../basic';
|
|
3
|
+
import FormUtils from '../../functions/FormUtils';
|
|
4
|
+
import './style.scss';
|
|
5
|
+
export default function AppSwitchGroup({ fields, form, onToggle, hasRole = () => true, className, }) {
|
|
6
|
+
const visibleFields = FormUtils.filterFieldsByUserRole(fields, hasRole).filter((field) => field.type === 'switch');
|
|
7
|
+
return (_jsx("div", { className: `app-switch-group-container ${className || ''}`, children: visibleFields.map((field) => (_jsxs("div", { className: "app-switch-group-row", children: [_jsx(SwitchField, { attr: field.attr, label: field.name, createdForm: form, disabled: field.disabled, onChange: (value) => onToggle(field.attr, value) }), field.tooltip && field.tooltipText && (_jsx(Tooltip, { title: field.tooltipText, children: _jsx("span", { className: "app-switch-group-tooltip", children: _jsx(Icon, { name: "help", size: "x-small" }) }) }))] }, field.attr))) }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.app-switch-group-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--spacing-200);
|
|
5
|
+
|
|
6
|
+
.app-switch-group-row {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: var(--spacing-100);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.app-switch-group-tooltip {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
color: var(--icon-secondary);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PaginationState, SortingState } from '@tanstack/react-table';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
import { AppPage } from './types/AppPage';
|
|
4
|
+
type Props = {
|
|
5
|
+
columns: any;
|
|
6
|
+
data: AppPage<any>;
|
|
7
|
+
pagination: PaginationState;
|
|
8
|
+
setPagination: (p: PaginationState) => void;
|
|
9
|
+
sorting: SortingState;
|
|
10
|
+
setSorting: (s: SortingState) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
onClickRow?: (row: any, col: any) => void;
|
|
13
|
+
onMouseEnter?: (row: any) => void;
|
|
14
|
+
onMouseLeave?: (row: any) => void;
|
|
15
|
+
hiddenColumns?: string[];
|
|
16
|
+
numItens?: number[];
|
|
17
|
+
};
|
|
18
|
+
export default function AppTable({ columns, data, pagination, setPagination, sorting, setSorting, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, numItens, }: Props): import("react").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeProvider } from '@emotion/react';
|
|
3
|
+
import Table from '@mui/material/Table';
|
|
4
|
+
import TableBody from '@mui/material/TableBody';
|
|
5
|
+
import TableCell from '@mui/material/TableCell';
|
|
6
|
+
import TableContainer from '@mui/material/TableContainer';
|
|
7
|
+
import TableHead from '@mui/material/TableHead';
|
|
8
|
+
import TableRow from '@mui/material/TableRow';
|
|
9
|
+
import { flexRender, getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
import AppPagination from '../AppPagination';
|
|
12
|
+
import { tableTheme } from './AppTableTheme';
|
|
13
|
+
import './styles.scss';
|
|
14
|
+
export default function AppTable({ columns, data, pagination, setPagination, sorting, setSorting, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, numItens, }) {
|
|
15
|
+
const { content, totalPages, totalElements } = data;
|
|
16
|
+
const columnVisibility = hiddenColumns?.reduce((acc, col) => {
|
|
17
|
+
acc[col] = false;
|
|
18
|
+
return acc;
|
|
19
|
+
}, {});
|
|
20
|
+
const table = useReactTable({
|
|
21
|
+
data: content || [],
|
|
22
|
+
columns,
|
|
23
|
+
pageCount: totalPages,
|
|
24
|
+
state: {
|
|
25
|
+
pagination,
|
|
26
|
+
sorting,
|
|
27
|
+
columnVisibility,
|
|
28
|
+
},
|
|
29
|
+
manualPagination: true,
|
|
30
|
+
getCoreRowModel: getCoreRowModel(),
|
|
31
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
32
|
+
getSortedRowModel: getSortedRowModel(),
|
|
33
|
+
onSortingChange: (updaterOrValue) => {
|
|
34
|
+
const newSorting = typeof updaterOrValue === 'function'
|
|
35
|
+
? updaterOrValue(sorting)
|
|
36
|
+
: updaterOrValue;
|
|
37
|
+
if (newSorting &&
|
|
38
|
+
sorting &&
|
|
39
|
+
JSON.stringify(newSorting) !== JSON.stringify(sorting)) {
|
|
40
|
+
setSorting(newSorting);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const tableClass = cx('ds-table', {
|
|
45
|
+
[className || '']: className || '',
|
|
46
|
+
});
|
|
47
|
+
return (_jsx(ThemeProvider, { theme: tableTheme, children: _jsxs("div", { className: tableClass, children: [_jsx(TableContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header) => {
|
|
48
|
+
const toggleSortingHandler = header.column.getToggleSortingHandler();
|
|
49
|
+
return (_jsxs(TableCell, { onClick: (event) => {
|
|
50
|
+
if (toggleSortingHandler) {
|
|
51
|
+
toggleSortingHandler(event);
|
|
52
|
+
}
|
|
53
|
+
}, style: {
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
width: `${header.column.columnDef.size}%`,
|
|
56
|
+
}, children: [flexRender(header.column.columnDef.header, header.getContext()), header.column.getIsSorted()
|
|
57
|
+
? header.column.getIsSorted() === 'desc'
|
|
58
|
+
? ' 🔽'
|
|
59
|
+
: ' 🔼'
|
|
60
|
+
: null] }, header.id));
|
|
61
|
+
}) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row) => (_jsx(TableRow, { onMouseEnter: () => onMouseEnter && onMouseEnter(row), onMouseLeave: () => onMouseLeave && onMouseLeave(row), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { onClick: () => onClickRow && onClickRow(row.original, cell.column), className: cell.id.includes('__') ? cell.id.split('__')[1] : '', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }), _jsx(AppPagination, { totalElements: totalElements, pagination: pagination, setPagination: setPagination, numItens: numItens })] }) }));
|
|
62
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
type Props = {
|
|
4
|
+
columns: ColumnDef<any, any>[];
|
|
5
|
+
data: any[];
|
|
6
|
+
className?: string;
|
|
7
|
+
onClickRow?: (row: any) => void;
|
|
8
|
+
onMouseEnter?: (row: any) => void;
|
|
9
|
+
onMouseLeave?: (row: any) => void;
|
|
10
|
+
hiddenColumns?: string[];
|
|
11
|
+
filter?: [string, string];
|
|
12
|
+
};
|
|
13
|
+
export default function AppTableList({ columns, data, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, filter, }: Props): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { ThemeProvider } from '@emotion/react';
|
|
4
|
+
import Table from '@mui/material/Table';
|
|
5
|
+
import TableBody from '@mui/material/TableBody';
|
|
6
|
+
import TableCell from '@mui/material/TableCell';
|
|
7
|
+
import TableContainer from '@mui/material/TableContainer';
|
|
8
|
+
import TableHead from '@mui/material/TableHead';
|
|
9
|
+
import TableRow from '@mui/material/TableRow';
|
|
10
|
+
import { flexRender, getCoreRowModel, getFilteredRowModel, useReactTable, } from '@tanstack/react-table';
|
|
11
|
+
import { tableTheme } from './AppTableTheme';
|
|
12
|
+
import './styles.scss';
|
|
13
|
+
import { useEffect } from 'react';
|
|
14
|
+
export default function AppTableList({ columns, data, className = '', onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, filter, }) {
|
|
15
|
+
const columnVisibility = hiddenColumns?.reduce((acc, key) => {
|
|
16
|
+
acc[key] = false;
|
|
17
|
+
return acc;
|
|
18
|
+
}, {});
|
|
19
|
+
const table = useReactTable({
|
|
20
|
+
data,
|
|
21
|
+
columns,
|
|
22
|
+
state: {
|
|
23
|
+
columnVisibility,
|
|
24
|
+
},
|
|
25
|
+
getCoreRowModel: getCoreRowModel(),
|
|
26
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
27
|
+
});
|
|
28
|
+
const handleClickRow = (row) => {
|
|
29
|
+
if (onClickRow)
|
|
30
|
+
onClickRow(row.original);
|
|
31
|
+
};
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!filter)
|
|
34
|
+
return;
|
|
35
|
+
if (filter[1]) {
|
|
36
|
+
table.getColumn(filter[0])?.setFilterValue(filter[1]);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
table.getColumn(filter[0])?.setFilterValue(undefined);
|
|
40
|
+
}
|
|
41
|
+
}, [filter]);
|
|
42
|
+
const tableClass = cx('ds-table', {
|
|
43
|
+
[className || '']: className || '',
|
|
44
|
+
});
|
|
45
|
+
return (_jsx(ThemeProvider, { theme: tableTheme, children: _jsx("div", { className: tableClass, children: _jsx(TableContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header) => (_jsx(TableCell, { style: { width: header.getSize() }, children: header.isPlaceholder
|
|
46
|
+
? null
|
|
47
|
+
: flexRender(header.column.columnDef.header, header.getContext()) }, header.id))) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row) => (_jsx(TableRow, { onClick: () => handleClickRow(row), onMouseEnter: () => onMouseEnter?.(row), onMouseLeave: () => onMouseLeave?.(row), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }) }) }));
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tableTheme: (outerTheme: any) => import("@mui/material/styles").Theme;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createTheme } from '@mui/material/styles';
|
|
2
|
+
export const tableTheme = (outerTheme) => createTheme({
|
|
3
|
+
...outerTheme,
|
|
4
|
+
components: {
|
|
5
|
+
MuiPaper: {
|
|
6
|
+
styleOverrides: {
|
|
7
|
+
root: {
|
|
8
|
+
borderRadius: '4px',
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
boxShadow: 'none',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
MuiTable: {
|
|
15
|
+
styleOverrides: {
|
|
16
|
+
root: {
|
|
17
|
+
minWidth: 'unset',
|
|
18
|
+
border: 0,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
MuiTableCell: {
|
|
23
|
+
styleOverrides: {
|
|
24
|
+
head: {
|
|
25
|
+
backgroundColor: '#F9FAFB',
|
|
26
|
+
fontWeight: 'bold',
|
|
27
|
+
padding: '4px 0px 4px 12px',
|
|
28
|
+
height: '48px',
|
|
29
|
+
},
|
|
30
|
+
body: {
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
padding: '4px 0px 4px 12px',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
MuiTablePagination: {
|
|
37
|
+
styleOverrides: {
|
|
38
|
+
root: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
justifyContent: 'flex-end',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const AppTableUtils: {
|
|
2
|
+
limitCharacters: (attr: string, props: any, max: number) => any;
|
|
3
|
+
addCenteredHeader: (header: string) => import("react").JSX.Element;
|
|
4
|
+
addCenteredCell: (attr: string, props: any) => import("react").JSX.Element;
|
|
5
|
+
addEnumBadge: (attr: string, props: any, append: string, t: any) => import("react").JSX.Element;
|
|
6
|
+
addSimpleCell: (value: any) => import("react").JSX.Element;
|
|
7
|
+
};
|
|
8
|
+
export default AppTableUtils;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const limitCharacters = (attr, props, max) => {
|
|
3
|
+
const value = props.row.original[attr];
|
|
4
|
+
if (!value)
|
|
5
|
+
return '';
|
|
6
|
+
return value.length > max ? `${value.substr(0, max)}...` : value;
|
|
7
|
+
};
|
|
8
|
+
const addCenteredHeader = (header) => (_jsx("div", { className: "text-center", children: header }));
|
|
9
|
+
const addCenteredCell = (attr, props) => (_jsx("div", { className: "text-center", children: props.row.original[attr] }));
|
|
10
|
+
const addEnumBadge = (attr, props, append, t) => {
|
|
11
|
+
const value = props[attr].toLowerCase();
|
|
12
|
+
return (_jsx("span", { className: `badge badge-enum ${attr}-${value}`, children: t(`${append}${value}`) }));
|
|
13
|
+
};
|
|
14
|
+
const addSimpleCell = (value) => {
|
|
15
|
+
return _jsx("div", { className: "text-center", children: value });
|
|
16
|
+
};
|
|
17
|
+
const AppTableUtils = {
|
|
18
|
+
limitCharacters,
|
|
19
|
+
addCenteredHeader,
|
|
20
|
+
addCenteredCell,
|
|
21
|
+
addEnumBadge,
|
|
22
|
+
addSimpleCell,
|
|
23
|
+
};
|
|
24
|
+
export default AppTableUtils;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.ds-table {
|
|
2
|
+
height: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
border: 1px solid var(--border-subtle-2);
|
|
6
|
+
background-color: var(--background-default);
|
|
7
|
+
|
|
8
|
+
.MuiTableContainer-root {
|
|
9
|
+
height: 100%;
|
|
10
|
+
flex: 1;
|
|
11
|
+
overflow: auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.MuiTableCell-root {
|
|
15
|
+
height: 46px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.MuiTableRow-root {
|
|
19
|
+
height: 46px;
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
background-color: var(--layer-hover-1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.text-center {
|
|
26
|
+
text-align: center;
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.MuiTableBody-root {
|
|
33
|
+
&.MuiTableRow-head {
|
|
34
|
+
.MuiTableCell-head {
|
|
35
|
+
@include tag-medium-2;
|
|
36
|
+
color: var(--text-primary);
|
|
37
|
+
font-family: "Lora";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.MuiTableCell-body {
|
|
42
|
+
@include label-medium-1;
|
|
43
|
+
color: var(--text-primary);
|
|
44
|
+
font-family: "Work Sans";
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.table-striped tbody tr:nth-of-type(odd) {
|
|
51
|
+
background-color: var(--layer-hover-1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.td-icons {
|
|
55
|
+
display: flex;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media (max-width: 768px) {
|
|
60
|
+
.ds-table {
|
|
61
|
+
.MuiTableContainer-root {
|
|
62
|
+
width: 100vw;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type AppPage<Type> = {
|
|
2
|
+
content: Type[];
|
|
3
|
+
totalElements: number;
|
|
4
|
+
totalPages: number;
|
|
5
|
+
number: number;
|
|
6
|
+
size: number;
|
|
7
|
+
seed: number;
|
|
8
|
+
executionTime?: number;
|
|
9
|
+
totalHits?: number;
|
|
10
|
+
uid?: string;
|
|
11
|
+
empty?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const EMPTY_PAGE: {
|
|
14
|
+
content: never[];
|
|
15
|
+
totalElements: number;
|
|
16
|
+
totalPages: number;
|
|
17
|
+
number: number;
|
|
18
|
+
size: number;
|
|
19
|
+
seed: number;
|
|
20
|
+
};
|
|
21
|
+
export declare const EMPTY_GRID_PAGE: {
|
|
22
|
+
content: never[];
|
|
23
|
+
totalElements: number;
|
|
24
|
+
totalPages: number;
|
|
25
|
+
number: number;
|
|
26
|
+
size: number;
|
|
27
|
+
seed: number;
|
|
28
|
+
};
|
|
29
|
+
export declare const isPageEmpty: <T>(data: AppPage<T> | undefined) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EMPTY_GRID_PAGEABLE, EMPTY_PAGEABLE } from "./AppPageable";
|
|
2
|
+
export const EMPTY_PAGE = {
|
|
3
|
+
content: [],
|
|
4
|
+
totalElements: 0,
|
|
5
|
+
totalPages: 0,
|
|
6
|
+
number: 0,
|
|
7
|
+
size: EMPTY_PAGEABLE.size,
|
|
8
|
+
seed: 0,
|
|
9
|
+
};
|
|
10
|
+
export const EMPTY_GRID_PAGE = {
|
|
11
|
+
content: [],
|
|
12
|
+
totalElements: 0,
|
|
13
|
+
totalPages: 0,
|
|
14
|
+
number: 0,
|
|
15
|
+
size: EMPTY_GRID_PAGEABLE.size,
|
|
16
|
+
seed: 0,
|
|
17
|
+
};
|
|
18
|
+
export const isPageEmpty = (data) => !data || !data.content || data.content.length === 0;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SortingState } from '@tanstack/react-table';
|
|
2
|
+
export type AppPageable = {
|
|
3
|
+
page: number;
|
|
4
|
+
size: number;
|
|
5
|
+
seed?: number;
|
|
6
|
+
sort?: SortingState;
|
|
7
|
+
};
|
|
8
|
+
export declare const EMPTY_PAGEABLE: AppPageable;
|
|
9
|
+
export declare const EMPTY_GRID_PAGEABLE: AppPageable;
|
|
10
|
+
export declare function convertPageable(pageable: AppPageable): {
|
|
11
|
+
sort: string;
|
|
12
|
+
page: number;
|
|
13
|
+
size: number;
|
|
14
|
+
seed?: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const EMPTY_PAGEABLE = {
|
|
2
|
+
page: 0,
|
|
3
|
+
size: 10,
|
|
4
|
+
seed: 1,
|
|
5
|
+
};
|
|
6
|
+
export const EMPTY_GRID_PAGEABLE = {
|
|
7
|
+
page: 0,
|
|
8
|
+
size: 12,
|
|
9
|
+
seed: 1,
|
|
10
|
+
};
|
|
11
|
+
export function convertPageable(pageable) {
|
|
12
|
+
const sort = [];
|
|
13
|
+
if (pageable.sort) {
|
|
14
|
+
pageable.sort.forEach((item, index) => {
|
|
15
|
+
sort.push(`${item.id},${item.desc ? 'desc' : 'asc'}`);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return { ...pageable, sort: sort.join(',') };
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type TextareaHTMLAttributes } from 'react';
|
|
2
|
+
import './style.scss';
|
|
3
|
+
export type AppTextAreaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
4
|
+
showLineNumbers?: boolean;
|
|
5
|
+
containerClassName?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const AppTextArea: import("react").ForwardRefExoticComponent<TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
8
|
+
showLineNumbers?: boolean;
|
|
9
|
+
containerClassName?: string;
|
|
10
|
+
} & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
11
|
+
export default AppTextArea;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { forwardRef, useCallback, useRef, } from 'react';
|
|
4
|
+
import './style.scss';
|
|
5
|
+
const AppTextArea = forwardRef(function AppTextArea({ showLineNumbers = false, containerClassName, className, value, defaultValue, onScroll, ...rest }, ref) {
|
|
6
|
+
const gutterRef = useRef(null);
|
|
7
|
+
const setTextareaRef = useCallback((node) => {
|
|
8
|
+
if (typeof ref === 'function') {
|
|
9
|
+
ref(node);
|
|
10
|
+
}
|
|
11
|
+
else if (ref) {
|
|
12
|
+
ref.current = node;
|
|
13
|
+
}
|
|
14
|
+
}, [ref]);
|
|
15
|
+
const textValue = value !== undefined
|
|
16
|
+
? String(value)
|
|
17
|
+
: defaultValue !== undefined
|
|
18
|
+
? String(defaultValue)
|
|
19
|
+
: '';
|
|
20
|
+
const lines = Math.max(textValue.split('\n').length, 1);
|
|
21
|
+
const handleScroll = (e) => {
|
|
22
|
+
if (gutterRef.current) {
|
|
23
|
+
gutterRef.current.scrollTop = e.currentTarget.scrollTop;
|
|
24
|
+
}
|
|
25
|
+
onScroll?.(e);
|
|
26
|
+
};
|
|
27
|
+
return (_jsxs("div", { className: cx('app-text-area', { 'app-text-area--numbered': showLineNumbers }, containerClassName), children: [showLineNumbers && (_jsx("div", { className: "app-text-area__gutter", "aria-hidden": true, ref: gutterRef, children: Array.from({ length: lines }, (_, i) => (_jsx("div", { children: i + 1 }, i))) })), _jsx("textarea", { ref: setTextareaRef, className: cx('app-text-area__input', className), value: value, defaultValue: defaultValue, onScroll: handleScroll, ...rest })] }));
|
|
28
|
+
});
|
|
29
|
+
export default AppTextArea;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type AppTextAreaProps } from './AppTextArea';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './AppTextArea';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.app-text-area {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
|
|
7
|
+
&__input {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
display: block;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: var(--spacing-200);
|
|
14
|
+
border: 0;
|
|
15
|
+
outline: 0;
|
|
16
|
+
resize: none;
|
|
17
|
+
background: transparent;
|
|
18
|
+
@include body-medium-1;
|
|
19
|
+
font-family: var(--font-family);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&--numbered {
|
|
23
|
+
font-family: monospace;
|
|
24
|
+
|
|
25
|
+
.app-text-area__gutter,
|
|
26
|
+
.app-text-area__input {
|
|
27
|
+
@include body-medium-1;
|
|
28
|
+
font-family: monospace;
|
|
29
|
+
line-height: 150%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.app-text-area__gutter {
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
padding: var(--spacing-200);
|
|
36
|
+
background-color: var(--layer-hover-2);
|
|
37
|
+
text-align: right;
|
|
38
|
+
user-select: none;
|
|
39
|
+
color: var(--text-secondary);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.app-text-area__input {
|
|
43
|
+
flex: 1;
|
|
44
|
+
min-width: 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|