@talxis/base-controls 1.2406.2 → 1.2406.3
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/examples/Currency/package.json +1 -1
- package/examples/DateTime/package.json +1 -1
- package/examples/Decimal/package.json +1 -1
- package/examples/Duration/package.json +1 -1
- package/examples/Grid/package.json +1 -1
- package/examples/Lookup/package.json +1 -1
- package/examples/MultiSelectOptionSet/package.json +1 -1
- package/examples/OptionSet/package.json +1 -1
- package/examples/TwoOptions/package.json +1 -1
- package/package.json +1 -1
- package/.env +0 -1
- package/.eslintrc +0 -117
- package/.npmgitignore +0 -9
- package/.vscode/settings.json +0 -3
- package/.yalcignore +0 -2
- package/azure-pipelines.yml +0 -44
- package/examples/Currency/package-lock.json +0 -15900
- package/examples/Currency/tsconfig.json +0 -7
- package/examples/DateTime/package-lock.json +0 -15900
- package/examples/DateTime/tsconfig.json +0 -7
- package/examples/Decimal/package-lock.json +0 -15900
- package/examples/Decimal/tsconfig.json +0 -7
- package/examples/Duration/package-lock.json +0 -15900
- package/examples/Duration/tsconfig.json +0 -7
- package/examples/Grid/package-lock.json +0 -15901
- package/examples/Grid/tsconfig.json +0 -7
- package/examples/Lookup/package-lock.json +0 -15900
- package/examples/Lookup/tsconfig.json +0 -8
- package/examples/MultiSelectOptionSet/package-lock.json +0 -15900
- package/examples/MultiSelectOptionSet/tsconfig.json +0 -7
- package/examples/OptionSet/package-lock.json +0 -15900
- package/examples/OptionSet/tsconfig.json +0 -7
- package/examples/TwoOptions/package-lock.json +0 -15900
- package/examples/TwoOptions/tsconfig.json +0 -7
- package/public/index.html +0 -43
- package/public/manifest.json +0 -25
- package/rollup.config.js +0 -44
- package/src/components/DateTime/DateTime.tsx +0 -97
- package/src/components/DateTime/components/Calendar.tsx +0 -80
- package/src/components/DateTime/hooks/useDateTime.ts +0 -144
- package/src/components/DateTime/index.ts +0 -2
- package/src/components/DateTime/interfaces.ts +0 -22
- package/src/components/DateTime/styles.ts +0 -37
- package/src/components/DateTime/translations.ts +0 -18
- package/src/components/Decimal/Decimal.tsx +0 -120
- package/src/components/Decimal/index.ts +0 -2
- package/src/components/Decimal/interfaces.ts +0 -20
- package/src/components/Duration/Duration.tsx +0 -143
- package/src/components/Duration/index.ts +0 -2
- package/src/components/Duration/interfaces.ts +0 -22
- package/src/components/Duration/translations.ts +0 -30
- package/src/components/Grid/Grid.tsx +0 -24
- package/src/components/Grid/core/components/AgGrid/AgGrid.tsx +0 -206
- package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/EmptyRecords.tsx +0 -16
- package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/styles.ts +0 -20
- package/src/components/Grid/core/components/AgGrid/components/LoadingOverlay/LoadingOverlay.tsx +0 -7
- package/src/components/Grid/core/components/AgGrid/controllers/useAgGridController.ts +0 -68
- package/src/components/Grid/core/components/AgGrid/model/AgGrid.ts +0 -100
- package/src/components/Grid/core/components/AgGrid/styles.ts +0 -72
- package/src/components/Grid/core/components/Cell/Commands/Commands.tsx +0 -32
- package/src/components/Grid/core/components/Cell/Commands/Icon.tsx +0 -17
- package/src/components/Grid/core/components/Cell/Commands/styles.ts +0 -21
- package/src/components/Grid/core/components/Cell/Commands/useCommands.tsx +0 -53
- package/src/components/Grid/core/components/Cell/EditableCell/EditableCell.tsx +0 -140
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.tsx +0 -176
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.tsx +0 -67
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.ts +0 -24
- package/src/components/Grid/core/components/Cell/ReadOnlyCell/styles.ts +0 -56
- package/src/components/Grid/core/components/ColumnHeader/ColumnHeader.tsx +0 -71
- package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.tsx +0 -31
- package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.ts +0 -16
- package/src/components/Grid/core/components/ColumnHeader/styles.ts +0 -40
- package/src/components/Grid/core/components/Component/Component.tsx +0 -59
- package/src/components/Grid/core/components/Component/controller/useComponentController.ts +0 -39
- package/src/components/Grid/core/components/Component/model/Component.ts +0 -251
- package/src/components/Grid/core/components/Dialog/Constants.tsx +0 -8
- package/src/components/Grid/core/components/Dialog/Styles.tsx +0 -61
- package/src/components/Grid/core/components/Dialog/index.tsx +0 -22
- package/src/components/Grid/core/components/Dialog/interfaces/index.d.ts +0 -7
- package/src/components/Grid/core/components/Save/Save.tsx +0 -74
- package/src/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.tsx +0 -63
- package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.tsx +0 -153
- package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/styles.ts +0 -52
- package/src/components/Grid/core/components/Save/components/ChangeEditor/styles.ts +0 -34
- package/src/components/Grid/core/components/Save/hooks/useSave.ts +0 -59
- package/src/components/Grid/core/components/Save/styles.ts +0 -41
- package/src/components/Grid/core/controllers/useGridController.ts +0 -46
- package/src/components/Grid/core/enums/ConditionOperator.ts +0 -46
- package/src/components/Grid/core/enums/DataType.ts +0 -25
- package/src/components/Grid/core/hooks/useGridInstance.ts +0 -7
- package/src/components/Grid/core/hooks/useRefreshCallback.ts +0 -20
- package/src/components/Grid/core/hooks/useRerender.ts +0 -15
- package/src/components/Grid/core/interfaces/IGridColumn.ts +0 -19
- package/src/components/Grid/core/interfaces/IGridContext.ts +0 -7
- package/src/components/Grid/core/model/Grid.ts +0 -250
- package/src/components/Grid/core/model/GridDependency.ts +0 -34
- package/src/components/Grid/core/model/Metadata.ts +0 -20
- package/src/components/Grid/core/services/RecordUpdateService/controllers/useRecordUpdateServiceController.ts +0 -36
- package/src/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.ts +0 -222
- package/src/components/Grid/filtering/components/FilterCallout/FilterCallout.tsx +0 -83
- package/src/components/Grid/filtering/components/FilterCallout/components/ConditionOperator/ConditionOperator.tsx +0 -66
- package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.tsx +0 -48
- package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.ts +0 -120
- package/src/components/Grid/filtering/components/FilterCallout/styles.ts +0 -37
- package/src/components/Grid/filtering/constants.ts +0 -48
- package/src/components/Grid/filtering/controller/useColumnFilterConditionController.ts +0 -63
- package/src/components/Grid/filtering/model/Condition.ts +0 -309
- package/src/components/Grid/filtering/model/Filtering.ts +0 -78
- package/src/components/Grid/filtering/utils/FilteringUtilts.ts +0 -190
- package/src/components/Grid/interfaces.ts +0 -109
- package/src/components/Grid/paging/components/Paging/Paging.tsx +0 -76
- package/src/components/Grid/paging/components/Paging/styles.ts +0 -38
- package/src/components/Grid/paging/controllers/usePagingController.ts +0 -34
- package/src/components/Grid/paging/model/Paging.ts +0 -49
- package/src/components/Grid/selection/controllers/useSelectionController.ts +0 -25
- package/src/components/Grid/selection/model/Selection.ts +0 -60
- package/src/components/Grid/sorting/Sorting.ts +0 -30
- package/src/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.tsx +0 -126
- package/src/components/Grid/sorting/components/SortingContextualMenu/styles.ts +0 -12
- package/src/components/Grid/sorting/controllers/useColumnSortingController.ts +0 -26
- package/src/components/Grid/translations.ts +0 -80
- package/src/components/Grid/validation/controllers/useRecordValidationController.ts +0 -31
- package/src/components/Grid/validation/model/ColumnValidation.ts +0 -81
- package/src/components/Lookup/Lookup.tsx +0 -199
- package/src/components/Lookup/components/RecordCreator.tsx +0 -53
- package/src/components/Lookup/components/TargetSelector.tsx +0 -43
- package/src/components/Lookup/hooks/useFetchXml.ts +0 -31
- package/src/components/Lookup/hooks/useLoadedEntities.ts +0 -23
- package/src/components/Lookup/hooks/useLookup.ts +0 -126
- package/src/components/Lookup/index.ts +0 -2
- package/src/components/Lookup/interfaces.ts +0 -45
- package/src/components/Lookup/lib.ts +0 -3110
- package/src/components/Lookup/styles.ts +0 -106
- package/src/components/Lookup/translations.ts +0 -28
- package/src/components/MultiSelectOptionSet/MultiSelectOptionSet.tsx +0 -83
- package/src/components/MultiSelectOptionSet/index.ts +0 -2
- package/src/components/MultiSelectOptionSet/interfaces.ts +0 -14
- package/src/components/OptionSet/OptionSet.tsx +0 -67
- package/src/components/OptionSet/index.ts +0 -2
- package/src/components/OptionSet/interfaces.ts +0 -17
- package/src/components/TextField/TextField.tsx +0 -58
- package/src/components/TextField/hooks/useTextField.ts +0 -42
- package/src/components/TextField/index.ts +0 -2
- package/src/components/TextField/interfaces.ts +0 -20
- package/src/components/TwoOptions/TwoOptions.tsx +0 -43
- package/src/components/TwoOptions/index.ts +0 -2
- package/src/components/TwoOptions/interfaces.ts +0 -17
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useComponent.ts +0 -83
- package/src/hooks/useFocusIn.ts +0 -23
- package/src/hooks/useInputBasedComponent.ts +0 -71
- package/src/hooks/useMouseOver.ts +0 -23
- package/src/index.tsx +0 -12
- package/src/interfaces/context.ts +0 -21
- package/src/interfaces/index.ts +0 -12
- package/src/interfaces/parameters.ts +0 -26
- package/src/interfaces/property.ts +0 -111
- package/src/sandbox/index.tsx +0 -137
- package/src/sandbox/mock/Context.ts +0 -18
- package/src/sandbox/mock/Formatting.ts +0 -186
- package/src/sandbox/mock/Mode.ts +0 -25
- package/src/sandbox/mock/UserSettings.ts +0 -31
- package/src/sandbox/mock/Utility.ts +0 -14
- package/src/sandbox/shared/durationList.tsx +0 -24
- package/src/sandbox/shared/multiSelectOptionList.tsx +0 -5
- package/src/sandbox/shared/optionList.tsx +0 -5
- package/src/stories/Introduction.stories.mdx +0 -122
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/types/index.ts +0 -3
- package/src/utils/NumeralPCF.ts +0 -62
- package/tsconfig.json +0 -28
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { ITheme, mergeStyleSets } from "@fluentui/react";
|
|
2
|
-
|
|
3
|
-
export const getTargetSelectorStyles = (theme: ITheme) => {
|
|
4
|
-
return mergeStyleSets({
|
|
5
|
-
targetSelector: {
|
|
6
|
-
display: 'flex',
|
|
7
|
-
paddingLeft: 8,
|
|
8
|
-
paddingRight: 8,
|
|
9
|
-
paddingBottom: 8,
|
|
10
|
-
gap: 8,
|
|
11
|
-
paddingTop: 8,
|
|
12
|
-
'>span': {
|
|
13
|
-
lineHeight: 15,
|
|
14
|
-
minWidth: 'fit-content',
|
|
15
|
-
color: theme.semanticColors.listText,
|
|
16
|
-
fontWeight: 600
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
targetSelectorLinks: {
|
|
20
|
-
display: 'flex',
|
|
21
|
-
gap: 5,
|
|
22
|
-
flexWrap: 'wrap'
|
|
23
|
-
},
|
|
24
|
-
targetSelectorLink: {
|
|
25
|
-
color: theme.palette.blackTranslucent40,
|
|
26
|
-
'&[data-selected="true"]': {
|
|
27
|
-
color: theme.semanticColors.link,
|
|
28
|
-
fontWeight: 600
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const getHeight = (height: number) => {
|
|
35
|
-
if(height === -1 || height === 0) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
return height;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const getLookupStyles = (theme: ITheme, height: number, isSingleSelect: boolean) => {
|
|
42
|
-
const _height = getHeight(height);
|
|
43
|
-
return mergeStyleSets({
|
|
44
|
-
root: {
|
|
45
|
-
'[class*="TALXIS__tag-picker__search-btn"][class*="TALXIS__tag-picker__search-btn"]': {
|
|
46
|
-
top: 0,
|
|
47
|
-
bottom: 0,
|
|
48
|
-
margin: `auto 0`,
|
|
49
|
-
right: 5
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
'[data-navigation-enabled="true"]': {
|
|
53
|
-
'> span > div > span': {
|
|
54
|
-
color: theme.semanticColors.link,
|
|
55
|
-
cursor: 'pointer',
|
|
56
|
-
},
|
|
57
|
-
':hover': {
|
|
58
|
-
textDecoration: 'underline',
|
|
59
|
-
cursor: 'pointer !important'
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
'.ms-BasePicker-itemsWrapper .ms-CommandBar': {
|
|
63
|
-
height: _height && isSingleSelect ? _height - 6 : undefined
|
|
64
|
-
},
|
|
65
|
-
'.ms-BasePicker-text': {
|
|
66
|
-
minHeight: _height ?? 36,
|
|
67
|
-
height: 'min-content',
|
|
68
|
-
paddingRight: !isSingleSelect ? 36 : undefined,
|
|
69
|
-
alignItems: 'baseline',
|
|
70
|
-
|
|
71
|
-
'input': {
|
|
72
|
-
alignSelf: 'center'
|
|
73
|
-
},
|
|
74
|
-
'.hover-only': {
|
|
75
|
-
animationName: 'none'
|
|
76
|
-
},
|
|
77
|
-
'::after': {
|
|
78
|
-
inset: '0px !important'
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
suggestions: {
|
|
83
|
-
'.ms-Suggestions-title': {
|
|
84
|
-
padding: 0,
|
|
85
|
-
display: 'flex',
|
|
86
|
-
flexDirection: 'column',
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
createRecordBtn: {
|
|
90
|
-
height: 38,
|
|
91
|
-
width: '100%',
|
|
92
|
-
'.ms-Button-menuIcon': {
|
|
93
|
-
display: 'none'
|
|
94
|
-
},
|
|
95
|
-
'>.ms-Button-flexContainer.ms-Button-flexContainer': {
|
|
96
|
-
justifyContent: 'flex-start'
|
|
97
|
-
},
|
|
98
|
-
'.ms-Button-textContainer': {
|
|
99
|
-
flexGrow: 'initial',
|
|
100
|
-
'>span': {
|
|
101
|
-
fontWeight: 600,
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ILookupTranslations } from "./interfaces";
|
|
2
|
-
|
|
3
|
-
export const lookupTranslations: ILookupTranslations = {
|
|
4
|
-
search: {
|
|
5
|
-
1033: "Search",
|
|
6
|
-
1029: "Vyhledejte"
|
|
7
|
-
},
|
|
8
|
-
newRecord: {
|
|
9
|
-
1033: "New record",
|
|
10
|
-
1029: "Nový záznam"
|
|
11
|
-
},
|
|
12
|
-
searching: {
|
|
13
|
-
1033: "Searching...",
|
|
14
|
-
1029: "Hledám..."
|
|
15
|
-
},
|
|
16
|
-
noRecordsFound: {
|
|
17
|
-
1033: "No records found",
|
|
18
|
-
1029: "Nebyly nalezeny žádné záznamy"
|
|
19
|
-
},
|
|
20
|
-
resultsFrom: {
|
|
21
|
-
1033: "Results from:",
|
|
22
|
-
1029: "Výsledky z:"
|
|
23
|
-
},
|
|
24
|
-
noName: {
|
|
25
|
-
1033: "(No Name)",
|
|
26
|
-
1029: "(Bez názvu)"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IMultiSelectOptionSet } from './interfaces';
|
|
3
|
-
import { useComponent } from '../../hooks';
|
|
4
|
-
import { ComboBox } from '@talxis/react-components/dist/components/ComboBox';
|
|
5
|
-
import { IComboBox, IComboBoxOption } from '@fluentui/react';
|
|
6
|
-
import React, { useEffect, useRef } from 'react';
|
|
7
|
-
|
|
8
|
-
export const MultiSelectOptionSet = (props: IMultiSelectOptionSet) => {
|
|
9
|
-
const [labels, onNotifyOutputChanged] = useComponent('MultiSelectOptionSet', props);
|
|
10
|
-
const parameters = props.parameters;
|
|
11
|
-
const boundValue = parameters.value;
|
|
12
|
-
const componentRef = useRef<IComboBox>(null);
|
|
13
|
-
const { Options } = parameters.value.attributes;
|
|
14
|
-
const context = props.context;
|
|
15
|
-
const comboBoxOptions: IComboBoxOption[] = Options.map(option => ({
|
|
16
|
-
key: option.Value.toString(),
|
|
17
|
-
text: option.Label,
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
const handleChange = (option?: IComboBoxOption | null): void => {
|
|
21
|
-
if(!option) {
|
|
22
|
-
onNotifyOutputChanged({
|
|
23
|
-
value: undefined
|
|
24
|
-
});
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const optionKey = option.key.toString();
|
|
28
|
-
const updatedSelectedKeys = new Set(boundValue.raw || []);
|
|
29
|
-
if (option.selected) {
|
|
30
|
-
updatedSelectedKeys.add(+optionKey);
|
|
31
|
-
} else {
|
|
32
|
-
updatedSelectedKeys.delete(+optionKey);
|
|
33
|
-
}
|
|
34
|
-
const updatedSelectedKeysArray = Array.from(updatedSelectedKeys);
|
|
35
|
-
|
|
36
|
-
onNotifyOutputChanged({
|
|
37
|
-
value: updatedSelectedKeysArray.map(key => +key)
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (parameters.AutoFocus?.raw) {
|
|
43
|
-
componentRef.current?.focus(true);
|
|
44
|
-
}
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
return <ComboBox
|
|
48
|
-
componentRef={componentRef}
|
|
49
|
-
borderless={parameters.EnableBorder?.raw === false}
|
|
50
|
-
options={comboBoxOptions}
|
|
51
|
-
allowFreeInput={true}
|
|
52
|
-
multiSelect
|
|
53
|
-
autoComplete="on"
|
|
54
|
-
autofill={parameters.AutoFocus?.raw === true ? {
|
|
55
|
-
autoFocus: true
|
|
56
|
-
}: undefined}
|
|
57
|
-
readOnly={context.mode.isControlDisabled}
|
|
58
|
-
errorMessage={boundValue.errorMessage}
|
|
59
|
-
selectedKey={boundValue.raw ? boundValue.raw.map(key => key.toString()) : [-1]}
|
|
60
|
-
useComboBoxAsMenuWidth
|
|
61
|
-
styles={{
|
|
62
|
-
root: {
|
|
63
|
-
height: context.mode.allocatedHeight || undefined,
|
|
64
|
-
width: context.mode.allocatedWidth || undefined,
|
|
65
|
-
display: 'flex',
|
|
66
|
-
alignItems: 'center',
|
|
67
|
-
},
|
|
68
|
-
callout: {
|
|
69
|
-
maxHeight: '300px !important'
|
|
70
|
-
}
|
|
71
|
-
}}
|
|
72
|
-
deleteButtonProps={{
|
|
73
|
-
key: 'delete',
|
|
74
|
-
showOnlyOnHover: false,
|
|
75
|
-
iconProps: {
|
|
76
|
-
iconName: 'Delete'
|
|
77
|
-
},
|
|
78
|
-
onClick: (e, value) => {
|
|
79
|
-
handleChange(null);
|
|
80
|
-
}
|
|
81
|
-
}}
|
|
82
|
-
onChange={(e, option) => handleChange(option)} />;
|
|
83
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { IMultiSelectOptionSetProperty } from "../../interfaces";
|
|
2
|
-
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
-
import { IBaseParameters } from "../../interfaces/parameters";
|
|
4
|
-
|
|
5
|
-
export interface IMultiSelectOptionSet extends IComponent<IMultiSelectOptionSetParameters, IMultiSelectOptionSetOutputs, ITranslations> {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IMultiSelectOptionSetParameters extends IBaseParameters {
|
|
9
|
-
value: IMultiSelectOptionSetProperty;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IMultiSelectOptionSetOutputs extends IOutputs {
|
|
13
|
-
value?: number[];
|
|
14
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IOptionSet } from './interfaces';
|
|
3
|
-
import { useComponent } from '../../hooks';
|
|
4
|
-
import { ComboBox } from '@talxis/react-components/dist/components/ComboBox';
|
|
5
|
-
import { IComboBox, IComboBoxOption } from '@fluentui/react';
|
|
6
|
-
import React, { useEffect, useRef } from 'react';
|
|
7
|
-
|
|
8
|
-
export const OptionSet = (props: IOptionSet) => {
|
|
9
|
-
const [labels, onNotifyOutputChanged] = useComponent('OptionSet', props);
|
|
10
|
-
const componentRef = useRef<IComboBox>(null);
|
|
11
|
-
const parameters = props.parameters;
|
|
12
|
-
const boundValue = parameters.value;
|
|
13
|
-
const { Options } = parameters.value.attributes;
|
|
14
|
-
const context = props.context;
|
|
15
|
-
const comboBoxOptions: IComboBoxOption[] = Options.map(option => ({
|
|
16
|
-
key: option.Value.toString(),
|
|
17
|
-
text: option.Label,
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
const handleChange = (option?: IComboBoxOption | null): void => {
|
|
21
|
-
let value = undefined;
|
|
22
|
-
if (option) {
|
|
23
|
-
value = parseInt(option.key as string);
|
|
24
|
-
}
|
|
25
|
-
onNotifyOutputChanged({
|
|
26
|
-
value: value
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (parameters.AutoFocus?.raw) {
|
|
32
|
-
componentRef.current?.focus(true);
|
|
33
|
-
}
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
return <ComboBox
|
|
37
|
-
componentRef={componentRef}
|
|
38
|
-
borderless={parameters.EnableBorder?.raw === false}
|
|
39
|
-
options={comboBoxOptions}
|
|
40
|
-
readOnly={context.mode.isControlDisabled}
|
|
41
|
-
//the defaultValue comes in the raw prop directly, no need to look at it
|
|
42
|
-
selectedKey={boundValue.raw?.toString() ?? -1}
|
|
43
|
-
dropdownWidth={context.mode.allocatedWidth || undefined}
|
|
44
|
-
errorMessage={boundValue.errorMessage}
|
|
45
|
-
useComboBoxAsMenuWidth
|
|
46
|
-
styles={{
|
|
47
|
-
root: {
|
|
48
|
-
height: context.mode.allocatedHeight || undefined,
|
|
49
|
-
width: context.mode.allocatedWidth || undefined,
|
|
50
|
-
display: 'flex',
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
},
|
|
53
|
-
callout: {
|
|
54
|
-
maxHeight: '300px !important'
|
|
55
|
-
}
|
|
56
|
-
}}
|
|
57
|
-
deleteButtonProps={{
|
|
58
|
-
key: 'delete',
|
|
59
|
-
showOnlyOnHover: true,
|
|
60
|
-
iconProps: {
|
|
61
|
-
iconName: 'Delete'
|
|
62
|
-
},
|
|
63
|
-
onClick: (e, value) => { handleChange(null); }
|
|
64
|
-
}}
|
|
65
|
-
onChange={(e, option) => handleChange(option)}
|
|
66
|
-
/>;
|
|
67
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IOptionSetProperty } from "../../interfaces";
|
|
2
|
-
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
-
import { IBaseParameters } from "../../interfaces/parameters";
|
|
4
|
-
|
|
5
|
-
export interface IOptionSet extends IComponent<IOptionSetParameters, IOptionSetOutputs, IOptionSetTranslations> {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IOptionSetParameters extends IBaseParameters {
|
|
9
|
-
value: IOptionSetProperty;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IOptionSetOutputs extends IOutputs {
|
|
13
|
-
value?: number
|
|
14
|
-
}
|
|
15
|
-
export interface IOptionSetTranslations extends ITranslations {
|
|
16
|
-
|
|
17
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { TextField as TextFieldBase } from '@talxis/react-components/dist/components/TextField';
|
|
2
|
-
import { useRef } from 'react';
|
|
3
|
-
import { useInputBasedComponent } from '../../hooks/useInputBasedComponent';
|
|
4
|
-
import { useTextField } from './hooks/useTextField';
|
|
5
|
-
import { ITextField, ITextFieldOutputs, ITextFieldParameters, ITextFieldTranslations } from './interfaces';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
export const TextField = (props: ITextField) => {
|
|
9
|
-
const context = props.context;
|
|
10
|
-
const parameters = props.parameters;
|
|
11
|
-
const boundValue = parameters.value;
|
|
12
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
13
|
-
const [value, labels, setValue, onNotifyOutputChanged] = useInputBasedComponent<string | undefined, ITextFieldParameters, ITextFieldOutputs, ITextFieldTranslations>('TextField', props);
|
|
14
|
-
const [height] = useTextField(props, ref);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<TextFieldBase
|
|
18
|
-
readOnly={context.mode.isControlDisabled}
|
|
19
|
-
//TODO: should be inherited by the type, eg TextArea = multiline
|
|
20
|
-
multiline={parameters.IsMultiLine?.raw}
|
|
21
|
-
resizable={parameters.isResizable?.raw}
|
|
22
|
-
autoFocus={parameters.AutoFocus?.raw}
|
|
23
|
-
elementRef={ref}
|
|
24
|
-
styles={{
|
|
25
|
-
fieldGroup: {
|
|
26
|
-
height: height,
|
|
27
|
-
width: context.mode.allocatedWidth || undefined
|
|
28
|
-
}
|
|
29
|
-
}}
|
|
30
|
-
borderless={parameters.EnableBorder?.raw === false}
|
|
31
|
-
errorMessage={boundValue.errorMessage}
|
|
32
|
-
deleteButtonProps={parameters.EnableDeleteButton?.raw === true ? {
|
|
33
|
-
key: 'delete',
|
|
34
|
-
showOnlyOnHover: true,
|
|
35
|
-
iconProps: {
|
|
36
|
-
iconName: 'Delete'
|
|
37
|
-
},
|
|
38
|
-
onClick: () => setValue(undefined)
|
|
39
|
-
} : undefined}
|
|
40
|
-
clickToCopyProps={parameters.EnableCopyButton?.raw === true ? {
|
|
41
|
-
key: 'copy',
|
|
42
|
-
showOnlyOnHover: true,
|
|
43
|
-
iconProps: {
|
|
44
|
-
iconName: 'Copy'
|
|
45
|
-
}
|
|
46
|
-
} : undefined}
|
|
47
|
-
value={value ?? ""}
|
|
48
|
-
onBlur={() => {
|
|
49
|
-
onNotifyOutputChanged({
|
|
50
|
-
value: value ?? undefined
|
|
51
|
-
});
|
|
52
|
-
}}
|
|
53
|
-
onChange={(e, value) => {
|
|
54
|
-
setValue(value);
|
|
55
|
-
}} />
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { ITextField } from "../interfaces";
|
|
3
|
-
|
|
4
|
-
export const useTextField = (props: ITextField, ref: React.RefObject<HTMLDivElement>): [number | undefined] => {
|
|
5
|
-
const getInitialHeight = () => {
|
|
6
|
-
if (props.context.mode.allocatedHeight) {
|
|
7
|
-
return props.context.mode.allocatedHeight;
|
|
8
|
-
}
|
|
9
|
-
if (props.parameters.IsMultiLine?.raw) {
|
|
10
|
-
return 80;
|
|
11
|
-
}
|
|
12
|
-
return undefined;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const hasBeenResizedRef = useRef<boolean>(false);
|
|
16
|
-
const [height, setHeight] = useState<number | undefined>(getInitialHeight());
|
|
17
|
-
const firstRenderRef = useRef<boolean>(true);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (!props.parameters.IsMultiLine?.raw) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
24
|
-
if (firstRenderRef.current || hasBeenResizedRef.current) {
|
|
25
|
-
firstRenderRef.current = false;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
hasBeenResizedRef.current = true;
|
|
29
|
-
setHeight(undefined);
|
|
30
|
-
});
|
|
31
|
-
const textarea = ref.current?.querySelector('textarea') as HTMLTextAreaElement;
|
|
32
|
-
if (height) {
|
|
33
|
-
textarea.setAttribute('style', `height: ${height}px`);
|
|
34
|
-
}
|
|
35
|
-
resizeObserver.observe(textarea);
|
|
36
|
-
|
|
37
|
-
return () => {
|
|
38
|
-
resizeObserver.disconnect();
|
|
39
|
-
};
|
|
40
|
-
}, []);
|
|
41
|
-
return [height];
|
|
42
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IStringProperty, ITwoOptionsProperty } from "../../interfaces";
|
|
2
|
-
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
-
import { IInputParameters } from "../../interfaces/parameters";
|
|
4
|
-
|
|
5
|
-
export interface ITextField extends IComponent<ITextFieldParameters, ITextFieldOutputs, ITextFieldTranslations> {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ITextFieldParameters extends IInputParameters {
|
|
9
|
-
IsMultiLine?: ITwoOptionsProperty;
|
|
10
|
-
isResizable?: ITwoOptionsProperty;
|
|
11
|
-
value: IStringProperty;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ITextFieldOutputs extends IOutputs {
|
|
15
|
-
value?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ITextFieldTranslations extends ITranslations {
|
|
19
|
-
|
|
20
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { IRefObject, IToggle, Toggle } from '@fluentui/react';
|
|
2
|
-
import { useComponent } from '../../hooks';
|
|
3
|
-
import { ITwoOptions } from './interfaces';
|
|
4
|
-
import React, { useEffect, useRef } from 'react';
|
|
5
|
-
|
|
6
|
-
export const TwoOptions = (props: ITwoOptions) => {
|
|
7
|
-
const parameters = props.parameters;
|
|
8
|
-
const boundValue = parameters.value;
|
|
9
|
-
const options = boundValue.attributes.Options;
|
|
10
|
-
const [labels, onNotifyOutputChanged] = useComponent('TwoOptions', props);
|
|
11
|
-
const context = props.context;
|
|
12
|
-
const componentRef = useRef<any>(null);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if(parameters.AutoFocus?.raw === true) {
|
|
16
|
-
componentRef.current.focus();
|
|
17
|
-
}
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
|
-
const handleChange = (value: boolean | undefined): void => {
|
|
21
|
-
onNotifyOutputChanged({
|
|
22
|
-
value: value
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return <Toggle
|
|
27
|
-
styles={{
|
|
28
|
-
root: {
|
|
29
|
-
height: context.mode.allocatedHeight || undefined,
|
|
30
|
-
width: context.mode.allocatedWidth || undefined,
|
|
31
|
-
},
|
|
32
|
-
container: {
|
|
33
|
-
alignItems: 'center'
|
|
34
|
-
}
|
|
35
|
-
}}
|
|
36
|
-
checked={boundValue.raw}
|
|
37
|
-
componentRef={componentRef}
|
|
38
|
-
inlineLabel
|
|
39
|
-
onText={options.find(option=>option.Value ===1)?.Label || 'Yes'}
|
|
40
|
-
offText={options.find(option=>option.Value ===0)?.Label || 'No'}
|
|
41
|
-
onChange={(e, value) => handleChange(value)}
|
|
42
|
-
/>;
|
|
43
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ITwoOptionsProperty } from "../../interfaces";
|
|
2
|
-
import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
|
|
3
|
-
import { IBaseParameters } from "../../interfaces/parameters";
|
|
4
|
-
|
|
5
|
-
export interface ITwoOptions extends IComponent<ITwoOptionsParameters, ITwoOptionsOutputs, ITwoOptionsTranslations> {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ITwoOptionsParameters extends IBaseParameters {
|
|
9
|
-
value: ITwoOptionsProperty
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ITwoOptionsOutputs extends IOutputs {
|
|
13
|
-
value?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface ITwoOptionsTranslations extends ITranslations {
|
|
16
|
-
|
|
17
|
-
}
|
package/src/hooks/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useComponent';
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import deepEqual from 'fast-deep-equal/es6';
|
|
4
|
-
import { IComponent, IOutputs, IParameters, ITranslations } from "../interfaces";
|
|
5
|
-
import { merge } from 'merge-anything';
|
|
6
|
-
import { StringProps } from "../types";
|
|
7
|
-
import { Liquid } from "liquidjs";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Provides automatic checking if the given outputs are different from the provided inputs. Use the provided method any time you want
|
|
11
|
-
* to notify the framework that you wish to write changes. The hook will notify the framework only if the provided output differs from the current inputs.
|
|
12
|
-
*/
|
|
13
|
-
export const useComponent = <TParameters extends IParameters, TOutputs extends IOutputs, TTranslations extends ITranslations>(name: string, props: IComponent<TParameters, TOutputs, TTranslations>, defaultTranslations?: TTranslations): [
|
|
14
|
-
Required<StringProps<TTranslations>>,
|
|
15
|
-
(outputs: TOutputs) => void,
|
|
16
|
-
] => {
|
|
17
|
-
const parametersRef = useRef<TParameters>(props.parameters);
|
|
18
|
-
const liquid = useMemo(() => new Liquid(), []);
|
|
19
|
-
const labels = useMemo(() => {
|
|
20
|
-
const mergedTranslations = merge(defaultTranslations ?? {}, props.translations ?? {}) as TTranslations;
|
|
21
|
-
return new Proxy(mergedTranslations, {
|
|
22
|
-
get(target, key) {
|
|
23
|
-
return (variables: any) => getLabel(key as string, mergedTranslations, variables)
|
|
24
|
-
}
|
|
25
|
-
}) as any;
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
parametersRef.current = props.parameters;
|
|
30
|
-
}, [props.parameters]);
|
|
31
|
-
|
|
32
|
-
const getLabel = (key: string, translations: TTranslations, variables?: any): string | string[] => {
|
|
33
|
-
const strigify = (value: string | string[]) => {
|
|
34
|
-
if(typeof value === 'string') {
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
return JSON.stringify(value);
|
|
38
|
-
};
|
|
39
|
-
const translation = translations[key];
|
|
40
|
-
if (!translation) {
|
|
41
|
-
console.error(`Translation for the ${key} label of the ${name} component has not been defined!`);
|
|
42
|
-
return key;
|
|
43
|
-
}
|
|
44
|
-
if (typeof translation === 'string' || Array.isArray(translation)) {
|
|
45
|
-
return strigify(translation);
|
|
46
|
-
}
|
|
47
|
-
let label = translation[props.context.userSettings.languageId];
|
|
48
|
-
if (!label) {
|
|
49
|
-
console.info(`Translation for the ${key} label of the ${name} component has not been found. Using default Czech label instead.`);
|
|
50
|
-
label = translation[1029];
|
|
51
|
-
}
|
|
52
|
-
if (!label) {
|
|
53
|
-
console.error(`Translation for the ${key} label of the ${name} component does not exists neither for Czech language and current LCID.`);
|
|
54
|
-
label = key;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return liquid.parseAndRenderSync(strigify(label), variables);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const onNotifyOutputChanged = (outputs: TOutputs) => {
|
|
61
|
-
let isDirty = false;
|
|
62
|
-
for (let [key, outputValue] of Object.entries(outputs)) {
|
|
63
|
-
const parameterValue = parametersRef.current[key]?.raw;
|
|
64
|
-
if (!deepEqual(parameterValue, outputValue)) {
|
|
65
|
-
if(outputValue === "") {
|
|
66
|
-
outputValue = null;
|
|
67
|
-
}
|
|
68
|
-
// handles undefined X null
|
|
69
|
-
if (parameterValue == outputValue) {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
isDirty = true;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (!isDirty) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
//console.log(`Change detected, triggering notifyOutputChanged on component ${name}.`);
|
|
80
|
-
props.onNotifyOutputChanged?.(outputs);
|
|
81
|
-
};
|
|
82
|
-
return [labels, onNotifyOutputChanged];
|
|
83
|
-
};
|
package/src/hooks/useFocusIn.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export const useFocusIn = (ref: React.RefObject<HTMLElement>): boolean => {
|
|
4
|
-
const [isFocused, setIsFocused] = useState<boolean>(false);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const onFocus = () => {
|
|
8
|
-
setIsFocused(true);
|
|
9
|
-
}
|
|
10
|
-
const onBlur = () => {
|
|
11
|
-
setIsFocused(false);
|
|
12
|
-
}
|
|
13
|
-
ref.current?.addEventListener('focusin', onFocus);
|
|
14
|
-
ref.current?.addEventListener('focusout', onBlur);
|
|
15
|
-
|
|
16
|
-
return () => {
|
|
17
|
-
ref.current?.removeEventListener('focusin', onFocus);
|
|
18
|
-
ref.current?.removeEventListener('focusout', onBlur);
|
|
19
|
-
}
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
return isFocused
|
|
23
|
-
};
|