@talxis/base-controls 1.2504.1 → 1.2504.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/dist/components/DatasetControl/DatasetControl.js +6 -10
- package/dist/components/DatasetControl/DatasetControl.js.map +1 -1
- package/dist/components/DatasetControl/QuickFind/QuickFind.js +8 -2
- package/dist/components/DatasetControl/QuickFind/QuickFind.js.map +1 -1
- package/dist/components/DatasetControl/QuickFind/styles.d.ts +8 -0
- package/dist/components/DatasetControl/QuickFind/styles.js +15 -0
- package/dist/components/DatasetControl/QuickFind/styles.js.map +1 -0
- package/dist/components/DatasetControl/interfaces.d.ts +2 -1
- package/dist/components/DatasetControl/styles.d.ts +3 -0
- package/dist/components/DatasetControl/styles.js +3 -0
- package/dist/components/DatasetControl/styles.js.map +1 -1
- package/dist/components/Grid/Grid.js +1 -1
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/AgGrid.d.ts +2 -1
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js +94 -58
- package/dist/components/Grid/core/components/AgGrid/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.d.ts +3 -1
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js +68 -57
- package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js.map +1 -1
- package/dist/components/Grid/core/components/AgGrid/styles.d.ts +3 -3
- package/dist/components/Grid/core/components/AgGrid/styles.js +3 -9
- package/dist/components/Grid/core/components/AgGrid/styles.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/Cell.js +5 -13
- package/dist/components/Grid/core/components/Cell/Cell.js.map +1 -1
- package/dist/components/Grid/core/components/Cell/CellContent/CellContent.js +14 -2
- package/dist/components/Grid/core/components/Cell/CellContent/CellContent.js.map +1 -1
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.js +9 -9
- package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.js.map +1 -1
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.js +16 -0
- package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.js.map +1 -1
- package/dist/components/Grid/core/model/Grid.d.ts +8 -4
- package/dist/components/Grid/core/model/Grid.js +32 -25
- package/dist/components/Grid/core/model/Grid.js.map +1 -1
- package/dist/components/Grid/filtering/model/Condition.d.ts +0 -1
- package/dist/components/Grid/filtering/model/Condition.js +5 -4
- package/dist/components/Grid/filtering/model/Condition.js.map +1 -1
- package/dist/components/Grid/interfaces.d.ts +9 -1
- package/dist/components/Grid/paging/components/Paging/Paging.js +2 -2
- package/dist/components/Grid/paging/components/Paging/Paging.js.map +1 -1
- package/dist/components/Grid/sorting/Sorting.d.ts +1 -0
- package/dist/components/Grid/sorting/Sorting.js +5 -6
- package/dist/components/Grid/sorting/Sorting.js.map +1 -1
- package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js +12 -0
- package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js.map +1 -1
- package/dist/components/Grid/sorting/controllers/useColumnSortingController.d.ts +1 -0
- package/dist/components/Grid/sorting/controllers/useColumnSortingController.js +2 -1
- package/dist/components/Grid/sorting/controllers/useColumnSortingController.js.map +1 -1
- package/dist/components/Grid/translations.d.ts +4 -0
- package/dist/components/Grid/translations.js +1 -0
- package/dist/components/Grid/translations.js.map +1 -1
- package/dist/components/GridCellRenderer/GridCellRenderer.js +4 -2
- package/dist/components/GridCellRenderer/GridCellRenderer.js.map +1 -1
- package/dist/components/GridCellRenderer/OptionSet/OptionSet.js +8 -2
- package/dist/components/GridCellRenderer/OptionSet/OptionSet.js.map +1 -1
- package/dist/components/GridCellRenderer/interfaces.d.ts +1 -0
- package/dist/components/Lookup/Lookup.js +1 -1
- package/dist/components/Lookup/Lookup.js.map +1 -1
- package/dist/components/Lookup/hooks/useLookup.js +2 -1
- package/dist/components/Lookup/hooks/useLookup.js.map +1 -1
- package/dist/components/Lookup/interfaces.d.ts +8 -0
- package/dist/index.d.ts +24 -2
- package/package.json +4 -3
- package/dist/components/DatasetControl/ErrorBoundary.js +0 -33
- package/dist/components/DatasetControl/ErrorBoundary.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useTheme, ThemeProvider, Text } from '@fluentui/react';
|
|
2
|
+
import { useTheme, merge, ThemeProvider, Text } from '@fluentui/react';
|
|
3
3
|
import { Theming, useThemeGenerator } from '@talxis/react-components';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { getOptionSetStyles, getColorfulOptionStyles } from './styles.js';
|
|
@@ -51,7 +51,13 @@ const ColorfulOption = (props) => {
|
|
|
51
51
|
const backgroundColor = option.Color ?? theme.palette.neutralLight;
|
|
52
52
|
const textColor = Theming.GetTextColorForBackground(backgroundColor);
|
|
53
53
|
const styles = useMemo(() => getColorfulOptionStyles(), []);
|
|
54
|
-
const optionTheme = useThemeGenerator(textColor, backgroundColor, textColor,
|
|
54
|
+
const optionTheme = useThemeGenerator(textColor, backgroundColor, textColor, merge({}, {
|
|
55
|
+
fonts: {
|
|
56
|
+
medium: {
|
|
57
|
+
fontWeight: 600
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, props.context.fluentDesignLanguage?.v8FluentOverrides));
|
|
55
61
|
const optionProps = props.optionSetProps.onGetOptionProps({
|
|
56
62
|
containerProps: {
|
|
57
63
|
className: styles.option,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionSet.js","sources":["../../../../src/components/GridCellRenderer/OptionSet/OptionSet.tsx"],"sourcesContent":["import { DataType } from \"@talxis/client-libraries\";\nimport { IOptionSet } from \"../../OptionSet\"\nimport { IMultiSelectOptionSet } from \"../../MultiSelectOptionSet\";\nimport { ITwoOptions } from \"../../TwoOptions\";\nimport { ThemeProvider, useTheme } from \"@fluentui/react\";\nimport { Theming, useThemeGenerator } from \"@talxis/react-components\";\nimport { Text } from '@fluentui/react';\nimport { IContext } from \"../../../interfaces\";\nimport { useMemo } from \"react\";\nimport { getColorfulOptionStyles, getOptionSetStyles } from \"./styles\";\nimport { useComponentProps } from \"../useComponentProps\";\nimport { IOptionSetProps } from \"../interfaces\";\nimport { DefaultContentRenderer } from \"../DefaultContentRenderer\";\n\nexport const OptionSet = (props: IOptionSet | IMultiSelectOptionSet | ITwoOptions) => {\n const dataType: DataType = props.parameters.value.type as DataType;\n const options = props.parameters.value.attributes.Options;\n const value: any = props.parameters.value.raw;\n const styles = useMemo(() => getOptionSetStyles(), []);\n const componentProps = useComponentProps();\n\n const optionSetProps = componentProps.onGetOptionSetProps({\n containerProps: {\n className: styles.root\n },\n onGetOptionProps: (props) => props\n })\n\n const shouldRenderDefaultLabel = () => {\n if (!props.parameters.EnableOptionSetColors?.raw || !options.some(option => option.Color)) {\n return true;\n }\n return false;\n }\n\n const getSelectedOptions = () => {\n let result: any = value ?? [];\n switch (dataType) {\n case 'OptionSet': {\n result = [value]\n break;\n }\n case 'TwoOptions': {\n result = [+value];\n break;\n }\n }\n return options.filter(option => result?.includes(option.Value)) ?? [];\n }\n\n if (shouldRenderDefaultLabel()) {\n return <DefaultContentRenderer />\n }\n return (<div {...optionSetProps.containerProps}>\n {getSelectedOptions().map(option => {\n return <ColorfulOption\n key={option.Value}\n optionSetProps={optionSetProps}\n option={option}\n context={props.context} />\n })}\n </div>)\n}\n\nconst ColorfulOption = (props: {\n option: ComponentFramework.PropertyHelper.OptionMetadata,\n context: IContext;\n optionSetProps: IOptionSetProps\n}) => {\n const theme = useTheme();\n const option = props.option;\n const backgroundColor = option.Color ?? theme.palette.neutralLight;\n const textColor = Theming.GetTextColorForBackground(backgroundColor);\n const styles = useMemo(() => getColorfulOptionStyles(), []);\n const optionTheme = useThemeGenerator(textColor, backgroundColor, textColor, props.context.fluentDesignLanguage?.v8FluentOverrides);\n\n const optionProps = props.optionSetProps.onGetOptionProps({\n containerProps: {\n className: styles.option,\n theme: optionTheme\n },\n option: option,\n textProps: {\n children: option.Label\n }\n })\n\n return (\n <ThemeProvider {...optionProps.containerProps}>\n <Text {...optionProps.textProps}>{optionProps.textProps.children}</Text>\n </ThemeProvider>\n )\n}"],"names":["_jsx"],"mappings":";;;;;;;;AAca,MAAA,SAAS,GAAG,CAAC,KAAuD,KAAI;IACjF,MAAM,QAAQ,GAAa,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAgB,CAAC;IACnE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;IAC1D,MAAM,KAAK,GAAQ,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9C,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,kBAAkB,EAAE,EAAE,EAAE,CAAC,CAAC;AACvD,IAAA,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;AAE3C,IAAA,MAAM,cAAc,GAAG,cAAc,CAAC,mBAAmB,CAAC;AACtD,QAAA,cAAc,EAAE;YACZ,SAAS,EAAE,MAAM,CAAC,IAAI;AACzB,SAAA;AACD,QAAA,gBAAgB,EAAE,CAAC,KAAK,KAAK,KAAK;AACrC,KAAA,CAAC,CAAA;IAEF,MAAM,wBAAwB,GAAG,MAAK;QAClC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;AACvF,YAAA,OAAO,IAAI,CAAC;AACf,SAAA;AACD,QAAA,OAAO,KAAK,CAAC;AACjB,KAAC,CAAA;IAED,MAAM,kBAAkB,GAAG,MAAK;AAC5B,QAAA,IAAI,MAAM,GAAQ,KAAK,IAAI,EAAE,CAAC;AAC9B,QAAA,QAAQ,QAAQ;YACZ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AAe,EAAE,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"OptionSet.js","sources":["../../../../src/components/GridCellRenderer/OptionSet/OptionSet.tsx"],"sourcesContent":["import { DataType } from \"@talxis/client-libraries\";\nimport { IOptionSet } from \"../../OptionSet\"\nimport { IMultiSelectOptionSet } from \"../../MultiSelectOptionSet\";\nimport { ITwoOptions } from \"../../TwoOptions\";\nimport { PartialTheme, ThemeProvider, useTheme, merge } from \"@fluentui/react\";\nimport { Theming, useThemeGenerator } from \"@talxis/react-components\";\nimport { Text } from '@fluentui/react';\nimport { IContext } from \"../../../interfaces\";\nimport { useMemo } from \"react\";\nimport { getColorfulOptionStyles, getOptionSetStyles } from \"./styles\";\nimport { useComponentProps } from \"../useComponentProps\";\nimport { IOptionSetProps } from \"../interfaces\";\nimport { DefaultContentRenderer } from \"../DefaultContentRenderer\";\n\nexport const OptionSet = (props: IOptionSet | IMultiSelectOptionSet | ITwoOptions) => {\n const dataType: DataType = props.parameters.value.type as DataType;\n const options = props.parameters.value.attributes.Options;\n const value: any = props.parameters.value.raw;\n const styles = useMemo(() => getOptionSetStyles(), []);\n const componentProps = useComponentProps();\n\n const optionSetProps = componentProps.onGetOptionSetProps({\n containerProps: {\n className: styles.root\n },\n onGetOptionProps: (props) => props\n })\n\n const shouldRenderDefaultLabel = () => {\n if (!props.parameters.EnableOptionSetColors?.raw || !options.some(option => option.Color)) {\n return true;\n }\n return false;\n }\n\n const getSelectedOptions = () => {\n let result: any = value ?? [];\n switch (dataType) {\n case 'OptionSet': {\n result = [value]\n break;\n }\n case 'TwoOptions': {\n result = [+value];\n break;\n }\n }\n return options.filter(option => result?.includes(option.Value)) ?? [];\n }\n\n if (shouldRenderDefaultLabel()) {\n return <DefaultContentRenderer />\n }\n return (<div {...optionSetProps.containerProps}>\n {getSelectedOptions().map(option => {\n return <ColorfulOption\n key={option.Value}\n optionSetProps={optionSetProps}\n option={option}\n context={props.context} />\n })}\n </div>)\n}\n\nconst ColorfulOption = (props: {\n option: ComponentFramework.PropertyHelper.OptionMetadata,\n context: IContext;\n optionSetProps: IOptionSetProps\n}) => {\n const theme = useTheme();\n const option = props.option;\n const backgroundColor = option.Color ?? theme.palette.neutralLight;\n const textColor = Theming.GetTextColorForBackground(backgroundColor);\n const styles = useMemo(() => getColorfulOptionStyles(), []);\n const optionTheme = useThemeGenerator(textColor, backgroundColor, textColor, merge({}, {\n fonts: {\n medium: {\n fontWeight: 600\n }\n }\n } as PartialTheme, props.context.fluentDesignLanguage?.v8FluentOverrides as PartialTheme));\n\n const optionProps = props.optionSetProps.onGetOptionProps({\n containerProps: {\n className: styles.option,\n theme: optionTheme\n },\n option: option,\n textProps: {\n children: option.Label\n }\n })\n\n return (\n <ThemeProvider {...optionProps.containerProps}>\n <Text {...optionProps.textProps}>{optionProps.textProps.children}</Text>\n </ThemeProvider>\n )\n}"],"names":["_jsx"],"mappings":";;;;;;;;AAca,MAAA,SAAS,GAAG,CAAC,KAAuD,KAAI;IACjF,MAAM,QAAQ,GAAa,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAgB,CAAC;IACnE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;IAC1D,MAAM,KAAK,GAAQ,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9C,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,kBAAkB,EAAE,EAAE,EAAE,CAAC,CAAC;AACvD,IAAA,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;AAE3C,IAAA,MAAM,cAAc,GAAG,cAAc,CAAC,mBAAmB,CAAC;AACtD,QAAA,cAAc,EAAE;YACZ,SAAS,EAAE,MAAM,CAAC,IAAI;AACzB,SAAA;AACD,QAAA,gBAAgB,EAAE,CAAC,KAAK,KAAK,KAAK;AACrC,KAAA,CAAC,CAAA;IAEF,MAAM,wBA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=> IOptionSetProps;
|
|
37
37
|
onGetLinkProps: (props: ILinkProps) => ILinkProps;
|
|
38
|
+
onRenderContent: (defaultRenderer: () => JSX.Element) => JSX.Element;
|
|
38
39
|
rootContainerProps: ThemeProviderProps;
|
|
39
40
|
contentWrapperProps: React.HTMLAttributes<HTMLDivElement>;
|
|
40
41
|
textProps: ITextProps;
|
|
@@ -213,7 +213,7 @@ const Lookup = (props) => {
|
|
|
213
213
|
}),
|
|
214
214
|
itemLimit: itemLimit,
|
|
215
215
|
onEmptyResolveSuggestions: !context.mode.isControlDisabled ? (selectedItems) => onResolveSuggestions("", selectedItems) : undefined,
|
|
216
|
-
onResolveSuggestions: onResolveSuggestions
|
|
216
|
+
onResolveSuggestions: onResolveSuggestions,
|
|
217
217
|
});
|
|
218
218
|
return (jsx(ThemeProvider, { applyTo: "none", theme: theme, className: `talxis__lookupControl ${styles.root}`, ref: ref, children: jsx(TagPicker, { ...componentProps }) }));
|
|
219
219
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lookup.js","sources":["../../../src/components/Lookup/Lookup.tsx"],"sourcesContent":["\nimport { ILayout, ILookup, IMetadata } from \"./interfaces\";\nimport { useLookup } from \"./hooks/useLookup\";\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { ThemeProvider } from \"@fluentui/react\";\nimport { IItemProps, TagPicker } from \"@talxis/react-components\";\nimport { TargetSelector } from \"./components/TargetSelector\";\nimport { useMouseOver } from \"../../hooks/useMouseOver\";\nimport { getLookupStyles, getSuggestionsCalloutStyles } from \"./styles\";\nimport { IBasePicker } from \"@fluentui/react/lib/components/pickers/BasePicker.types\";\nimport { ITag } from \"@fluentui/react/lib/components/pickers/TagPicker/TagPicker.types\";\nimport { RecordCreator } from \"./components/RecordCreator\";\nimport { useFocusIn } from \"../../hooks/useFocusIn\";\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const Lookup = (props: ILookup) => {\n const context = props.context;\n const ref = useRef<HTMLDivElement>(null);\n const componentRef = useRef<IBasePicker<ITag>>(null);\n const itemLimit = props.parameters.MultipleEnabled?.raw === true ? Infinity : 1\n const { height } = useControlSizing(props.context.mode);\n const [value, entities, labels, records, selectEntity, getSearchResults, theme] = useLookup(props);\n const styles = getLookupStyles(theme, itemLimit === 1, height);\n const suggestionsCalloutTheme = props.context.fluentDesignLanguage?.applicationTheme ?? theme;\n const suggestionsCalloutStyles = useMemo(() => getSuggestionsCalloutStyles(suggestionsCalloutTheme), [suggestionsCalloutTheme])\n const mouseOver = useMouseOver(ref);\n const isFocused = useFocusIn(ref, 100);\n const firstRenderRef = useRef(true);\n const shouldFocusRef = useRef(false);\n const [placeholder, setPlaceholder] = useState('---');\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n\n\n useEffect(() => {\n if (firstRenderRef.current) {\n firstRenderRef.current = false;\n return;\n }\n //@ts-ignore\n if (componentRef.current.state.suggestionsVisible) {\n //if the suggestions callout is open and the selected target changes, refresh the results\n forceSearch();\n }\n }, [entities])\n\n useEffect(() => {\n const onKeyPress = (ev: KeyboardEvent) => {\n if (context.mode.isControlDisabled) {\n return;\n }\n if (ev.key === 'Backspace') {\n const picker = ref.current?.querySelector('[class*=\"TALXIS__tag-picker__root\"]');\n if ((document.activeElement === picker) && value.length === 1) {\n records.select(undefined);\n setTimeout(() => {\n componentRef.current?.focusInput()\n }, 200)\n }\n }\n }\n document.addEventListener('keydown', onKeyPress)\n return () => {\n document.removeEventListener('keydown', onKeyPress);\n }\n }, [value]);\n\n useEffect(() => {\n if (props.parameters.AutoFocus?.raw === true) {\n focus();\n }\n }, []);\n\n const focus = () => {\n if (componentRef.current?.items?.length === itemLimit) {\n const el = ref.current?.querySelector(':scope>div') as HTMLDivElement;\n el?.click();\n el?.focus();\n return;\n }\n componentRef.current?.focusInput();\n }\n\n const forceSearch = async () => {\n //@ts-ignore - We need to use internal methods to show and fill the suggestions on entity change\n componentRef.current.suggestionStore.updateSuggestions([]);\n //@ts-ignore - ^^same as above\n componentRef.current.setState({\n suggestionsVisible: true,\n suggestionsLoading: true,\n });\n //@ts-ignore - ^^same as above\n const results = await onResolveSuggestions(componentRef.current.input.current.value)\n //@ts-ignore - ^^same as above\n componentRef.current.updateSuggestionsList(results);\n //@ts-ignore - ^^same above\n componentRef.current.setState({\n isMostRecentlyUsedVisible: false,\n suggestionsVisible: true,\n moreSuggestionsAvailable: false,\n });\n }\n\n const isComponentActive = () => {\n return mouseOver || isFocused;\n }\n\n const getSecondaryName = (result: ComponentFramework.LookupValue & {\n entityData: {\n [key: string]: any;\n };\n layout: ILayout;\n }, metadata?: IMetadata) => {\n //polymorphic, selected all\n if (!entities.find(x => x.selected)) {\n return metadata?.DisplayName;\n }\n else {\n let text: string | undefined = result.entityData[result.layout?.Rows?.[0]?.Cells?.[1]?.Name];\n const dateRegex = /\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z/;\n if(typeof text === 'string' && text.match(dateRegex)) {\n text = props.context.formatting.formatTime(dayjs(text).toDate(), 1);\n }\n return text;\n }\n }\n\n const onResolveSuggestions = async (filter: string, selectedItems?: IItemProps[] | undefined): Promise<IItemProps[]> => {\n //TODO: onResolveSuggestions gets called when the record gets selected resulting in unnecessary call\n const results = await getSearchResults(filter);\n const suggestions: IItemProps[] = [];\n for (const result of results) {\n if (selectedItems?.find(x => x.key === result.id)) {\n continue;\n }\n const metadata = await entities.find(x => x.entityName === result.entityType)?.metadata;\n suggestions.push({\n key: result.id,\n text: result.name,\n secondaryText: getSecondaryName(result, metadata),\n 'data-entity': result.entityType\n })\n }\n return suggestions;\n }\n const componentProps = onOverrideComponentProps({\n ref: componentRef,\n readOnly: context.mode.isControlDisabled,\n resolveDelay: 200,\n stackItems: itemLimit === 1,\n errorMessage: props.parameters.value.errorMessage,\n hideErrorMessage: !props.parameters.ShowErrorMessage?.raw,\n pickerCalloutProps: {\n layerProps: {\n eventBubblingEnabled: true\n },\n className: suggestionsCalloutStyles.suggestionsCallout,\n theme: suggestionsCalloutTheme,\n \n },\n inputProps: {\n placeholder: placeholder,\n onMouseEnter: () => {\n if (context.mode.isControlDisabled) {\n return;\n }\n setPlaceholder(`${labels.placeholder()} ${props.parameters.value.attributes.DisplayName}`);\n },\n onMouseLeave: () => {\n setPlaceholder(\"---\");\n }\n\n },\n pickerSuggestionsProps: {\n loadingText: labels.searching(),\n theme: suggestionsCalloutTheme,\n noResultsFoundText: labels.noRecordsFound(),\n className: suggestionsCalloutStyles.suggestionsContainer,\n // @ts-ignore\n suggestionsHeaderText: (\n <>\n {props.parameters.IsInlineNewEnabled?.raw !== false && (\n <RecordCreator labels={labels} entities={entities} onCreateRecord={records.create} />\n )}\n {props.parameters.value.attributes.Targets.length > 1 && (\n <TargetSelector\n labels={labels}\n entities={entities}\n onEntitySelected={(entityName) => {\n selectEntity(entityName);\n }}\n />\n )}\n </>\n )\n },\n transparent: itemLimit === 1,\n onChange: (items) => {\n records.select(\n items?.map((item) => {\n return {\n entityType: item['data-entity'],\n id: item.key,\n name: item.text\n };\n })\n );\n },\n searchBtnProps: {\n key: 'search',\n iconProps: {\n iconName: 'Search'\n },\n showOnlyOnHover: true\n },\n selectedItems: value.map((lookup) => {\n return {\n key: lookup.id,\n text: lookup.name || labels.noName(),\n 'data-entity': lookup.entityType,\n 'data-navigation-enabled': props.parameters.EnableNavigation?.raw !== false,\n onClick: () => {\n if (props.parameters.EnableNavigation?.raw === false) {\n return;\n }\n context.navigation.openForm({\n entityName: lookup.entityType,\n entityId: lookup.id\n });\n },\n deleteButtonProps:\n isComponentActive() || itemLimit > 1\n ? {\n key: 'delete',\n iconProps: {\n iconName: 'Cancel',\n },\n onClick: () => {\n shouldFocusRef.current = false;\n records.deselect(lookup);\n setTimeout(() => {\n focus();\n }, 200);\n }\n }\n : undefined\n };\n }),\n itemLimit: itemLimit,\n onEmptyResolveSuggestions: !context.mode.isControlDisabled ? (selectedItems) => onResolveSuggestions(\"\", selectedItems as IItemProps[]) as any : undefined,\n onResolveSuggestions: onResolveSuggestions\n });\n\n return (\n <ThemeProvider applyTo=\"none\" theme={theme} className={`talxis__lookupControl ${styles.root}`} ref={ref}>\n <TagPicker {...componentProps} />\n </ThemeProvider>\n );\n};"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;AAgBa,MAAA,MAAM,GAAG,CAAC,KAAc,KAAI;AACrC,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AACzC,IAAA,MAAM,YAAY,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;AACrD,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,KAAK,IAAI,GAAG,QAAQ,GAAG,CAAC,CAAA;AAC/E,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACnG,IAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/D,MAAM,uBAAuB,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,gBAAgB,IAAI,KAAK,CAAC;AAC9F,IAAA,MAAM,wBAAwB,GAAG,OAAO,CAAC,MAAM,2BAA2B,CAAC,uBAAuB,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAA;AAC/H,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACvC,IAAA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GAAG,CAAC,aAAa,KAAK,oBAAoB,CAAC,EAAE,EAAE,aAA6B,CAAQ,GAAG,SAAS;AAC1J,QAAA,oBAAoB,EAAE,oBAAoB;AAC7C,KAAA,CAAC,CAAC;AAEH,IAAA,QACIA,GAAA,CAAC,aAAa,EAAA,EAAC,OAAO,EAAC,MAAM,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA,sBAAA,EAAyB,MAAM,CAAC,IAAI,CAAA,CAAE,EAAE,GAAG,EAAE,GAAG,EAAA,QAAA,EACnGA,GAAC,CAAA,SAAS,EAAK,EAAA,GAAA,cAAc,EAAI,CAAA,EAAA,CACrB,EAClB;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"Lookup.js","sources":["../../../src/components/Lookup/Lookup.tsx"],"sourcesContent":["\nimport { ILayout, ILookup, IMetadata } from \"./interfaces\";\nimport { useLookup } from \"./hooks/useLookup\";\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { ThemeProvider } from \"@fluentui/react\";\nimport { IItemProps, TagPicker } from \"@talxis/react-components\";\nimport { TargetSelector } from \"./components/TargetSelector\";\nimport { useMouseOver } from \"../../hooks/useMouseOver\";\nimport { getLookupStyles, getSuggestionsCalloutStyles } from \"./styles\";\nimport { IBasePicker } from \"@fluentui/react/lib/components/pickers/BasePicker.types\";\nimport { ITag } from \"@fluentui/react/lib/components/pickers/TagPicker/TagPicker.types\";\nimport { RecordCreator } from \"./components/RecordCreator\";\nimport { useFocusIn } from \"../../hooks/useFocusIn\";\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const Lookup = (props: ILookup) => {\n const context = props.context;\n const ref = useRef<HTMLDivElement>(null);\n const componentRef = useRef<IBasePicker<ITag>>(null);\n const itemLimit = props.parameters.MultipleEnabled?.raw === true ? Infinity : 1\n const { height } = useControlSizing(props.context.mode);\n const [value, entities, labels, records, selectEntity, getSearchResults, theme] = useLookup(props);\n const styles = getLookupStyles(theme, itemLimit === 1, height);\n const suggestionsCalloutTheme = props.context.fluentDesignLanguage?.applicationTheme ?? theme;\n const suggestionsCalloutStyles = useMemo(() => getSuggestionsCalloutStyles(suggestionsCalloutTheme), [suggestionsCalloutTheme])\n const mouseOver = useMouseOver(ref);\n const isFocused = useFocusIn(ref, 100);\n const firstRenderRef = useRef(true);\n const shouldFocusRef = useRef(false);\n const [placeholder, setPlaceholder] = useState('---');\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n\n\n useEffect(() => {\n if (firstRenderRef.current) {\n firstRenderRef.current = false;\n return;\n }\n //@ts-ignore\n if (componentRef.current.state.suggestionsVisible) {\n //if the suggestions callout is open and the selected target changes, refresh the results\n forceSearch();\n }\n }, [entities])\n\n useEffect(() => {\n const onKeyPress = (ev: KeyboardEvent) => {\n if (context.mode.isControlDisabled) {\n return;\n }\n if (ev.key === 'Backspace') {\n const picker = ref.current?.querySelector('[class*=\"TALXIS__tag-picker__root\"]');\n if ((document.activeElement === picker) && value.length === 1) {\n records.select(undefined);\n setTimeout(() => {\n componentRef.current?.focusInput()\n }, 200)\n }\n }\n }\n document.addEventListener('keydown', onKeyPress)\n return () => {\n document.removeEventListener('keydown', onKeyPress);\n }\n }, [value]);\n\n useEffect(() => {\n if (props.parameters.AutoFocus?.raw === true) {\n focus();\n }\n }, []);\n\n const focus = () => {\n if (componentRef.current?.items?.length === itemLimit) {\n const el = ref.current?.querySelector(':scope>div') as HTMLDivElement;\n el?.click();\n el?.focus();\n return;\n }\n componentRef.current?.focusInput();\n }\n\n const forceSearch = async () => {\n //@ts-ignore - We need to use internal methods to show and fill the suggestions on entity change\n componentRef.current.suggestionStore.updateSuggestions([]);\n //@ts-ignore - ^^same as above\n componentRef.current.setState({\n suggestionsVisible: true,\n suggestionsLoading: true,\n });\n //@ts-ignore - ^^same as above\n const results = await onResolveSuggestions(componentRef.current.input.current.value)\n //@ts-ignore - ^^same as above\n componentRef.current.updateSuggestionsList(results);\n //@ts-ignore - ^^same above\n componentRef.current.setState({\n isMostRecentlyUsedVisible: false,\n suggestionsVisible: true,\n moreSuggestionsAvailable: false,\n });\n }\n\n const isComponentActive = () => {\n return mouseOver || isFocused;\n }\n\n const getSecondaryName = (result: ComponentFramework.LookupValue & {\n entityData: {\n [key: string]: any;\n };\n layout: ILayout;\n }, metadata?: IMetadata) => {\n //polymorphic, selected all\n if (!entities.find(x => x.selected)) {\n return metadata?.DisplayName;\n }\n else {\n let text: string | undefined = result.entityData[result.layout?.Rows?.[0]?.Cells?.[1]?.Name];\n const dateRegex = /\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z/;\n if (typeof text === 'string' && text.match(dateRegex)) {\n text = props.context.formatting.formatTime(dayjs(text).toDate(), 1);\n }\n return text;\n }\n }\n\n const onResolveSuggestions = async (filter: string, selectedItems?: IItemProps[] | undefined): Promise<IItemProps[]> => {\n //TODO: onResolveSuggestions gets called when the record gets selected resulting in unnecessary call\n const results = await getSearchResults(filter);\n const suggestions: IItemProps[] = [];\n for (const result of results) {\n if (selectedItems?.find(x => x.key === result.id)) {\n continue;\n }\n const metadata = await entities.find(x => x.entityName === result.entityType)?.metadata;\n suggestions.push({\n key: result.id,\n text: result.name,\n secondaryText: getSecondaryName(result, metadata),\n 'data-entity': result.entityType\n })\n }\n return suggestions;\n }\n\n const componentProps = onOverrideComponentProps({\n ref: componentRef,\n readOnly: context.mode.isControlDisabled,\n resolveDelay: 200,\n stackItems: itemLimit === 1,\n errorMessage: props.parameters.value.errorMessage,\n hideErrorMessage: !props.parameters.ShowErrorMessage?.raw,\n pickerCalloutProps: {\n layerProps: {\n eventBubblingEnabled: true\n },\n className: suggestionsCalloutStyles.suggestionsCallout,\n theme: suggestionsCalloutTheme,\n },\n inputProps: {\n placeholder: placeholder,\n onMouseEnter: () => {\n if (context.mode.isControlDisabled) {\n return;\n }\n setPlaceholder(`${labels.placeholder()} ${props.parameters.value.attributes.DisplayName}`);\n },\n onMouseLeave: () => {\n setPlaceholder(\"---\");\n }\n\n },\n pickerSuggestionsProps: {\n loadingText: labels.searching(),\n theme: suggestionsCalloutTheme,\n noResultsFoundText: labels.noRecordsFound(),\n className: suggestionsCalloutStyles.suggestionsContainer,\n // @ts-ignore\n suggestionsHeaderText: (\n <>\n {props.parameters.IsInlineNewEnabled?.raw !== false && (\n <RecordCreator labels={labels} entities={entities} onCreateRecord={records.create} />\n )}\n {props.parameters.value.attributes.Targets.length > 1 && (\n <TargetSelector\n labels={labels}\n entities={entities}\n onEntitySelected={(entityName) => {\n selectEntity(entityName);\n }}\n />\n )}\n </>\n )\n },\n transparent: itemLimit === 1,\n onChange: (items) => {\n records.select(\n items?.map((item) => {\n return {\n entityType: item['data-entity'],\n id: item.key,\n name: item.text\n };\n })\n );\n },\n searchBtnProps: {\n key: 'search',\n iconProps: {\n iconName: 'Search'\n },\n showOnlyOnHover: true\n },\n selectedItems: value.map((lookup) => {\n return {\n key: lookup.id,\n text: lookup.name || labels.noName(),\n 'data-entity': lookup.entityType,\n 'data-navigation-enabled': props.parameters.EnableNavigation?.raw !== false,\n onClick: () => {\n if (props.parameters.EnableNavigation?.raw === false) {\n return;\n }\n context.navigation.openForm({\n entityName: lookup.entityType,\n entityId: lookup.id\n });\n },\n deleteButtonProps:\n isComponentActive() || itemLimit > 1\n ? {\n key: 'delete',\n iconProps: {\n iconName: 'Cancel',\n },\n onClick: () => {\n shouldFocusRef.current = false;\n records.deselect(lookup);\n setTimeout(() => {\n focus();\n }, 200);\n }\n }\n : undefined\n };\n }),\n itemLimit: itemLimit,\n onEmptyResolveSuggestions: !context.mode.isControlDisabled ? (selectedItems) => onResolveSuggestions(\"\", selectedItems as IItemProps[]) as any : undefined,\n onResolveSuggestions: onResolveSuggestions,\n });\n\n return (\n <ThemeProvider applyTo=\"none\" theme={theme} className={`talxis__lookupControl ${styles.root}`} ref={ref}>\n <TagPicker {...componentProps} />\n </ThemeProvider>\n );\n};"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;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,MAAM,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA,sBAAA,EAAyB,MAAM,CAAC,IAAI,CAAA,CAAE,EAAE,GAAG,EAAE,GAAG,EAAA,QAAA,EACnGA,GAAC,CAAA,SAAS,EAAK,EAAA,GAAA,cAAc,EAAI,CAAA,EAAA,CACrB,EAClB;AACN;;;;"}
|
|
@@ -82,10 +82,11 @@ const useLookup = (props) => {
|
|
|
82
82
|
return result;
|
|
83
83
|
};
|
|
84
84
|
const createRecord = async (entityName) => {
|
|
85
|
+
const formParameters = props.onGetOnCreateFormParameters?.(entityName);
|
|
85
86
|
const result = await context.navigation.openForm({
|
|
86
87
|
entityName: entityName,
|
|
87
88
|
useQuickCreateForm: true
|
|
88
|
-
});
|
|
89
|
+
}, formParameters);
|
|
89
90
|
if (!result.savedEntityReference) {
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLookup.js","sources":["../../../../src/components/Lookup/hooks/useLookup.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { ITranslation, useControl } from \"../../../hooks\";\nimport { IEntity, ILayout, ILookup } from \"../interfaces\";\nimport { lookupTranslations } from \"../translations\";\nimport { useFetchXml } from \"./useFetchXml\";\nimport { ITheme } from \"@talxis/react-components\";\n\nexport const useLookup = (props: ILookup): [\n ComponentFramework.LookupValue[],\n IEntity[],\n ITranslation<Required<ILookup>['translations']>,\n {\n create: (entityName: string) => void,\n select: (record: ComponentFramework.LookupValue[] | undefined) => void,\n deselect: (record: ComponentFramework.LookupValue) => void,\n },\n (entityName: string | null) => void,\n (query: string) => Promise<(ComponentFramework.LookupValue & {entityData: {[key: string]: any}, layout: ILayout})[]>,\n ITheme\n] => {\n\n const targets = props.parameters.value.attributes.Targets;\n const boundValue = props.parameters.value.raw;\n const context = props.context;\n const {labels, theme, onNotifyOutputChanged} = useControl('Lookup', props, lookupTranslations);\n const [getFetchXml, applyLookupQuery] = useFetchXml(context);\n \n const [entities, setEntities] = useState<IEntity[]>(() => {\n return targets.map(target => {\n return {\n entityName: target,\n selected: targets.length === 1 ? true : false,\n metadata: props.context.utils.getEntityMetadata(target, []) as any,\n }\n })\n });\n\n const selectedEntity = entities.find(x => x.selected);\n\n const selectEntity = (entityName: string | null) => {\n setEntities([...entities as IEntity[]].map(entity => {\n return {\n entityName: entity.entityName,\n metadata: entity.metadata,\n selected: entity.entityName === entityName\n }\n }))\n }\n\n const selectRecords = (records: ComponentFramework.LookupValue[] | undefined) => {\n onNotifyOutputChanged({\n value: records\n })\n }\n const getSearchFetchXml = async (entityName: string, query: string, viewIdCallBack: (id: string) => void): Promise<string> => {\n const response = (await props.parameters.value.getAllViews(entityName)).find(x => x.isDefault);\n if (!response?.viewId) {\n throw new Error(`Entity ${entityName} does not have a default view id!`);\n }\n viewIdCallBack(response.viewId);\n let fetchXml = response?.fetchXml\n if(!fetchXml) {\n fetchXml = (await getFetchXml(response.viewId)).fetchxml;\n }\n return applyLookupQuery(entities.find(x => x.entityName === entityName)!, fetchXml, query);\n\n }\n const getSearchResults = async (query: string): Promise<(ComponentFramework.LookupValue & {entityData: {[key: string]: any}, layout: ILayout})[]> => {\n if(props.onSearch) { \n return props.onSearch(selectedEntity ? [selectedEntity?.entityName] : targets, query) as any;\n }\n const fetchXmlMap = new Map<string, Promise<string>>();\n const entityViewIdMap = new Map<string, string>();\n if(selectedEntity) {\n fetchXmlMap.set(selectedEntity.entityName, getSearchFetchXml(selectedEntity.entityName, query, (viewId) => entityViewIdMap.set(selectedEntity.entityName, viewId)))\n }\n else {\n for (const entity of targets) {\n fetchXmlMap.set(entity, getSearchFetchXml(entity, query, (viewId) => entityViewIdMap.set(entity, viewId)))\n }\n }\n await Promise.all(fetchXmlMap.values());\n const responsePromiseMap = new Map<string, Promise<ComponentFramework.WebApi.RetrieveMultipleResponse>>()\n for (const [entityName, fetchXml] of fetchXmlMap) {\n responsePromiseMap.set(entityName, context.webAPI.retrieveMultipleRecords(entityName, `?$top=25&fetchXml=${encodeURIComponent((await fetchXml))}`))\n }\n await Promise.all(responsePromiseMap.values());\n const result: (ComponentFramework.LookupValue & {entityData: {[key: string]: any}, layout: ILayout})[] = [];\n for (const [entityName, response] of responsePromiseMap) {\n const layout: ILayout = JSON.parse((await getFetchXml(entityViewIdMap.get(entityName)!)).layoutjson ?? \"{}\");\n for (const entity of (await response).entities) {\n const entityMetadata = await entities.find(x => x.entityName === entityName)!.metadata;\n result.push({\n entityType: entityName,\n id: entity[entityMetadata.PrimaryIdAttribute],\n name: entity[layout.Rows?.[0]?.Cells?.[0]?.Name] ?? entity[entityMetadata.PrimaryNameAttribute] ?? labels.noName(),\n entityData: entity,\n layout: layout\n });\n }\n }\n return result;\n }\n\n const createRecord = async (entityName: string) => {\n const result = await context.navigation.openForm({\n entityName: entityName,\n useQuickCreateForm: true\n });\n if (!result.savedEntityReference) {\n return;\n }\n onNotifyOutputChanged({\n value: [\n ...boundValue,\n ...result.savedEntityReference\n ]\n })\n }\n\n const deselectRecord = (record: ComponentFramework.LookupValue) => {\n const map = new Map<string, ComponentFramework.LookupValue>(boundValue.map(value => [value.id, value]));\n map.delete(record.id);\n onNotifyOutputChanged({\n value: [...map.values()]\n })\n }\n\n return [\n boundValue, entities, labels, {\n create: createRecord,\n deselect: deselectRecord,\n select: selectRecords\n },\n selectEntity,\n getSearchResults,\n theme\n ];\n};"],"names":[],"mappings":";;;;;AAOa,MAAA,SAAS,GAAG,CAAC,KAAc,KAYpC;IAEA,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;IAC1D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,EAAC,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAC,GAAG,UAAU,CAAC,QAAQ,EAAE,KA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OAAO;AACH,QAAA,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1B,YAAA,MAAM,EAAE,YAAY;AACpB,YAAA,QAAQ,EAAE,cAAc;AACxB,YAAA,MAAM,EAAE,aAAa;AACxB,SAAA;QACD,YAAY;QACZ,gBAAgB;QAChB,KAAK;KACR,CAAC;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"useLookup.js","sources":["../../../../src/components/Lookup/hooks/useLookup.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { ITranslation, useControl } from \"../../../hooks\";\nimport { IEntity, ILayout, ILookup } from \"../interfaces\";\nimport { lookupTranslations } from \"../translations\";\nimport { useFetchXml } from \"./useFetchXml\";\nimport { ITheme } from \"@talxis/react-components\";\n\nexport const useLookup = (props: ILookup): [\n ComponentFramework.LookupValue[],\n IEntity[],\n ITranslation<Required<ILookup>['translations']>,\n {\n create: (entityName: string) => void,\n select: (record: ComponentFramework.LookupValue[] | undefined) => void,\n deselect: (record: ComponentFramework.LookupValue) => void,\n },\n (entityName: string | null) => void,\n (query: string) => Promise<(ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[]>,\n ITheme\n] => {\n\n const targets = props.parameters.value.attributes.Targets;\n const boundValue = props.parameters.value.raw;\n const context = props.context;\n const { labels, theme, onNotifyOutputChanged } = useControl('Lookup', props, lookupTranslations);\n const [getFetchXml, applyLookupQuery] = useFetchXml(context);\n\n const [entities, setEntities] = useState<IEntity[]>(() => {\n return targets.map(target => {\n return {\n entityName: target,\n selected: targets.length === 1 ? true : false,\n metadata: props.context.utils.getEntityMetadata(target, []) as any,\n }\n })\n });\n\n const selectedEntity = entities.find(x => x.selected);\n\n const selectEntity = (entityName: string | null) => {\n setEntities([...entities as IEntity[]].map(entity => {\n return {\n entityName: entity.entityName,\n metadata: entity.metadata,\n selected: entity.entityName === entityName\n }\n }))\n }\n\n const selectRecords = (records: ComponentFramework.LookupValue[] | undefined) => {\n onNotifyOutputChanged({\n value: records\n })\n }\n const getSearchFetchXml = async (entityName: string, query: string, viewIdCallBack: (id: string) => void): Promise<string> => {\n const response = (await props.parameters.value.getAllViews(entityName)).find(x => x.isDefault);\n if (!response?.viewId) {\n throw new Error(`Entity ${entityName} does not have a default view id!`);\n }\n viewIdCallBack(response.viewId);\n let fetchXml = response?.fetchXml\n if (!fetchXml) {\n fetchXml = (await getFetchXml(response.viewId)).fetchxml;\n }\n return applyLookupQuery(entities.find(x => x.entityName === entityName)!, fetchXml, query);\n\n }\n const getSearchResults = async (query: string): Promise<(ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[]> => {\n if (props.onSearch) {\n return props.onSearch(selectedEntity ? [selectedEntity?.entityName] : targets, query) as any;\n }\n const fetchXmlMap = new Map<string, Promise<string>>();\n const entityViewIdMap = new Map<string, string>();\n if (selectedEntity) {\n fetchXmlMap.set(selectedEntity.entityName, getSearchFetchXml(selectedEntity.entityName, query, (viewId) => entityViewIdMap.set(selectedEntity.entityName, viewId)))\n }\n else {\n for (const entity of targets) {\n fetchXmlMap.set(entity, getSearchFetchXml(entity, query, (viewId) => entityViewIdMap.set(entity, viewId)))\n }\n }\n await Promise.all(fetchXmlMap.values());\n const responsePromiseMap = new Map<string, Promise<ComponentFramework.WebApi.RetrieveMultipleResponse>>()\n for (const [entityName, fetchXml] of fetchXmlMap) {\n responsePromiseMap.set(entityName, context.webAPI.retrieveMultipleRecords(entityName, `?$top=25&fetchXml=${encodeURIComponent((await fetchXml))}`))\n }\n await Promise.all(responsePromiseMap.values());\n const result: (ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[] = [];\n for (const [entityName, response] of responsePromiseMap) {\n const layout: ILayout = JSON.parse((await getFetchXml(entityViewIdMap.get(entityName)!)).layoutjson ?? \"{}\");\n for (const entity of (await response).entities) {\n const entityMetadata = await entities.find(x => x.entityName === entityName)!.metadata;\n result.push({\n entityType: entityName,\n id: entity[entityMetadata.PrimaryIdAttribute],\n name: entity[layout.Rows?.[0]?.Cells?.[0]?.Name] ?? entity[entityMetadata.PrimaryNameAttribute] ?? labels.noName(),\n entityData: entity,\n layout: layout\n });\n }\n }\n return result;\n }\n\n const createRecord = async (entityName: string) => {\n const formParameters = props.onGetOnCreateFormParameters?.(entityName)\n const result = await context.navigation.openForm({\n entityName: entityName,\n useQuickCreateForm: true\n }, formParameters);\n if (!result.savedEntityReference) {\n return;\n }\n onNotifyOutputChanged({\n value: [\n ...boundValue,\n ...result.savedEntityReference\n ]\n });\n }\n\n const deselectRecord = (record: ComponentFramework.LookupValue) => {\n const map = new Map<string, ComponentFramework.LookupValue>(boundValue.map(value => [value.id, value]));\n map.delete(record.id);\n onNotifyOutputChanged({\n value: [...map.values()]\n })\n }\n\n return [\n boundValue, entities, labels, {\n create: createRecord,\n deselect: deselectRecord,\n select: selectRecords\n },\n selectEntity,\n getSearchResults,\n theme\n ];\n};"],"names":[],"mappings":";;;;;AAOa,MAAA,SAAS,GAAG,CAAC,KAAc,KAYpC;IAEA,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;IAC1D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACjG,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAE7D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAY,MAAK;AACrD,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,IAAG;YACxB,OAAO;AACH,gBAAA,UAAU,EAAE,MAAM;AAClB,gBAAA,QAAQ,EAAE,OAAO,CA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,14 @@ export interface ILookup extends IControl<ILookupParameters, ILookupOutputs, Par
|
|
|
12
12
|
* @returns {any}
|
|
13
13
|
*/
|
|
14
14
|
onSearch?: (entityNames: string[], query: string) => Promise<ComponentFramework.LookupValue[]>;
|
|
15
|
+
/**
|
|
16
|
+
* When new record is being created, this function is called beforehand and its return value is used to populate the form.
|
|
17
|
+
* @param {any} entityName The name of the entity that is being created.
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
onGetOnCreateFormParameters?: (entityName: string) => {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
} | undefined;
|
|
15
23
|
}
|
|
16
24
|
export interface ILookupParameters extends IBaseParameters {
|
|
17
25
|
IsInlineNewEnabled?: Omit<ITwoOptionsProperty, 'attributes'>;
|
package/dist/index.d.ts
CHANGED
|
@@ -480,6 +480,10 @@ declare const gridTranslations: {
|
|
|
480
480
|
1029: string;
|
|
481
481
|
1033: string;
|
|
482
482
|
};
|
|
483
|
+
"filtersortmenu-clearsorting": {
|
|
484
|
+
1029: string;
|
|
485
|
+
1033: string;
|
|
486
|
+
};
|
|
483
487
|
"paging-of": {
|
|
484
488
|
1029: string;
|
|
485
489
|
1033: string;
|
|
@@ -606,7 +610,13 @@ declare const gridTranslations: {
|
|
|
606
610
|
};
|
|
607
611
|
};
|
|
608
612
|
|
|
609
|
-
interface
|
|
613
|
+
interface IGridComponentProps {
|
|
614
|
+
agGrid: AgGridReactProps;
|
|
615
|
+
registerRowGroupingModule: boolean;
|
|
616
|
+
container: any;
|
|
617
|
+
pagingProps: any;
|
|
618
|
+
}
|
|
619
|
+
interface IGrid extends IControl<IGridParameters, IGridOutputs, Partial<ITranslation<typeof gridTranslations>>, IGridComponentProps> {
|
|
610
620
|
}
|
|
611
621
|
interface IGridParameters extends IParameters$1 {
|
|
612
622
|
EnableEditing?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
@@ -617,7 +627,9 @@ interface IGridParameters extends IParameters$1 {
|
|
|
617
627
|
EnableOptionSetColors?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
618
628
|
EnableChangeEditor?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
619
629
|
EnableMultiEdit?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
630
|
+
EnableZebra?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
620
631
|
RowHeight?: Omit<IWholeNumberProperty, 'attributes'>;
|
|
632
|
+
EnablePageSizeSwitcher?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
621
633
|
Height?: IStringProperty;
|
|
622
634
|
InlineRibbonButtonIds?: IStringProperty;
|
|
623
635
|
SelectableRows?: Omit<ComponentFramework.PropertyTypes.EnumProperty<"none" | "single" | "multiple">, 'type'>;
|
|
@@ -659,6 +671,7 @@ interface IDatasetControlComponentProps {
|
|
|
659
671
|
onRender: (renderQuickFind: () => React.ReactElement) => React.ReactElement;
|
|
660
672
|
onGetQuickFindProps: (props: IQuickFindProps) => IQuickFindProps;
|
|
661
673
|
};
|
|
674
|
+
onOverrideControlProps: (props: IGridComponentProps) => IGridComponentProps;
|
|
662
675
|
}
|
|
663
676
|
interface IDatasetControl extends IControl<IGridParameters, IGridOutputs, Partial<ITranslation<typeof datasetControlTranslations & typeof gridTranslations>>, IDatasetControlComponentProps> {
|
|
664
677
|
EnableQuickFind?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
@@ -786,6 +799,7 @@ interface IOptionProps {
|
|
|
786
799
|
interface IGridCellRendererComponentProps {
|
|
787
800
|
onGetOptionSetProps: (props: IOptionSetProps) => IOptionSetProps;
|
|
788
801
|
onGetLinkProps: (props: ILinkProps) => ILinkProps;
|
|
802
|
+
onRenderContent: (defaultRenderer: () => JSX.Element) => JSX.Element;
|
|
789
803
|
rootContainerProps: ThemeProviderProps;
|
|
790
804
|
contentWrapperProps: React.HTMLAttributes<HTMLDivElement>;
|
|
791
805
|
textProps: ITextProps;
|
|
@@ -844,6 +858,14 @@ interface ILookup extends IControl<ILookupParameters, ILookupOutputs, Partial<IT
|
|
|
844
858
|
* @returns {any}
|
|
845
859
|
*/
|
|
846
860
|
onSearch?: (entityNames: string[], query: string) => Promise<ComponentFramework.LookupValue[]>;
|
|
861
|
+
/**
|
|
862
|
+
* When new record is being created, this function is called beforehand and its return value is used to populate the form.
|
|
863
|
+
* @param {any} entityName The name of the entity that is being created.
|
|
864
|
+
* @returns
|
|
865
|
+
*/
|
|
866
|
+
onGetOnCreateFormParameters?: (entityName: string) => {
|
|
867
|
+
[key: string]: string;
|
|
868
|
+
} | undefined;
|
|
847
869
|
}
|
|
848
870
|
interface ILookupParameters extends IBaseParameters {
|
|
849
871
|
IsInlineNewEnabled?: Omit<ITwoOptionsProperty, 'attributes'>;
|
|
@@ -1241,4 +1263,4 @@ interface IDurationOutputs extends IOutputs$1 {
|
|
|
1241
1263
|
|
|
1242
1264
|
declare const Duration: (props: IDuration) => JSX.Element;
|
|
1243
1265
|
|
|
1244
|
-
export { BaseControl, BaseControls, ControlTheme, DatasetControl, DateTime, Decimal, Duration, Grid, GridCellRenderer, IContext, IControl, IControlController, IDatasetControl, IDatasetControlComponentProps, IDateTime, IDateTimeOutputs, IDateTimeParameters, IDateTimeProperty, IDecimal, IDecimalNumberProperty, IDecimalOutputs, IDecimalParameters, IDefaultTranslations, IDuration, IDurationOutputs, IDurationParameters, IEntity, IFileProperty, IFluentDesignState, IGrid, IGridOutputs, IGridParameters, ILayout, ILookup, ILookupOutputs, ILookupParameters, ILookupProperty, IMetadata, IMultiSelectOptionSet, IMultiSelectOptionSetOutputs, IMultiSelectOptionSetParameters, IMultiSelectOptionSetProperty, IOptionSet, IOptionSetOutputs, IOptionSetParameters, IOptionSetProperty, IOutputs, IParameters$1 as IParameters, IProperty, IQuickFindProps, IStringProperty, ITextField, ITextFieldOutputs, ITextFieldParameters, ITranslation, ITranslations, ITwoOptions, ITwoOptionsOutputs, ITwoOptionsParameters, ITwoOptionsProperty, IWholeNumberProperty, Lookup, MultiSelectOptionSet, NestedControlRenderer, OptionSet, TextField, ThemeWrapper, TwoOptions, useControl, useControlLabels, useControlSizing, useControlTheme, useControlThemeGenerator, useDateTime, useFocusIn, useInputBasedControl, useLookup, useMouseOver };
|
|
1266
|
+
export { BaseControl, BaseControls, ControlTheme, DatasetControl, DateTime, Decimal, Duration, Grid, GridCellRenderer, IContext, IControl, IControlController, IDatasetControl, IDatasetControlComponentProps, IDateTime, IDateTimeOutputs, IDateTimeParameters, IDateTimeProperty, IDecimal, IDecimalNumberProperty, IDecimalOutputs, IDecimalParameters, IDefaultTranslations, IDuration, IDurationOutputs, IDurationParameters, IEntity, IFileProperty, IFluentDesignState, IGrid, IGridComponentProps, IGridOutputs, IGridParameters, ILayout, ILookup, ILookupOutputs, ILookupParameters, ILookupProperty, IMetadata, IMultiSelectOptionSet, IMultiSelectOptionSetOutputs, IMultiSelectOptionSetParameters, IMultiSelectOptionSetProperty, IOptionSet, IOptionSetOutputs, IOptionSetParameters, IOptionSetProperty, IOutputs, IParameters$1 as IParameters, IProperty, IQuickFindProps, IStringProperty, ITextField, ITextFieldOutputs, ITextFieldParameters, ITranslation, ITranslations, ITwoOptions, ITwoOptionsOutputs, ITwoOptionsParameters, ITwoOptionsProperty, IWholeNumberProperty, Lookup, MultiSelectOptionSet, NestedControlRenderer, OptionSet, TextField, ThemeWrapper, TwoOptions, useControl, useControlLabels, useControlSizing, useControlTheme, useControlThemeGenerator, useDateTime, useFocusIn, useInputBasedControl, useLookup, useMouseOver };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talxis/base-controls",
|
|
3
|
-
"version": "1.2504.
|
|
3
|
+
"version": "1.2504.3",
|
|
4
4
|
"description": "Set of React components that natively work with Power Apps Component Framework API's",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@ag-grid-community/core": "^31.3.2",
|
|
71
71
|
"@ag-grid-community/react": "^31.3.2",
|
|
72
72
|
"@ag-grid-community/styles": "^31.3.2",
|
|
73
|
+
"@ag-grid-enterprise/row-grouping": "^31.3.2",
|
|
73
74
|
"@fluentui/react-migration-v8-v9": "^9.6.20",
|
|
74
75
|
"color": "^4.2.3",
|
|
75
76
|
"dayjs": "^1.11.10",
|
|
@@ -85,8 +86,8 @@
|
|
|
85
86
|
"peerDependencies": {
|
|
86
87
|
"react": "^16.8.6 || ^17.0.2",
|
|
87
88
|
"react-dom": "^16.8.6 || ^17.0.2",
|
|
88
|
-
"@talxis/react-components": "^1.2503.
|
|
89
|
-
"@talxis/client-libraries": "^1.
|
|
89
|
+
"@talxis/react-components": "^1.2503.4",
|
|
90
|
+
"@talxis/client-libraries": "^1.2504.1",
|
|
90
91
|
"@fluentui/react": "<=8.121.5"
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
|
|
3
|
-
class ErrorBoundary extends React__default.Component {
|
|
4
|
-
constructor(props) {
|
|
5
|
-
super(props);
|
|
6
|
-
this.state = { hasError: false };
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
static getDerivedStateFromError(error) {
|
|
10
|
-
// Update state so the next render will show the fallback UI.
|
|
11
|
-
return { hasError: true };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
componentDidCatch(error, info) {
|
|
15
|
-
console.error(error);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
resetError() {
|
|
19
|
-
this.setState({ hasError: false });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
render() {
|
|
23
|
-
if (this.state.hasError) {
|
|
24
|
-
// You can render any custom fallback UI
|
|
25
|
-
return this.props.fallback(() => this.resetError());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return this.props.children;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { ErrorBoundary };
|
|
33
|
-
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sources":["../../../src/components/DatasetControl/ErrorBoundary.js"],"sourcesContent":["import React from 'react';\n\nexport class ErrorBoundary extends React.Component {\n constructor(props) {\n super(props);\n this.state = { hasError: false };\n }\n \n static getDerivedStateFromError(error) {\n // Update state so the next render will show the fallback UI.\n return { hasError: true };\n }\n \n componentDidCatch(error, info) {\n console.error(error);\n }\n\n resetError() {\n this.setState({ hasError: false });\n }\n \n render() {\n if (this.state.hasError) {\n // You can render any custom fallback UI\n return this.props.fallback(() => this.resetError());\n }\n \n return this.props.children;\n }\n }"],"names":["React"],"mappings":";;AAEO,MAAM,aAAa,SAASA,cAAK,CAAC,SAAS,CAAC;AACnD,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC;AACnB,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACvC,KAAK;AACL;AACA,IAAI,OAAO,wBAAwB,CAAC,KAAK,EAAE;AAC3C;AACA,MAAM,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChC,KAAK;AACL;AACA,IAAI,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE;AACnC,QAAQ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC7B,KAAK;AACL;AACA,IAAI,UAAU,GAAG;AACjB,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AACzC,KAAK;AACL;AACA,IAAI,MAAM,GAAG;AACb,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;AAC/B;AACA,QAAQ,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;AAC5D,OAAO;AACP;AACA,MAAM,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;AACjC,KAAK;AACL;;;;"}
|