@servicetitan/dte-unlayer 0.144.0 → 0.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LookupValueControl.d.ts","sourceRoot":"","sources":["../../src/display-conditions/LookupValueControl.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;
|
|
1
|
+
{"version":3,"file":"LookupValueControl.d.ts","sourceRoot":"","sources":["../../src/display-conditions/LookupValueControl.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAiCD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,EAC/B,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,KAAK,GACR,EAAE,QAAQ,CAAC,uBAAuB,CAAC,2CAyJnC"}
|
|
@@ -7,6 +7,16 @@ const toOption = (option)=>({
|
|
|
7
7
|
id: option.key,
|
|
8
8
|
label: option.label
|
|
9
9
|
});
|
|
10
|
+
/*
|
|
11
|
+
* Searchable sources return nothing until the user types, which would make the
|
|
12
|
+
* dropdown show its built-in "No match found" empty state on open — confusing
|
|
13
|
+
* before any search has happened. Render a disabled hint instead so the list is
|
|
14
|
+
* never mistaken for "no results".
|
|
15
|
+
*/ const SEARCH_HINT_OPTION = {
|
|
16
|
+
id: '__lookup_search_hint__',
|
|
17
|
+
label: 'Start typing to search…',
|
|
18
|
+
disabled: true
|
|
19
|
+
};
|
|
10
20
|
const sanitizeNumericInput = (raw)=>{
|
|
11
21
|
let value = raw.replaceAll(/[^0-9.-]/g, '');
|
|
12
22
|
const isNegative = value.startsWith('-');
|
|
@@ -121,6 +131,11 @@ const sanitizeNumericInput = (raw)=>{
|
|
|
121
131
|
resolveOptions
|
|
122
132
|
]);
|
|
123
133
|
const handleLoadOptions = useCallback(async (query)=>{
|
|
134
|
+
if (!query.trim()) {
|
|
135
|
+
return [
|
|
136
|
+
SEARCH_HINT_OPTION
|
|
137
|
+
];
|
|
138
|
+
}
|
|
124
139
|
const result = await loadOptions(query);
|
|
125
140
|
return result.map(toOption);
|
|
126
141
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/display-conditions/LookupValueControl.tsx"],"sourcesContent":["import { TextField } from '@servicetitan/anvil2';\nimport { SelectField, SelectFieldOption, SelectFieldSync } from '@servicetitan/anvil2/beta';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { LookupOption } from './lookupOptionsController';\nimport { useLookupOptions } from './useLookupOptions';\n\nexport interface LookupValueControlProps {\n value: string;\n fieldType: 'number' | 'string';\n /** The selected data point's `options.fieldLookupSource`; empty -> free-text input. */\n lookupSource?: string;\n onChange: (value: string) => void;\n}\n\nconst toOption = (option: LookupOption): SelectFieldOption => ({\n id: option.key,\n label: option.label,\n});\n\nconst sanitizeNumericInput = (raw: string): string => {\n let value = raw.replaceAll(/[^0-9.-]/g, '');\n const isNegative = value.startsWith('-');\n value = value.replaceAll('-', '');\n if (isNegative) {\n value = `-${value}`;\n }\n const firstDot = value.indexOf('.');\n if (firstDot >= 0) {\n value = `${value.slice(0, firstDot + 1)}${value.slice(firstDot + 1).replaceAll('.', '')}`;\n }\n return value;\n};\n\n/**\n * Renders the value control for a single condition based on the field's lookup source:\n * - `static` -> full list returned by the host, filtered locally (`SelectFieldSync`).\n * - `searchable` -> host searches per typed query (`SelectField` + `loadOptions`).\n * - `idle`/`fallback`/`loading` -> free-text input (never block the user).\n *\n * Unlayer persists conditions as a Nunjucks string, so a saved searchable value\n * has no stored label — we display the saved key as the label until the user\n * re-searches and re-selects.\n */\nexport function LookupValueControl({\n fieldType,\n lookupSource,\n onChange,\n value,\n}: Readonly<LookupValueControlProps>) {\n const { loadOptions, options, resolveOptions, status } = useLookupOptions(lookupSource);\n\n const staticOptions = useMemo<SelectFieldOption[]>(() => options.map(toOption), [options]);\n\n /*\n * Fall back to the raw value so a saved key that the host omits from its list\n * (e.g. an inactive/renamed option) still shows on edit instead of vanishing.\n */\n const staticSelected = useMemo<SelectFieldOption | null>(() => {\n if (!value) {\n return null;\n }\n return (\n staticOptions.find(option => String(option.id) === value) ?? { id: value, label: value }\n );\n }, [staticOptions, value]);\n\n /*\n * Ensure the saved value is present in the list so it is visible/selectable\n * even when the host did not return it.\n */\n const staticOptionsWithSelected = useMemo<SelectFieldOption[]>(() => {\n if (\n staticSelected &&\n !staticOptions.some(option => String(option.id) === String(staticSelected.id))\n ) {\n return [staticSelected, ...staticOptions];\n }\n return staticOptions;\n }, [staticOptions, staticSelected]);\n\n const [searchableSelected, setSearchableSelected] = useState<SelectFieldOption | null>(\n value ? { id: value, label: value } : null,\n );\n\n // Tracks the key we've already turned into a human-readable label so we don't re-resolve it.\n const resolvedKeyRef = useRef<string | null>(null);\n\n useEffect(() => {\n setSearchableSelected(prev => {\n if (!value) {\n return null;\n }\n if (prev?.id === value) {\n return prev;\n }\n return { id: value, label: value };\n });\n }, [value]);\n\n // On open (or when a saved searchable value appears), ask the host to resolve key -> label.\n useEffect(() => {\n if (status !== 'searchable' || !value) {\n resolvedKeyRef.current = null;\n return;\n }\n if (resolvedKeyRef.current === value) {\n return;\n }\n\n let cancelled = false;\n resolveOptions([value]).then(result => {\n if (cancelled) {\n return;\n }\n const match = result.find(option => option.key === value);\n if (match) {\n resolvedKeyRef.current = value;\n setSearchableSelected({ id: match.key, label: match.label });\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [status, value, resolveOptions]);\n\n const handleLoadOptions = useCallback(\n async (query: string) => {\n const result = await loadOptions(query);\n return result.map(toOption);\n },\n [loadOptions],\n );\n\n if (status === 'loading') {\n return (\n <TextField\n label=\"Value\"\n size=\"small\"\n flex={1}\n disabled\n value=\"\"\n placeholder=\"\"\n aria-label=\"Value\"\n />\n );\n }\n\n if (status === 'static') {\n return (\n <SelectFieldSync\n flex={1}\n size=\"small\"\n label=\"Value\"\n placeholder=\"Search value...\"\n options={staticOptionsWithSelected}\n value={staticSelected}\n onSelectedOptionChange={option => onChange(option ? String(option.id) : '')}\n />\n );\n }\n\n if (status === 'searchable') {\n return (\n <SelectField\n flex={1}\n size=\"small\"\n label=\"Value\"\n placeholder=\"Type to search...\"\n initialLoad=\"open\"\n loadOptions={handleLoadOptions}\n value={searchableSelected}\n onSelectedOptionChange={option => {\n resolvedKeyRef.current = option ? String(option.id) : null;\n setSearchableSelected(option);\n onChange(option ? String(option.id) : '');\n }}\n />\n );\n }\n\n // idle / fallback (no source, empty, error, or timeout) -> free text.\n const handleTextChange = (raw: string) => {\n onChange(fieldType === 'number' ? sanitizeNumericInput(raw) : raw);\n };\n\n return (\n <TextField\n label=\"Value\"\n size=\"small\"\n flex={1}\n value={value}\n onChange={e => handleTextChange(e.target.value)}\n placeholder={fieldType === 'number' ? 'e.g. 1.5' : 'Enter value...'}\n aria-label=\"Value\"\n {...(fieldType === 'number' && { inputMode: 'decimal' })}\n />\n );\n}\n"],"names":["TextField","SelectField","SelectFieldSync","useCallback","useEffect","useMemo","useRef","useState","useLookupOptions","toOption","option","id","key","label","sanitizeNumericInput","raw","value","replaceAll","isNegative","startsWith","firstDot","indexOf","slice","LookupValueControl","fieldType","lookupSource","onChange","loadOptions","options","resolveOptions","status","staticOptions","map","staticSelected","find","String","staticOptionsWithSelected","some","searchableSelected","setSearchableSelected","resolvedKeyRef","prev","current","cancelled","then","result","match","handleLoadOptions","query","size","flex","disabled","placeholder","aria-label","onSelectedOptionChange","initialLoad","handleTextChange","e","target","inputMode"],"mappings":";AAAA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,WAAW,EAAqBC,eAAe,QAAQ,4BAA4B;AAC5F,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE1E,SAASC,gBAAgB,QAAQ,qBAAqB;AAUtD,MAAMC,WAAW,CAACC,SAA6C,CAAA;QAC3DC,IAAID,OAAOE,GAAG;QACdC,OAAOH,OAAOG,KAAK;IACvB,CAAA;AAEA,MAAMC,uBAAuB,CAACC;IAC1B,IAAIC,QAAQD,IAAIE,UAAU,CAAC,aAAa;IACxC,MAAMC,aAAaF,MAAMG,UAAU,CAAC;IACpCH,QAAQA,MAAMC,UAAU,CAAC,KAAK;IAC9B,IAAIC,YAAY;QACZF,QAAQ,CAAC,CAAC,EAAEA,OAAO;IACvB;IACA,MAAMI,WAAWJ,MAAMK,OAAO,CAAC;IAC/B,IAAID,YAAY,GAAG;QACfJ,QAAQ,GAAGA,MAAMM,KAAK,CAAC,GAAGF,WAAW,KAAKJ,MAAMM,KAAK,CAACF,WAAW,GAAGH,UAAU,CAAC,KAAK,KAAK;IAC7F;IACA,OAAOD;AACX;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASO,mBAAmB,EAC/BC,SAAS,EACTC,YAAY,EACZC,QAAQ,EACRV,KAAK,EAC2B;IAChC,MAAM,EAAEW,WAAW,EAAEC,OAAO,EAAEC,cAAc,EAAEC,MAAM,EAAE,GAAGtB,iBAAiBiB;IAE1E,MAAMM,gBAAgB1B,QAA6B,IAAMuB,QAAQI,GAAG,CAACvB,WAAW;QAACmB;KAAQ;IAEzF;;;KAGC,GACD,MAAMK,iBAAiB5B,QAAkC;QACrD,IAAI,CAACW,OAAO;YACR,OAAO;QACX;YAEIe;QADJ,OACIA,CAAAA,sBAAAA,cAAcG,IAA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YAAY;YAAEmC,WAAW;QAAU,CAAC;;AAGnE"}
|
|
1
|
+
{"version":3,"sources":["../../src/display-conditions/LookupValueControl.tsx"],"sourcesContent":["import { TextField } from '@servicetitan/anvil2';\nimport { SelectField, SelectFieldOption, SelectFieldSync } from '@servicetitan/anvil2/beta';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { LookupOption } from './lookupOptionsController';\nimport { useLookupOptions } from './useLookupOptions';\n\nexport interface LookupValueControlProps {\n value: string;\n fieldType: 'number' | 'string';\n /** The selected data point's `options.fieldLookupSource`; empty -> free-text input. */\n lookupSource?: string;\n onChange: (value: string) => void;\n}\n\nconst toOption = (option: LookupOption): SelectFieldOption => ({\n id: option.key,\n label: option.label,\n});\n\n/*\n * Searchable sources return nothing until the user types, which would make the\n * dropdown show its built-in \"No match found\" empty state on open — confusing\n * before any search has happened. Render a disabled hint instead so the list is\n * never mistaken for \"no results\".\n */\nconst SEARCH_HINT_OPTION: SelectFieldOption = {\n id: '__lookup_search_hint__',\n label: 'Start typing to search…',\n disabled: true,\n};\n\nconst sanitizeNumericInput = (raw: string): string => {\n let value = raw.replaceAll(/[^0-9.-]/g, '');\n const isNegative = value.startsWith('-');\n value = value.replaceAll('-', '');\n if (isNegative) {\n value = `-${value}`;\n }\n const firstDot = value.indexOf('.');\n if (firstDot >= 0) {\n value = `${value.slice(0, firstDot + 1)}${value.slice(firstDot + 1).replaceAll('.', '')}`;\n }\n return value;\n};\n\n/**\n * Renders the value control for a single condition based on the field's lookup source:\n * - `static` -> full list returned by the host, filtered locally (`SelectFieldSync`).\n * - `searchable` -> host searches per typed query (`SelectField` + `loadOptions`).\n * - `idle`/`fallback`/`loading` -> free-text input (never block the user).\n *\n * Unlayer persists conditions as a Nunjucks string, so a saved searchable value\n * has no stored label — we display the saved key as the label until the user\n * re-searches and re-selects.\n */\nexport function LookupValueControl({\n fieldType,\n lookupSource,\n onChange,\n value,\n}: Readonly<LookupValueControlProps>) {\n const { loadOptions, options, resolveOptions, status } = useLookupOptions(lookupSource);\n\n const staticOptions = useMemo<SelectFieldOption[]>(() => options.map(toOption), [options]);\n\n /*\n * Fall back to the raw value so a saved key that the host omits from its list\n * (e.g. an inactive/renamed option) still shows on edit instead of vanishing.\n */\n const staticSelected = useMemo<SelectFieldOption | null>(() => {\n if (!value) {\n return null;\n }\n return (\n staticOptions.find(option => String(option.id) === value) ?? { id: value, label: value }\n );\n }, [staticOptions, value]);\n\n /*\n * Ensure the saved value is present in the list so it is visible/selectable\n * even when the host did not return it.\n */\n const staticOptionsWithSelected = useMemo<SelectFieldOption[]>(() => {\n if (\n staticSelected &&\n !staticOptions.some(option => String(option.id) === String(staticSelected.id))\n ) {\n return [staticSelected, ...staticOptions];\n }\n return staticOptions;\n }, [staticOptions, staticSelected]);\n\n const [searchableSelected, setSearchableSelected] = useState<SelectFieldOption | null>(\n value ? { id: value, label: value } : null,\n );\n\n // Tracks the key we've already turned into a human-readable label so we don't re-resolve it.\n const resolvedKeyRef = useRef<string | null>(null);\n\n useEffect(() => {\n setSearchableSelected(prev => {\n if (!value) {\n return null;\n }\n if (prev?.id === value) {\n return prev;\n }\n return { id: value, label: value };\n });\n }, [value]);\n\n // On open (or when a saved searchable value appears), ask the host to resolve key -> label.\n useEffect(() => {\n if (status !== 'searchable' || !value) {\n resolvedKeyRef.current = null;\n return;\n }\n if (resolvedKeyRef.current === value) {\n return;\n }\n\n let cancelled = false;\n resolveOptions([value]).then(result => {\n if (cancelled) {\n return;\n }\n const match = result.find(option => option.key === value);\n if (match) {\n resolvedKeyRef.current = value;\n setSearchableSelected({ id: match.key, label: match.label });\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [status, value, resolveOptions]);\n\n const handleLoadOptions = useCallback(\n async (query: string) => {\n if (!query.trim()) {\n return [SEARCH_HINT_OPTION];\n }\n const result = await loadOptions(query);\n return result.map(toOption);\n },\n [loadOptions],\n );\n\n if (status === 'loading') {\n return (\n <TextField\n label=\"Value\"\n size=\"small\"\n flex={1}\n disabled\n value=\"\"\n placeholder=\"\"\n aria-label=\"Value\"\n />\n );\n }\n\n if (status === 'static') {\n return (\n <SelectFieldSync\n flex={1}\n size=\"small\"\n label=\"Value\"\n placeholder=\"Search value...\"\n options={staticOptionsWithSelected}\n value={staticSelected}\n onSelectedOptionChange={option => onChange(option ? String(option.id) : '')}\n />\n );\n }\n\n if (status === 'searchable') {\n return (\n <SelectField\n flex={1}\n size=\"small\"\n label=\"Value\"\n placeholder=\"Type to search...\"\n initialLoad=\"open\"\n loadOptions={handleLoadOptions}\n value={searchableSelected}\n onSelectedOptionChange={option => {\n resolvedKeyRef.current = option ? String(option.id) : null;\n setSearchableSelected(option);\n onChange(option ? String(option.id) : '');\n }}\n />\n );\n }\n\n // idle / fallback (no source, empty, error, or timeout) -> free text.\n const handleTextChange = (raw: string) => {\n onChange(fieldType === 'number' ? sanitizeNumericInput(raw) : raw);\n };\n\n return (\n <TextField\n label=\"Value\"\n size=\"small\"\n flex={1}\n value={value}\n onChange={e => handleTextChange(e.target.value)}\n placeholder={fieldType === 'number' ? 'e.g. 1.5' : 'Enter value...'}\n aria-label=\"Value\"\n {...(fieldType === 'number' && { inputMode: 'decimal' })}\n />\n );\n}\n"],"names":["TextField","SelectField","SelectFieldSync","useCallback","useEffect","useMemo","useRef","useState","useLookupOptions","toOption","option","id","key","label","SEARCH_HINT_OPTION","disabled","sanitizeNumericInput","raw","value","replaceAll","isNegative","startsWith","firstDot","indexOf","slice","LookupValueControl","fieldType","lookupSource","onChange","loadOptions","options","resolveOptions","status","staticOptions","map","staticSelected","find","String","staticOptionsWithSelected","some","searchableSelected","setSearchableSelected","resolvedKeyRef","prev","current","cancelled","then","result","match","handleLoadOptions","query","trim","size","flex","placeholder","aria-label","onSelectedOptionChange","initialLoad","handleTextChange","e","target","inputMode"],"mappings":";AAAA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,WAAW,EAAqBC,eAAe,QAAQ,4BAA4B;AAC5F,SAASC,WAAW,EAAE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C;;AAGnE"}
|
package/package.json
CHANGED
|
@@ -17,6 +17,18 @@ const toOption = (option: LookupOption): SelectFieldOption => ({
|
|
|
17
17
|
label: option.label,
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
/*
|
|
21
|
+
* Searchable sources return nothing until the user types, which would make the
|
|
22
|
+
* dropdown show its built-in "No match found" empty state on open — confusing
|
|
23
|
+
* before any search has happened. Render a disabled hint instead so the list is
|
|
24
|
+
* never mistaken for "no results".
|
|
25
|
+
*/
|
|
26
|
+
const SEARCH_HINT_OPTION: SelectFieldOption = {
|
|
27
|
+
id: '__lookup_search_hint__',
|
|
28
|
+
label: 'Start typing to search…',
|
|
29
|
+
disabled: true,
|
|
30
|
+
};
|
|
31
|
+
|
|
20
32
|
const sanitizeNumericInput = (raw: string): string => {
|
|
21
33
|
let value = raw.replaceAll(/[^0-9.-]/g, '');
|
|
22
34
|
const isNegative = value.startsWith('-');
|
|
@@ -126,6 +138,9 @@ export function LookupValueControl({
|
|
|
126
138
|
|
|
127
139
|
const handleLoadOptions = useCallback(
|
|
128
140
|
async (query: string) => {
|
|
141
|
+
if (!query.trim()) {
|
|
142
|
+
return [SEARCH_HINT_OPTION];
|
|
143
|
+
}
|
|
129
144
|
const result = await loadOptions(query);
|
|
130
145
|
return result.map(toOption);
|
|
131
146
|
},
|