@talxis/base-controls 1.2503.11 → 1.2504.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/dist/components/DatasetControl/DatasetControl.js +1 -1
- package/dist/components/DatasetControl/DatasetControl.js.map +1 -1
- package/dist/components/DatasetControl/QuickFind/QuickFind.d.ts +6 -4
- package/dist/components/DatasetControl/QuickFind/QuickFind.js +31 -24
- package/dist/components/DatasetControl/QuickFind/QuickFind.js.map +1 -1
- package/dist/components/DatasetControl/interfaces.d.ts +5 -1
- package/dist/components/DateTime/DateTime.js +7 -0
- package/dist/components/DateTime/DateTime.js.map +1 -1
- package/dist/components/DateTime/hooks/useDateTime.d.ts +1 -0
- package/dist/components/DateTime/hooks/useDateTime.js +2 -1
- package/dist/components/DateTime/hooks/useDateTime.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ const DatasetControl = (props) => {
|
|
|
53
53
|
}, []);
|
|
54
54
|
return (jsxs(ThemeProvider, { ...componentProps.containerProps, children: [jsx("div", { ...componentProps.headerProps.headerContainerProps, children: componentProps.headerProps.onRender(() => {
|
|
55
55
|
return jsx(Fragment, { children: props.parameters.EnableQuickFind?.raw &&
|
|
56
|
-
jsx(QuickFind, { dataset: dataset, labels: labels, onGetQuickFindComponentProps: (props) => componentProps.headerProps.onGetQuickFindProps(props) }) });
|
|
56
|
+
jsx(QuickFind, { dataset: dataset, labels: labels, theme: theme, onGetQuickFindComponentProps: (props) => componentProps.headerProps.onGetQuickFindProps(props) }) });
|
|
57
57
|
}) }), jsx(ErrorBoundary, { fallback: (resetError) => { renderErrorMessageBar(() => resetError()); }, children: jsx(Grid, { ...props, onOverrideComponentProps: (props) => props, context: injectedContextRef.current }) })] }));
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatasetControl.js","sources":["../../../src/components/DatasetControl/DatasetControl.tsx"],"sourcesContent":["import { useMemo, useRef } from \"react\";\nimport { Grid } from \"../Grid\";\nimport { useControl } from \"../../hooks\";\nimport { MessageBar, MessageBarButton, MessageBarType, ThemeProvider } from \"@fluentui/react\";\nimport { datasetControlTranslations } from \"./translations\";\nimport { getDatasetControlStyles } from \"./styles\";\nimport { IDatasetControl } from \"./interfaces\";\nimport { QuickFind } from \"./QuickFind/QuickFind\";\nimport { ErrorBoundary } from \"./ErrorBoundary\";\nimport { useRerender } from \"@talxis/react-components\";\n\nexport const DatasetControl = (props: IDatasetControl) => {\n const { labels, theme } = useControl('DatasetControl', props, datasetControlTranslations);\n const rerender = useRerender();\n const dataset = props.parameters.Grid;\n const injectedContextRef = useRef(props.context);\n const styles = useMemo(() => getDatasetControlStyles(theme, props.parameters.Height?.raw), []);\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n //@ts-ignore - private property\n dataset._setRenderer(() => rerender());\n\n //we need to have a way to customize the init behavior from above\n const componentProps = onOverrideComponentProps({\n onDatasetInit: () => {\n if (dataset.paging.pageNumber > 1) {\n dataset.paging.loadExactPage(dataset.paging.pageNumber)\n }\n else {\n dataset.refresh();\n }\n },\n containerProps: {\n theme: theme,\n className: styles.datasetControlRoot,\n },\n headerProps: {\n headerContainerProps: {},\n onRender: (renderQuickFind) => renderQuickFind(),\n onGetQuickFindProps: (props) => props\n },\n });\n\n const renderErrorMessageBar = (onReset?: () => void) => {\n <MessageBar\n isMultiline={false}\n actions={<MessageBarButton className={styles.messageBarBtn} text={labels.reload()} onClick={() => {\n onReset?.();\n dataset.refresh();\n }} />}\n messageBarType={MessageBarType.error}>\n {dataset.errorMessage || labels.generalError()}\n </MessageBar>\n }\n\n useMemo(() => {\n //@ts-ignore - private property\n injectedContextRef.current = dataset._patchContext(props.context);\n }, [props.context]);\n\n useMemo(() => {\n componentProps.onDatasetInit();\n }, []);\n\n\n return (\n <ThemeProvider {...componentProps.containerProps}>\n <div {...componentProps.headerProps.headerContainerProps}>\n {componentProps.headerProps.onRender(() => {\n return <>\n {props.parameters.EnableQuickFind?.raw &&\n <QuickFind dataset={dataset} labels={labels} onGetQuickFindComponentProps={(props) => componentProps.headerProps.onGetQuickFindProps(props)} />\n }\n </>\n })}\n </div>\n <ErrorBoundary fallback={(resetError: () => void) => { renderErrorMessageBar(() => resetError()) }}>\n <Grid\n {...props}\n onOverrideComponentProps={(props) => props}\n context={injectedContextRef.current} />\n </ErrorBoundary>\n </ThemeProvider>\n )\n}"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAWa,MAAA,cAAc,GAAG,CAAC,KAAsB,KAAI;AACvD,IAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,gBAAgB,EAAE,KAAK,EAAE,0BAA0B,CAAC,CAAC;AAC1F,IAAA,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;AAC/B,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;IACtC,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/F,IAAA,MAAM,wBAAwB,GAAG,KAAK,CAAC,wBAAwB,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;;IAEtF,OAAO,CAAC,YAAY,CAAC,MAAM,QAAQ,EAAE,CAAC,CAAC;;IAGvC,MAAM,cAAc,GAAG,wBAAwB,CAAC;QAC9C,aAAa,EAAE,MAAK;AAClB,YAAA,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE;gBACjC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;AACxD,aAAA;AACI,iBAAA;gBACH,OAAO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c,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAK;AACxC,oBAAA,OAAOA,0BACJ,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"DatasetControl.js","sources":["../../../src/components/DatasetControl/DatasetControl.tsx"],"sourcesContent":["import { useMemo, useRef } from \"react\";\nimport { Grid } from \"../Grid\";\nimport { useControl } from \"../../hooks\";\nimport { MessageBar, MessageBarButton, MessageBarType, ThemeProvider } from \"@fluentui/react\";\nimport { datasetControlTranslations } from \"./translations\";\nimport { getDatasetControlStyles } from \"./styles\";\nimport { IDatasetControl } from \"./interfaces\";\nimport { QuickFind } from \"./QuickFind/QuickFind\";\nimport { ErrorBoundary } from \"./ErrorBoundary\";\nimport { useRerender } from \"@talxis/react-components\";\n\nexport const DatasetControl = (props: IDatasetControl) => {\n const { labels, theme } = useControl('DatasetControl', props, datasetControlTranslations);\n const rerender = useRerender();\n const dataset = props.parameters.Grid;\n const injectedContextRef = useRef(props.context);\n const styles = useMemo(() => getDatasetControlStyles(theme, props.parameters.Height?.raw), []);\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n //@ts-ignore - private property\n dataset._setRenderer(() => rerender());\n\n //we need to have a way to customize the init behavior from above\n const componentProps = onOverrideComponentProps({\n onDatasetInit: () => {\n if (dataset.paging.pageNumber > 1) {\n dataset.paging.loadExactPage(dataset.paging.pageNumber)\n }\n else {\n dataset.refresh();\n }\n },\n containerProps: {\n theme: theme,\n className: styles.datasetControlRoot,\n },\n headerProps: {\n headerContainerProps: {},\n onRender: (renderQuickFind) => renderQuickFind(),\n onGetQuickFindProps: (props) => props\n },\n });\n\n const renderErrorMessageBar = (onReset?: () => void) => {\n <MessageBar\n isMultiline={false}\n actions={<MessageBarButton className={styles.messageBarBtn} text={labels.reload()} onClick={() => {\n onReset?.();\n dataset.refresh();\n }} />}\n messageBarType={MessageBarType.error}>\n {dataset.errorMessage || labels.generalError()}\n </MessageBar>\n }\n\n useMemo(() => {\n //@ts-ignore - private property\n injectedContextRef.current = dataset._patchContext(props.context);\n }, [props.context]);\n\n useMemo(() => {\n componentProps.onDatasetInit();\n }, []);\n\n\n return (\n <ThemeProvider {...componentProps.containerProps}>\n <div {...componentProps.headerProps.headerContainerProps}>\n {componentProps.headerProps.onRender(() => {\n return <>\n {props.parameters.EnableQuickFind?.raw &&\n <QuickFind \n dataset={dataset} \n labels={labels} \n theme={theme}\n onGetQuickFindComponentProps={(props) => componentProps.headerProps.onGetQuickFindProps(props)} />\n }\n </>\n })}\n </div>\n <ErrorBoundary fallback={(resetError: () => void) => { renderErrorMessageBar(() => resetError()) }}>\n <Grid\n {...props}\n onOverrideComponentProps={(props) => props}\n context={injectedContextRef.current} />\n </ErrorBoundary>\n </ThemeProvider>\n )\n}"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAWa,MAAA,cAAc,GAAG,CAAC,KAAsB,KAAI;AACvD,IAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,gBAAgB,EAAE,KAAK,EAAE,0BAA0B,CAAC,CAAC;AAC1F,IAAA,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;AAC/B,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;IACtC,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/F,IAAA,MAAM,wBAAwB,GAAG,KAAK,CAAC,wBAAwB,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;;IAEtF,OAAO,CAAC,YAAY,CAAC,MAAM,QAAQ,EAAE,CAAC,CAAC;;IAGvC,MAAM,cAAc,GAAG,wBAAwB,CAAC;QAC9C,aAAa,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AC;KAChC,EAAE,EAAE,CAAC,CAAC;IAGP,QACEC,KAAC,aAAa,EAAA,EAAA,GAAK,cAAc,CAAC,cAAc,EAC9C,QAAA,EAAA,CAAAD,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,cAAc,CAAC,WAAW,CAAC,oBAAoB,YACrD,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAK;AACxC,oBAAA,OAAOA,0BACJ,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG;AACpC,4BAAAA,GAAA,CAAC,SAAS,EAAA,EACR,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,4BAA4B,EAAE,CAAC,KAAK,KAAK,cAAc,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAA,CAAI,GAErG,CAAA;iBACJ,CAAC,GACE,EACNA,GAAA,CAAC,aAAa,EAAC,EAAA,QAAQ,EAAE,CAAC,UAAsB,KAAO,EAAA,qBAAqB,CAAC,MAAM,UAAU,EAAE,CAAC,CAAA,EAAE,YAChGA,GAAC,CAAA,IAAI,OACC,KAAK,EACT,wBAAwB,EAAE,CAAC,KAAK,KAAK,KAAK,EAC1C,OAAO,EAAE,kBAAkB,CAAC,OAAO,EAAI,CAAA,EAAA,CAC3B,CACF,EAAA,CAAA,EACjB;AACH;;;;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IDataset } from "@talxis/client-libraries";
|
|
3
|
-
import {
|
|
3
|
+
import { ITheme } from "@talxis/react-components";
|
|
4
4
|
import { datasetControlTranslations } from "../translations";
|
|
5
5
|
import { ITranslation } from "../../../hooks";
|
|
6
|
-
|
|
6
|
+
import { IQuickFindProps } from "../interfaces";
|
|
7
|
+
export interface IQuickFindComponentProps {
|
|
7
8
|
labels: ITranslation<typeof datasetControlTranslations>;
|
|
8
9
|
dataset: IDataset;
|
|
9
|
-
|
|
10
|
+
theme: ITheme;
|
|
11
|
+
onGetQuickFindComponentProps: (props: IQuickFindProps) => IQuickFindProps;
|
|
10
12
|
}
|
|
11
|
-
export declare const QuickFind: (props:
|
|
13
|
+
export declare const QuickFind: (props: IQuickFindComponentProps) => JSX.Element;
|
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { TextField } from '@talxis/react-components';
|
|
3
3
|
import { useState, useEffect } from 'react';
|
|
4
|
+
import { ThemeProvider } from '@fluentui/react';
|
|
4
5
|
|
|
5
6
|
const QuickFind = (props) => {
|
|
6
|
-
const { dataset, labels } = { ...props };
|
|
7
|
+
const { dataset, labels, theme } = { ...props };
|
|
7
8
|
const [query, setQuery] = useState('');
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onChange: (e, newValue) => setQuery(newValue ?? ''),
|
|
12
|
-
onKeyUp: (e) => {
|
|
13
|
-
if (e.key === 'Enter') {
|
|
14
|
-
onSearch(query);
|
|
15
|
-
}
|
|
9
|
+
const quickFindProps = props.onGetQuickFindComponentProps({
|
|
10
|
+
container: {
|
|
11
|
+
theme: theme
|
|
16
12
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
textFieldProps: {
|
|
14
|
+
value: query,
|
|
15
|
+
placeholder: `${labels.search()} ${dataset.getMetadata()?.DisplayCollectionName ?? labels.records()}...`,
|
|
16
|
+
onChange: (e, newValue) => setQuery(newValue ?? ''),
|
|
17
|
+
onKeyUp: (e) => {
|
|
18
|
+
if (e.key === 'Enter') {
|
|
19
|
+
onSearch(query);
|
|
20
|
+
}
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onSearch(undefined);
|
|
25
|
-
}
|
|
26
|
-
} : undefined,
|
|
27
|
-
suffixItems: [{
|
|
28
|
-
key: 'search',
|
|
22
|
+
deleteButtonProps: query ? {
|
|
23
|
+
key: 'delete',
|
|
29
24
|
iconProps: {
|
|
30
|
-
iconName: '
|
|
25
|
+
iconName: 'Cancel'
|
|
31
26
|
},
|
|
32
|
-
onClick: () =>
|
|
33
|
-
|
|
27
|
+
onClick: () => {
|
|
28
|
+
setQuery("");
|
|
29
|
+
onSearch(undefined);
|
|
30
|
+
}
|
|
31
|
+
} : undefined,
|
|
32
|
+
suffixItems: [{
|
|
33
|
+
key: 'search',
|
|
34
|
+
iconProps: {
|
|
35
|
+
iconName: 'Search'
|
|
36
|
+
},
|
|
37
|
+
onClick: () => onSearch(query)
|
|
38
|
+
}]
|
|
39
|
+
}
|
|
34
40
|
});
|
|
35
41
|
const onSearch = (query) => {
|
|
36
42
|
dataset.setSearchQuery?.(query ?? "");
|
|
@@ -39,7 +45,8 @@ const QuickFind = (props) => {
|
|
|
39
45
|
useEffect(() => {
|
|
40
46
|
setQuery(dataset.getSearchQuery?.() ?? '');
|
|
41
47
|
}, [dataset.getSearchQuery?.()]);
|
|
42
|
-
|
|
48
|
+
//needs to be wrapped within ThemeProvider because the theme context can be lost if we are overriding the header render
|
|
49
|
+
return jsx(ThemeProvider, { ...quickFindProps.container, children: jsx(TextField, { ...quickFindProps.textFieldProps }) });
|
|
43
50
|
};
|
|
44
51
|
|
|
45
52
|
export { QuickFind };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickFind.js","sources":["../../../../src/components/DatasetControl/QuickFind/QuickFind.tsx"],"sourcesContent":["import { IDataset } from \"@talxis/client-libraries\";\nimport { ITextFieldProps, TextField } from \"@talxis/react-components\";\nimport { datasetControlTranslations } from \"../translations\";\nimport { ITranslation } from \"../../../hooks\";\nimport { useEffect, useState } from \"react\";\n\nexport interface
|
|
1
|
+
{"version":3,"file":"QuickFind.js","sources":["../../../../src/components/DatasetControl/QuickFind/QuickFind.tsx"],"sourcesContent":["import { IDataset } from \"@talxis/client-libraries\";\nimport { ITextFieldProps, ITheme, TextField } from \"@talxis/react-components\";\nimport { datasetControlTranslations } from \"../translations\";\nimport { ITranslation } from \"../../../hooks\";\nimport { useEffect, useState } from \"react\";\nimport { ThemeProvider } from \"@fluentui/react\";\nimport { IQuickFindProps } from \"../interfaces\";\n\nexport interface IQuickFindComponentProps {\n labels: ITranslation<typeof datasetControlTranslations>\n dataset: IDataset;\n theme: ITheme;\n onGetQuickFindComponentProps: (props: IQuickFindProps) => IQuickFindProps;\n}\n\nexport const QuickFind = (props: IQuickFindComponentProps) => {\n const { dataset, labels, theme } = { ...props };\n const [query, setQuery] = useState<string>('');\n\n const quickFindProps = props.onGetQuickFindComponentProps({\n container: {\n theme: theme\n },\n textFieldProps: {\n value: query,\n placeholder: `${labels.search()} ${dataset.getMetadata()?.DisplayCollectionName ?? labels.records()}...`,\n onChange: (e, newValue) => setQuery(newValue ?? ''),\n onKeyUp: (e) => {\n if (e.key === 'Enter') {\n onSearch(query);\n }\n },\n deleteButtonProps: query ? {\n key: 'delete',\n iconProps: {\n iconName: 'Cancel'\n },\n onClick: () => {\n setQuery(\"\");\n onSearch(undefined);\n }\n } : undefined,\n suffixItems: [{\n key: 'search',\n iconProps: {\n iconName: 'Search'\n },\n onClick: () => onSearch(query)\n }]\n }\n })\n const onSearch = (query?: string) => {\n dataset.setSearchQuery?.(query ?? \"\");\n dataset.refresh();\n }\n\n useEffect(() => {\n setQuery(dataset.getSearchQuery?.() ?? '');\n }, [dataset.getSearchQuery?.()])\n //needs to be wrapped within ThemeProvider because the theme context can be lost if we are overriding the header render\n return <ThemeProvider {...quickFindProps.container}><TextField {...quickFindProps.textFieldProps} /></ThemeProvider>\n}"],"names":["_jsx"],"mappings":";;;;;AAea,MAAA,SAAS,GAAG,CAAC,KAA+B,KAAI;AACzD,IAAA,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;AAE/C,IAAA,MAAM,cAAc,G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QACX,QAAQ,CAAC,OAAO,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC,CAAC;KAC9C,EAAE,CAAC,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC,CAAA;;AAEhC,IAAA,OAAOA,GAAC,CAAA,aAAa,EAAK,EAAA,GAAA,cAAc,CAAC,SAAS,EAAA,QAAA,EAAEA,GAAC,CAAA,SAAS,OAAK,cAAc,CAAC,cAAc,EAAA,CAAI,GAAgB,CAAA;AACxH;;;;"}
|
|
@@ -6,13 +6,17 @@ import { IGridOutputs, IGridParameters } from "../Grid";
|
|
|
6
6
|
import { gridTranslations } from "../Grid/translations";
|
|
7
7
|
import { datasetControlTranslations } from "./translations";
|
|
8
8
|
import { ITextFieldProps } from "@talxis/react-components";
|
|
9
|
+
export interface IQuickFindProps {
|
|
10
|
+
textFieldProps: ITextFieldProps;
|
|
11
|
+
container: ThemeProviderProps;
|
|
12
|
+
}
|
|
9
13
|
export interface IDatasetControlComponentProps {
|
|
10
14
|
onDatasetInit: () => void;
|
|
11
15
|
containerProps: ThemeProviderProps;
|
|
12
16
|
headerProps: {
|
|
13
17
|
headerContainerProps: React.HTMLAttributes<HTMLDivElement>;
|
|
14
18
|
onRender: (renderQuickFind: () => React.ReactElement) => React.ReactElement;
|
|
15
|
-
onGetQuickFindProps: (props:
|
|
19
|
+
onGetQuickFindProps: (props: IQuickFindProps) => IQuickFindProps;
|
|
16
20
|
};
|
|
17
21
|
}
|
|
18
22
|
export interface IDatasetControl extends IControl<IGridParameters, IGridOutputs, Partial<ITranslation<typeof datasetControlTranslations & typeof gridTranslations>>, IDatasetControlComponentProps> {
|
|
@@ -52,6 +52,13 @@ const DateTime = (componentProps) => {
|
|
|
52
52
|
allowTextInput: !parameters.RestrictedDates?.raw && !parameters.RestrictedDaysOfWeek?.raw,
|
|
53
53
|
// Lowest date supported by CDS: https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/dn996866(v=crm.8)?redirectedfrom=MSDN
|
|
54
54
|
minDate: new Date('1753-01-01T00:00:00.000Z'),
|
|
55
|
+
parseDateFromString: (dateString) => {
|
|
56
|
+
const parsedDate = date.parseDateString(dateString);
|
|
57
|
+
if (parsedDate instanceof Date) {
|
|
58
|
+
return parsedDate;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
},
|
|
55
62
|
firstDayOfWeek: componentProps.context.userSettings.dateFormattingInfo.firstDayOfWeek,
|
|
56
63
|
deleteButtonProps: parameters.EnableDeleteButton?.raw === true ? {
|
|
57
64
|
key: 'Delete',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","sources":["../../../src/components/DateTime/DateTime.tsx"],"sourcesContent":["import { IDateTime } from \"./interfaces\";\nimport { ICalendarDayGridStyles, IDatePicker, IProcessedStyleSet, ThemeProvider } from \"@fluentui/react\";\nimport { useEffect, useRef } from \"react\";\nimport { getDateTimeStyles } from \"./styles\";\nimport { useDateTime } from \"./hooks/useDateTime\";\nimport { Calendar, IInternalCalendarProps } from \"./components/Calendar\";\nimport { DatePicker } from \"@talxis/react-components\";\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const DateTime = (componentProps: IDateTime) => {\n const ref = useRef<HTMLDivElement>(null);\n const onOverrideComponentProps = componentProps.onOverrideComponentProps ?? ((props) => props);\n const datePickerRef = useRef<IDatePicker>(null);\n const context = componentProps.context;\n const parameters = componentProps.parameters;\n const [isDateTime, theme, labels, date, patterns] = useDateTime(componentProps, ref);\n const styles = getDateTimeStyles(theme);\n const { height, width } = useControlSizing(componentProps.context.mode);\n const lastInputedTimeString = useRef<string>();\n\n useEffect(() => {\n if (componentProps.parameters.AutoFocus?.raw === true) {\n datePickerRef.current?.showDatePickerPopup();\n }\n }, []);\n\n const getRestrictedDates = (): Date[] | undefined => {\n if(!parameters.RestrictedDates?.raw) {\n return undefined;\n }\n return JSON.parse(parameters.RestrictedDates?.raw).map((x: string) => new Date(x))\n }\n \n const onOverrideDayCellProps = (element: HTMLElement, date: Date, classNames: IProcessedStyleSet<ICalendarDayGridStyles>) => {\n if(!element || !parameters.RestrictedDaysOfWeek?.raw) {\n return;\n }\n const weekDaysToExclude: number[] = JSON.parse(parameters.RestrictedDaysOfWeek.raw);\n if(weekDaysToExclude.includes(date.getDay())) {\n element.setAttribute('data-is-focusable', 'false');\n element.classList?.add(classNames.dayOutsideBounds!);\n (element.children[0] as HTMLButtonElement).disabled = true;\n }\n }\n\n const datePickerProps = onOverrideComponentProps({\n className: styles.datePicker,\n componentRef: datePickerRef,\n hideErrorMessage: !parameters.ShowErrorMessage?.raw,\n keepCalendarOpenAfterDaySelect: isDateTime,\n readOnly: context.mode.isControlDisabled,\n //@ts-ignore - this is a hack to close the calendar when dates get selected on date only fields\n onSelectDate: isDateTime ? undefined : (newDate) => date.set(newDate!),\n //disable so the user cannot input restricted Dates\n allowTextInput: !parameters.RestrictedDates?.raw && !parameters.RestrictedDaysOfWeek?.raw,\n // Lowest date supported by CDS: https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/dn996866(v=crm.8)?redirectedfrom=MSDN\n minDate: new Date('1753-01-01T00:00:00.000Z'),\n firstDayOfWeek: componentProps.context.userSettings.dateFormattingInfo.firstDayOfWeek,\n deleteButtonProps: parameters.EnableDeleteButton?.raw === true ? {\n key: 'Delete',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Cancel'\n },\n onClick: () => date.clear()\n } : undefined,\n clickToCopyProps: parameters.EnableCopyButton?.raw === true ? {\n key: 'copy',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Copy'\n }\n } : undefined,\n calendarAs: (props) => {\n const calendarProps: IInternalCalendarProps = {\n ...props,\n isMonthPickerVisible: parameters.EnableMonthPicker?.raw !== false,\n isDayPickerVisible: parameters.EnableDayPicker?.raw !== false,\n calendarDayProps: {\n restrictedDates: getRestrictedDates(),\n customDayCellRef: onOverrideDayCellProps\n },\n value: date.get(),\n strings: {\n goToToday: labels.goToToday(),\n days: JSON.parse(labels.days()),\n months: JSON.parse(labels.months()),\n shortDays: JSON.parse(labels.shortDays()),\n shortMonths: JSON.parse(labels.shortMonths())\n },\n timePickerProps: {\n dateTimeFormat: patterns.fullDateTimePattern,\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n timeFormat: patterns.shortTimePattern,\n label: labels.time(),\n visible: isDateTime,\n errorMessage: labels.invalidTimeInput(),\n lastInputedTimeString: lastInputedTimeString.current,\n useHour12: patterns.shortTimePattern.endsWith('A'),\n onChange: (time?: string) => {\n date.set(undefined, time);\n lastInputedTimeString.current = time;\n },\n value: date.get(),\n formattedDateTime: date.getFormatted() ?? \"\",\n strings: {\n invalidInputErrorMessage: labels.invalidTimeInput()\n }\n },\n theme: componentProps.context.fluentDesignLanguage?.applicationTheme ?? theme\n };\n if(isDateTime) {\n calendarProps.onSelectDate = (newDate) => date.set(newDate)\n }\n return <Calendar {...calendarProps} />\n },\n errorMessage: parameters.value.errorMessage,\n textField: {\n value: date.getFormatted() ?? \"\",\n onChange: (e, value) => {\n if(isDateTime) {\n const datePart = dayjs(value, patterns.shortDatePattern).format(patterns.shortDatePattern);\n const time = value?.split(datePart).pop()?.substring(1);\n lastInputedTimeString.current = time;\n }\n date.setDateString(value)\n },\n placeholder: '---',\n onNotifyValidationResult: () => null,\n noValidate: true,\n styles: {\n fieldGroup: {\n height: height,\n width: width\n }\n }\n },\n value: date.get() ?? undefined\n });\n\n return (\n <ThemeProvider theme={theme} applyTo=\"none\" ref={ref}>\n <DatePicker {...datePickerProps} />\n </ThemeProvider>\n );\n};"],"names":["_jsx"],"mappings":";;;;;;;;;;AAUa,MAAA,QAAQ,GAAG,CAAC,cAAyB,KAAI;AAClD,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AACzC,IAAA,MAAM,wBAAwB,GAAG,cAAc,CAAC,wBAAwB,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AAC/F,IAAA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Q,CAAC,gBAAgB,CAAC,CAAC;AAC3F,oBAAA,MAAM,IAAI,GAAG,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,oBAAA,qBAAqB,CAAC,OAAO,GAAG,IAAI,CAAC;AACxC,iBAAA;AACD,gBAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;aAC5B;AACD,YAAA,WAAW,EAAE,KAAK;AAClB,YAAA,wBAAwB,EAAE,MAAM,IAAI;AACpC,YAAA,UAAU,EAAE,IAAI;AAChB,YAAA,MAAM,EAAE;AACJ,gBAAA,UAAU,EAAE;AACR,oBAAA,MAAM,EAAE,MAAM;AACd,oBAAA,KAAK,EAAE,KAAK;AACf,iBAAA;AACJ,aAAA;AACJ,SAAA;AACD,QAAA,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,SAAS;AACjC,KAAA,CAAC,CAAC;IAEH,QACIA,IAAC,aAAa,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAC,GAAG,EAAE,GAAG,EAAA,QAAA,EAChDA,GAAC,CAAA,UAAU,OAAK,eAAe,EAAA,CAAI,EACvB,CAAA,EAClB;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"DateTime.js","sources":["../../../src/components/DateTime/DateTime.tsx"],"sourcesContent":["import { IDateTime } from \"./interfaces\";\nimport { ICalendarDayGridStyles, IDatePicker, IProcessedStyleSet, ThemeProvider } from \"@fluentui/react\";\nimport { useEffect, useRef } from \"react\";\nimport { getDateTimeStyles } from \"./styles\";\nimport { useDateTime } from \"./hooks/useDateTime\";\nimport { Calendar, IInternalCalendarProps } from \"./components/Calendar\";\nimport { DatePicker } from \"@talxis/react-components\";\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const DateTime = (componentProps: IDateTime) => {\n const ref = useRef<HTMLDivElement>(null);\n const onOverrideComponentProps = componentProps.onOverrideComponentProps ?? ((props) => props);\n const datePickerRef = useRef<IDatePicker>(null);\n const context = componentProps.context;\n const parameters = componentProps.parameters;\n const [isDateTime, theme, labels, date, patterns] = useDateTime(componentProps, ref);\n const styles = getDateTimeStyles(theme);\n const { height, width } = useControlSizing(componentProps.context.mode);\n const lastInputedTimeString = useRef<string>();\n\n useEffect(() => {\n if (componentProps.parameters.AutoFocus?.raw === true) {\n datePickerRef.current?.showDatePickerPopup();\n }\n }, []);\n\n const getRestrictedDates = (): Date[] | undefined => {\n if(!parameters.RestrictedDates?.raw) {\n return undefined;\n }\n return JSON.parse(parameters.RestrictedDates?.raw).map((x: string) => new Date(x))\n }\n \n const onOverrideDayCellProps = (element: HTMLElement, date: Date, classNames: IProcessedStyleSet<ICalendarDayGridStyles>) => {\n if(!element || !parameters.RestrictedDaysOfWeek?.raw) {\n return;\n }\n const weekDaysToExclude: number[] = JSON.parse(parameters.RestrictedDaysOfWeek.raw);\n if(weekDaysToExclude.includes(date.getDay())) {\n element.setAttribute('data-is-focusable', 'false');\n element.classList?.add(classNames.dayOutsideBounds!);\n (element.children[0] as HTMLButtonElement).disabled = true;\n }\n }\n\n const datePickerProps = onOverrideComponentProps({\n className: styles.datePicker,\n componentRef: datePickerRef,\n hideErrorMessage: !parameters.ShowErrorMessage?.raw,\n keepCalendarOpenAfterDaySelect: isDateTime,\n readOnly: context.mode.isControlDisabled,\n //@ts-ignore - this is a hack to close the calendar when dates get selected on date only fields\n onSelectDate: isDateTime ? undefined : (newDate) => date.set(newDate!),\n //disable so the user cannot input restricted Dates\n allowTextInput: !parameters.RestrictedDates?.raw && !parameters.RestrictedDaysOfWeek?.raw,\n // Lowest date supported by CDS: https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/dn996866(v=crm.8)?redirectedfrom=MSDN\n minDate: new Date('1753-01-01T00:00:00.000Z'),\n parseDateFromString: (dateString) => {\n const parsedDate = date.parseDateString(dateString);\n if (parsedDate instanceof Date) {\n return parsedDate;\n }\n return null;\n },\n firstDayOfWeek: componentProps.context.userSettings.dateFormattingInfo.firstDayOfWeek,\n deleteButtonProps: parameters.EnableDeleteButton?.raw === true ? {\n key: 'Delete',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Cancel'\n },\n onClick: () => date.clear()\n } : undefined,\n clickToCopyProps: parameters.EnableCopyButton?.raw === true ? {\n key: 'copy',\n showOnlyOnHover: true,\n iconProps: {\n iconName: 'Copy'\n }\n } : undefined,\n calendarAs: (props) => {\n const calendarProps: IInternalCalendarProps = {\n ...props,\n isMonthPickerVisible: parameters.EnableMonthPicker?.raw !== false,\n isDayPickerVisible: parameters.EnableDayPicker?.raw !== false,\n calendarDayProps: {\n restrictedDates: getRestrictedDates(),\n customDayCellRef: onOverrideDayCellProps\n },\n value: date.get(),\n strings: {\n goToToday: labels.goToToday(),\n days: JSON.parse(labels.days()),\n months: JSON.parse(labels.months()),\n shortDays: JSON.parse(labels.shortDays()),\n shortMonths: JSON.parse(labels.shortMonths())\n },\n timePickerProps: {\n dateTimeFormat: patterns.fullDateTimePattern,\n autoComplete: \"off\",\n autoCapitalize: \"off\",\n timeFormat: patterns.shortTimePattern,\n label: labels.time(),\n visible: isDateTime,\n errorMessage: labels.invalidTimeInput(),\n lastInputedTimeString: lastInputedTimeString.current,\n useHour12: patterns.shortTimePattern.endsWith('A'),\n onChange: (time?: string) => {\n date.set(undefined, time);\n lastInputedTimeString.current = time;\n },\n value: date.get(),\n formattedDateTime: date.getFormatted() ?? \"\",\n strings: {\n invalidInputErrorMessage: labels.invalidTimeInput()\n }\n },\n theme: componentProps.context.fluentDesignLanguage?.applicationTheme ?? theme\n };\n if(isDateTime) {\n calendarProps.onSelectDate = (newDate) => date.set(newDate)\n }\n return <Calendar {...calendarProps} />\n },\n errorMessage: parameters.value.errorMessage,\n textField: {\n value: date.getFormatted() ?? \"\",\n onChange: (e, value) => {\n if(isDateTime) {\n const datePart = dayjs(value, patterns.shortDatePattern).format(patterns.shortDatePattern);\n const time = value?.split(datePart).pop()?.substring(1);\n lastInputedTimeString.current = time;\n }\n date.setDateString(value)\n },\n placeholder: '---',\n onNotifyValidationResult: () => null,\n noValidate: true,\n styles: {\n fieldGroup: {\n height: height,\n width: width\n }\n }\n },\n value: date.get() ?? undefined\n });\n\n return (\n <ThemeProvider theme={theme} applyTo=\"none\" ref={ref}>\n <DatePicker {...datePickerProps} />\n </ThemeProvider>\n );\n};"],"names":["_jsx"],"mappings":";;;;;;;;;;AAUa,MAAA,QAAQ,GAAG,CAAC,cAAyB,KAAI;AAClD,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AACzC,IAAA,MAAM,wBAAwB,GAAG,cAAc,CAAC,wBAAwB,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AAC/F,IAAA,MAAM,aAAa,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;AAChD,IAAA,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;AACvC,IAAA,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC;AAC7C,IAAA,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;AACrF,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACxC,IAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACxE,IAAA,MAAM,qBAAqB,GAAG,MAAM,EAAU,CAAC;IAE/C,SAAS,CAAC,MAAK;QACX,IAAI,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,EAAE;AACnD,YAAA,aAAa,CAAC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAChD,SAAA;KACJ,EAAE,EAAE,CAAC,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KAAK;AACf,iBAAA;AACJ,aAAA;AACJ,SAAA;AACD,QAAA,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,SAAS;AACjC,KAAA,CAAC,CAAC;IAEH,QACIA,IAAC,aAAa,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAC,GAAG,EAAE,GAAG,EAAA,QAAA,EAChDA,GAAC,CAAA,UAAU,OAAK,eAAe,EAAA,CAAI,EACvB,CAAA,EAClB;AACN;;;;"}
|
|
@@ -24,6 +24,7 @@ export declare const useDateTime: (props: IDateTime, ref: React.RefObject<HTMLDi
|
|
|
24
24
|
set: (date?: Date, time?: string) => void;
|
|
25
25
|
setDateString: (value: string | undefined) => void;
|
|
26
26
|
clear: () => void;
|
|
27
|
+
parseDateString: (dateString: string) => Date | string;
|
|
27
28
|
}, {
|
|
28
29
|
shortDatePattern: string;
|
|
29
30
|
shortTimePattern: string;
|
|
@@ -135,7 +135,8 @@ const useDateTime = (props, ref) => {
|
|
|
135
135
|
clear: clearDate,
|
|
136
136
|
getFormatted: () => value,
|
|
137
137
|
set: selectDate,
|
|
138
|
-
setDateString: setValue
|
|
138
|
+
setDateString: setValue,
|
|
139
|
+
parseDateString: (dateString) => dateExtractor(dateString)
|
|
139
140
|
},
|
|
140
141
|
{
|
|
141
142
|
shortDatePattern: shortDatePattern,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDateTime.js","sources":["../../../../src/components/DateTime/hooks/useDateTime.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useInputBasedControl } from \"../../../hooks/useInputBasedControl\";\nimport { IDateTime, IDateTimeOutputs, IDateTimeParameters} from \"../interfaces\";\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport { getDefaultDateTimeTranslations } from \"../translations\";\nimport {ITranslation } from \"../../../hooks\";\nimport { ITheme } from \"@talxis/react-components\";\n\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\n\nexport const useDateTime = (props: IDateTime, ref: React.RefObject<HTMLDivElement>): [\n boolean,\n ITheme,\n ITranslation<Required<IDateTime>['translations']>,\n {\n get: () => Date | undefined;\n getFormatted: () => string | undefined;\n set: (date?: Date, time?: string) => void;\n setDateString: (value: string | undefined) => void;\n clear: () => void;\n },\n {\n shortDatePattern: string\n shortTimePattern: string;\n fullDateTimePattern: string;\n },\n] => {\n\n const boundValue = props.parameters.value;\n const context = props.context;\n const behavior = boundValue.attributes.Behavior;\n const format = boundValue.attributes.Format ?? boundValue.type;\n const dateFormattingInfo = context.userSettings.dateFormattingInfo;\n const lastValidDateRef = useRef<Date | undefined>(undefined);\n \n const isDateTime = (() => {\n switch (format) {\n case 'DateAndTime':\n case 'Date and Time':\n case 'DateAndTime.DateAndTime':\n case 'datetime': {\n return true;\n }\n default: {\n return false;\n }\n }\n })();\n\n //MS returns the pattern without correct separator and they do this during formatting\n const shortDatePattern = dateFormattingInfo.shortDatePattern.replace(/\\//g, dateFormattingInfo.dateSeparator).toUpperCase();\n const shortTimePattern = dateFormattingInfo.shortTimePattern.replace(/:/g, dateFormattingInfo.timeSeparator).replace('tt', 'A');\n const formatting = (() => {\n if (isDateTime) {\n return `${shortDatePattern} ${shortTimePattern}`;\n }\n return shortDatePattern;\n })();\n\n const formatDate = (date: Date | undefined | null | string): string | undefined | null => {\n if (date instanceof Date) {\n if (isDateTime) {\n //should handle the time zone conversion\n return context.formatting.formatTime(date, behavior);\n }\n return context.formatting.formatDateShort(date);\n }\n return date;\n };\n\n useEffect(() => {\n if (boundValue.raw instanceof Date) {\n lastValidDateRef.current = boundValue.raw;\n }\n }, [boundValue.raw]);\n\n const getDate = (): Date | undefined => {\n if (boundValue.raw instanceof Date) {\n if (behavior === 3) {\n //the date in javascript gets automatically adjusted to local time zone\n //this will make it think that the date already came in local time, thus not adjusting the time\n const date = new Date(boundValue.raw.toISOString().replace('Z', ''));\n return date;\n }\n return boundValue.raw;\n }\n if(boundValue.error) {\n return lastValidDateRef.current;\n }\n return undefined;\n };\n\n const dateExtractor = (value: string | Date): Date | string => {\n if (value instanceof Date) {\n return value;\n }\n const dayjsDate = dayjs(value, formatting, true);\n if (!dayjsDate.isValid()) {\n const dayJsDateNoWhiteSpace = dayjs(value?.replaceAll(' ', ''), formatting.replaceAll(' ', ''));\n if(!dayJsDateNoWhiteSpace.isValid()) {\n return value;\n }\n else {\n return dayJsDateNoWhiteSpace.toDate();\n }\n }\n return dayjsDate.toDate();\n };\n\n const clearDate = () => {\n onNotifyOutputChanged({\n value: undefined\n });\n };\n\n const selectDate = (date?: Date, time?: string) => {\n //onSelectDate can trigger on initial click with empty date, do not continue in this case\n //for clearing dates, date.clear should be used\n if(!date && !time) {\n return;\n }\n let dayjsDate = dayjs(date ?? getDate());\n //date selected from calendar, keep the original time\n if (!time) {\n time = dayjs(getDate()).format(shortTimePattern);\n }\n const dayjsTime = dayjs(time, shortTimePattern, true);\n let invalidDateString;\n if(!dayjsTime.isValid()) {\n invalidDateString = `${dayjsDate.format(shortDatePattern)} ${time}`\n }\n dayjsDate = dayjsDate.hour(dayjsTime.hour());\n dayjsDate = dayjsDate.minute(dayjsTime.minute());\n onNotifyOutputChanged({\n value: dateExtractor(invalidDateString ?? dayjsDate.toDate()) as any\n });\n };\n const {value, labels, theme, setValue, onNotifyOutputChanged} = useInputBasedControl<string | undefined, IDateTimeParameters, IDateTimeOutputs, Required<IDateTime>['translations']>('DateTime', props, {\n formatter: formatDate,\n valueExtractor: dateExtractor,\n defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)\n });\n\n\n useEffect(() => {\n const onBlur = () => {\n onNotifyOutputChanged({\n value: dateExtractor(value!) as any\n });\n };\n const input = ref.current?.querySelector('input');\n input?.addEventListener('blur', onBlur);\n return () => {\n input?.removeEventListener('blur', onBlur);\n };\n }, [value]);\n\n return [\n isDateTime,\n theme,\n labels,\n {\n get: getDate,\n clear: clearDate,\n getFormatted: () => value,\n set: selectDate,\n setDateString: setValue\n },\n {\n shortDatePattern: shortDatePattern,\n shortTimePattern: shortTimePattern,\n fullDateTimePattern: `${shortDatePattern} ${shortTimePattern}`\n }\n ]\n};"],"names":[],"mappings":";;;;;;;AAUA,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;MAEL,WAAW,GAAG,CAAC,KAAgB,EAAE,GAAoC,KAgB9E;AAEA,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;AAC1C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC;IAChD,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC;AAC/D,IAAA,MAAM,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC;AACnE,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAmB,SAAS,CAAC,CAAC;AAE7D,IAAA,MAAM,UAAU,GAAG,CAAC,MAAK;AACrB,QAAA,QAAQ,MAAM;AACV,YAAA,KAAK,aAAa,CAAC;AACnB,YAAA,KAAK,eAAe,CAAC;AACrB,YAAA,KAAK,yBAAyB,CAAC;YAC/B,KAAK,UAAU,EAAE;AACb,gBAAA,OAAO,IAAI,CAAC;AACf,aAAA;AACD,YAAA,SAAS;AACL,gBAAA,OAAO,KAAK,CAAC;AAChB,aAAA;AACJ,SAAA;KACJ,GAAG,CAAC;;AAGL,IAAA,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5H,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,gBAAgB,CAA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C,QAAA,OAAO,MAAK;AACR,YAAA,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/C,SAAC,CAAC;AACN,KAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO;QACH,UAAU;QACV,KAAK;QACL,MAAM;AACN,QAAA;AACI,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,YAAY,EAAE,MAAM,KAAK;AACzB,YAAA,GAAG,EAAE,UAAU;AACf,YAAA,aAAa,EAAE,QAAQ;AAC1B,SAAA;AACD,QAAA;AACI,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,mBAAmB,EAAE,CAAA,EAAG,gBAAgB,CAAA,CAAA,EAAI,gBAAgB,CAAE,CAAA;AACjE,SAAA;KACJ,CAAA;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"useDateTime.js","sources":["../../../../src/components/DateTime/hooks/useDateTime.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useInputBasedControl } from \"../../../hooks/useInputBasedControl\";\nimport { IDateTime, IDateTimeOutputs, IDateTimeParameters} from \"../interfaces\";\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport { getDefaultDateTimeTranslations } from \"../translations\";\nimport {ITranslation } from \"../../../hooks\";\nimport { ITheme } from \"@talxis/react-components\";\n\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\n\nexport const useDateTime = (props: IDateTime, ref: React.RefObject<HTMLDivElement>): [\n boolean,\n ITheme,\n ITranslation<Required<IDateTime>['translations']>,\n {\n get: () => Date | undefined;\n getFormatted: () => string | undefined;\n set: (date?: Date, time?: string) => void;\n setDateString: (value: string | undefined) => void;\n clear: () => void;\n parseDateString: (dateString: string) => Date | string;\n },\n {\n shortDatePattern: string\n shortTimePattern: string;\n fullDateTimePattern: string;\n },\n] => {\n\n const boundValue = props.parameters.value;\n const context = props.context;\n const behavior = boundValue.attributes.Behavior;\n const format = boundValue.attributes.Format ?? boundValue.type;\n const dateFormattingInfo = context.userSettings.dateFormattingInfo;\n const lastValidDateRef = useRef<Date | undefined>(undefined);\n \n const isDateTime = (() => {\n switch (format) {\n case 'DateAndTime':\n case 'Date and Time':\n case 'DateAndTime.DateAndTime':\n case 'datetime': {\n return true;\n }\n default: {\n return false;\n }\n }\n })();\n\n //MS returns the pattern without correct separator and they do this during formatting\n const shortDatePattern = dateFormattingInfo.shortDatePattern.replace(/\\//g, dateFormattingInfo.dateSeparator).toUpperCase();\n const shortTimePattern = dateFormattingInfo.shortTimePattern.replace(/:/g, dateFormattingInfo.timeSeparator).replace('tt', 'A');\n const formatting = (() => {\n if (isDateTime) {\n return `${shortDatePattern} ${shortTimePattern}`;\n }\n return shortDatePattern;\n })();\n\n const formatDate = (date: Date | undefined | null | string): string | undefined | null => {\n if (date instanceof Date) {\n if (isDateTime) {\n //should handle the time zone conversion\n return context.formatting.formatTime(date, behavior);\n }\n return context.formatting.formatDateShort(date);\n }\n return date;\n };\n\n useEffect(() => {\n if (boundValue.raw instanceof Date) {\n lastValidDateRef.current = boundValue.raw;\n }\n }, [boundValue.raw]);\n\n const getDate = (): Date | undefined => {\n if (boundValue.raw instanceof Date) {\n if (behavior === 3) {\n //the date in javascript gets automatically adjusted to local time zone\n //this will make it think that the date already came in local time, thus not adjusting the time\n const date = new Date(boundValue.raw.toISOString().replace('Z', ''));\n return date;\n }\n return boundValue.raw;\n }\n if(boundValue.error) {\n return lastValidDateRef.current;\n }\n return undefined;\n };\n\n const dateExtractor = (value: string | Date): Date | string => {\n if (value instanceof Date) {\n return value;\n }\n const dayjsDate = dayjs(value, formatting, true);\n if (!dayjsDate.isValid()) {\n const dayJsDateNoWhiteSpace = dayjs(value?.replaceAll(' ', ''), formatting.replaceAll(' ', ''));\n if(!dayJsDateNoWhiteSpace.isValid()) {\n return value;\n }\n else {\n return dayJsDateNoWhiteSpace.toDate();\n }\n }\n return dayjsDate.toDate();\n };\n\n const clearDate = () => {\n onNotifyOutputChanged({\n value: undefined\n });\n };\n\n const selectDate = (date?: Date, time?: string) => {\n //onSelectDate can trigger on initial click with empty date, do not continue in this case\n //for clearing dates, date.clear should be used\n if(!date && !time) {\n return;\n }\n let dayjsDate = dayjs(date ?? getDate());\n //date selected from calendar, keep the original time\n if (!time) {\n time = dayjs(getDate()).format(shortTimePattern);\n }\n const dayjsTime = dayjs(time, shortTimePattern, true);\n let invalidDateString;\n if(!dayjsTime.isValid()) {\n invalidDateString = `${dayjsDate.format(shortDatePattern)} ${time}`\n }\n dayjsDate = dayjsDate.hour(dayjsTime.hour());\n dayjsDate = dayjsDate.minute(dayjsTime.minute());\n onNotifyOutputChanged({\n value: dateExtractor(invalidDateString ?? dayjsDate.toDate()) as any\n });\n };\n const {value, labels, theme, setValue, onNotifyOutputChanged} = useInputBasedControl<string | undefined, IDateTimeParameters, IDateTimeOutputs, Required<IDateTime>['translations']>('DateTime', props, {\n formatter: formatDate,\n valueExtractor: dateExtractor,\n defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)\n });\n\n\n useEffect(() => {\n const onBlur = () => {\n onNotifyOutputChanged({\n value: dateExtractor(value!) as any\n });\n };\n const input = ref.current?.querySelector('input');\n input?.addEventListener('blur', onBlur);\n return () => {\n input?.removeEventListener('blur', onBlur);\n };\n }, [value]);\n\n return [\n isDateTime,\n theme,\n labels,\n {\n get: getDate,\n clear: clearDate,\n getFormatted: () => value,\n set: selectDate,\n setDateString: setValue,\n parseDateString: (dateString: string) => dateExtractor(dateString)\n },\n {\n shortDatePattern: shortDatePattern,\n shortTimePattern: shortTimePattern,\n fullDateTimePattern: `${shortDatePattern} ${shortTimePattern}`\n }\n ]\n};"],"names":[],"mappings":";;;;;;;AAUA,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChC,KAAK,CAA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AAE,OAAO;AACZ,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,YAAY,EAAE,MAAM,KAAK;AACzB,YAAA,GAAG,EAAE,UAAU;AACf,YAAA,aAAa,EAAE,QAAQ;YACvB,eAAe,EAAE,CAAC,UAAkB,KAAK,aAAa,CAAC,UAAU,CAAC;AACrE,SAAA;AACD,QAAA;AACI,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,gBAAgB,EAAE,gBAAgB;AAClC,YAAA,mBAAmB,EAAE,CAAA,EAAG,gBAAgB,CAAA,CAAA,EAAI,gBAAgB,CAAE,CAAA;AACjE,SAAA;KACJ,CAAA;AACL;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -647,13 +647,17 @@ declare const datasetControlTranslations: {
|
|
|
647
647
|
};
|
|
648
648
|
};
|
|
649
649
|
|
|
650
|
+
interface IQuickFindProps {
|
|
651
|
+
textFieldProps: ITextFieldProps;
|
|
652
|
+
container: ThemeProviderProps;
|
|
653
|
+
}
|
|
650
654
|
interface IDatasetControlComponentProps {
|
|
651
655
|
onDatasetInit: () => void;
|
|
652
656
|
containerProps: ThemeProviderProps;
|
|
653
657
|
headerProps: {
|
|
654
658
|
headerContainerProps: React.HTMLAttributes<HTMLDivElement>;
|
|
655
659
|
onRender: (renderQuickFind: () => React.ReactElement) => React.ReactElement;
|
|
656
|
-
onGetQuickFindProps: (props:
|
|
660
|
+
onGetQuickFindProps: (props: IQuickFindProps) => IQuickFindProps;
|
|
657
661
|
};
|
|
658
662
|
}
|
|
659
663
|
interface IDatasetControl extends IControl<IGridParameters, IGridOutputs, Partial<ITranslation<typeof datasetControlTranslations & typeof gridTranslations>>, IDatasetControlComponentProps> {
|
|
@@ -725,6 +729,7 @@ declare const useDateTime: (props: IDateTime, ref: React.RefObject<HTMLDivElemen
|
|
|
725
729
|
set: (date?: Date, time?: string) => void;
|
|
726
730
|
setDateString: (value: string | undefined) => void;
|
|
727
731
|
clear: () => void;
|
|
732
|
+
parseDateString: (dateString: string) => Date | string;
|
|
728
733
|
}, {
|
|
729
734
|
shortDatePattern: string;
|
|
730
735
|
shortTimePattern: string;
|
|
@@ -1236,4 +1241,4 @@ interface IDurationOutputs extends IOutputs$1 {
|
|
|
1236
1241
|
|
|
1237
1242
|
declare const Duration: (props: IDuration) => JSX.Element;
|
|
1238
1243
|
|
|
1239
|
-
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, 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 };
|
|
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 };
|
package/package.json
CHANGED