@servicetitan/dte-unlayer 0.158.0 → 0.159.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.
Files changed (147) hide show
  1. package/dist/api-core.js +22 -29
  2. package/dist/api-core.js.map +1 -1
  3. package/dist/api-custom-tools.js +23 -29
  4. package/dist/api-custom-tools.js.map +1 -1
  5. package/dist/business-calendar/BusinessCalendarDrawer.d.ts +19 -0
  6. package/dist/business-calendar/BusinessCalendarDrawer.d.ts.map +1 -0
  7. package/dist/business-calendar/BusinessCalendarDrawer.js +41 -0
  8. package/dist/business-calendar/BusinessCalendarDrawer.js.map +1 -0
  9. package/dist/business-calendar/business-calendar-requests.d.ts +25 -0
  10. package/dist/business-calendar/business-calendar-requests.d.ts.map +1 -0
  11. package/dist/business-calendar/business-calendar-requests.js +46 -0
  12. package/dist/business-calendar/business-calendar-requests.js.map +1 -0
  13. package/dist/business-calendar/business-calendar-state.d.ts +22 -0
  14. package/dist/business-calendar/business-calendar-state.d.ts.map +1 -0
  15. package/dist/business-calendar/business-calendar-state.js +74 -0
  16. package/dist/business-calendar/business-calendar-state.js.map +1 -0
  17. package/dist/business-calendar/useBusinessCalendarRequests.d.ts +15 -0
  18. package/dist/business-calendar/useBusinessCalendarRequests.d.ts.map +1 -0
  19. package/dist/business-calendar/useBusinessCalendarRequests.js +30 -0
  20. package/dist/business-calendar/useBusinessCalendarRequests.js.map +1 -0
  21. package/dist/display-conditions/ConditionGroup.js +15 -89
  22. package/dist/display-conditions/ConditionGroup.js.map +1 -1
  23. package/dist/display-conditions/ConditionGroupsSection.js +2 -70
  24. package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
  25. package/dist/display-conditions/ConditionRow.js +63 -205
  26. package/dist/display-conditions/ConditionRow.js.map +1 -1
  27. package/dist/display-conditions/DisplayConditionModal.js +40 -190
  28. package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
  29. package/dist/display-conditions/LookupValueControl.js +42 -105
  30. package/dist/display-conditions/LookupValueControl.js.map +1 -1
  31. package/dist/display-conditions/SeparatorWithChip.js +1 -10
  32. package/dist/display-conditions/SeparatorWithChip.js.map +1 -1
  33. package/dist/display-conditions/constants.js +15 -20
  34. package/dist/display-conditions/constants.js.map +1 -1
  35. package/dist/display-conditions/displayConditionController.js +5 -8
  36. package/dist/display-conditions/displayConditionController.js.map +1 -1
  37. package/dist/display-conditions/lookupOptionsController.js +16 -16
  38. package/dist/display-conditions/lookupOptionsController.js.map +1 -1
  39. package/dist/display-conditions/nunjucks.js +98 -116
  40. package/dist/display-conditions/nunjucks.js.map +1 -1
  41. package/dist/display-conditions/schemaDataPoints.js +13 -11
  42. package/dist/display-conditions/schemaDataPoints.js.map +1 -1
  43. package/dist/display-conditions/types.js +23 -67
  44. package/dist/display-conditions/types.js.map +1 -1
  45. package/dist/display-conditions/useConditionForms.js +38 -56
  46. package/dist/display-conditions/useConditionForms.js.map +1 -1
  47. package/dist/display-conditions/useLookupOptions.js +24 -44
  48. package/dist/display-conditions/useLookupOptions.js.map +1 -1
  49. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +37 -150
  50. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -1
  51. package/dist/e-sign-offset/ESignOffsetRuleRow.js +12 -73
  52. package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -1
  53. package/dist/e-sign-offset/eSignOffsetController.js +5 -8
  54. package/dist/e-sign-offset/eSignOffsetController.js.map +1 -1
  55. package/dist/editor-core-source.d.ts +2 -2
  56. package/dist/editor-core-source.d.ts.map +1 -1
  57. package/dist/editor-core-source.js +3 -3
  58. package/dist/editor-core-source.js.map +1 -1
  59. package/dist/editor-core.js +2 -2
  60. package/dist/editor-core.js.map +1 -1
  61. package/dist/editor.d.ts.map +1 -1
  62. package/dist/editor.js +56 -118
  63. package/dist/editor.js.map +1 -1
  64. package/dist/image-upload-error.js +3 -3
  65. package/dist/image-upload-error.js.map +1 -1
  66. package/dist/index.d.ts +1 -0
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +0 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/loadScript.js +7 -8
  71. package/dist/loadScript.js.map +1 -1
  72. package/dist/log.js +2 -3
  73. package/dist/log.js.map +1 -1
  74. package/dist/merge-tags.js +18 -17
  75. package/dist/merge-tags.js.map +1 -1
  76. package/dist/shared/configs.js +1 -2
  77. package/dist/shared/configs.js.map +1 -1
  78. package/dist/shared/const.d.ts +70 -0
  79. package/dist/shared/const.d.ts.map +1 -1
  80. package/dist/shared/const.js +13 -4
  81. package/dist/shared/const.js.map +1 -1
  82. package/dist/shared/date-calc.js +47 -38
  83. package/dist/shared/date-calc.js.map +1 -1
  84. package/dist/shared/e-sign-offset.js +46 -63
  85. package/dist/shared/e-sign-offset.js.map +1 -1
  86. package/dist/shared/edit-icon.js +0 -1
  87. package/dist/shared/edit-icon.js.map +1 -1
  88. package/dist/shared/fonts.js +16 -17
  89. package/dist/shared/fonts.js.map +1 -1
  90. package/dist/shared/forms.js +16 -38
  91. package/dist/shared/forms.js.map +1 -1
  92. package/dist/shared/instance-id.js +6 -9
  93. package/dist/shared/instance-id.js.map +1 -1
  94. package/dist/shared/nunjucks-helpers.js +2 -5
  95. package/dist/shared/nunjucks-helpers.js.map +1 -1
  96. package/dist/shared/schema.js +52 -96
  97. package/dist/shared/schema.js.map +1 -1
  98. package/dist/shared/tools.js +6 -13
  99. package/dist/shared/tools.js.map +1 -1
  100. package/dist/store.d.ts +15 -1
  101. package/dist/store.d.ts.map +1 -1
  102. package/dist/store.js +851 -548
  103. package/dist/store.js.map +1 -1
  104. package/dist/tools.js +133 -143
  105. package/dist/tools.js.map +1 -1
  106. package/dist/unlayer-interface.d.ts +15 -4
  107. package/dist/unlayer-interface.d.ts.map +1 -1
  108. package/dist/unlayer-interface.js +1 -2
  109. package/dist/unlayer-interface.js.map +1 -1
  110. package/dist/unlayer.js +86 -113
  111. package/dist/unlayer.js.map +1 -1
  112. package/dist/vendor/dte-shared/business-calendar-validation.utils.d.ts +25 -0
  113. package/dist/vendor/dte-shared/business-calendar-validation.utils.js +80 -0
  114. package/dist/vendor/dte-shared/components/business-calendar-section.d.ts +15 -0
  115. package/dist/vendor/dte-shared/components/business-calendar-section.js +14 -0
  116. package/dist/vendor/dte-shared/components/schedule-drawer.d.ts +18 -0
  117. package/dist/vendor/dte-shared/components/schedule-drawer.js +119 -0
  118. package/dist/vendor/dte-shared/components/schedule-picker.d.ts +8 -0
  119. package/dist/vendor/dte-shared/components/schedule-picker.js +88 -0
  120. package/dist/vendor/dte-shared/constants.d.ts +31 -0
  121. package/dist/vendor/dte-shared/constants.js +34 -0
  122. package/dist/vendor/dte-shared/field-schedule-editor-context.d.ts +31 -0
  123. package/dist/vendor/dte-shared/field-schedule-editor-context.js +110 -0
  124. package/dist/vendor/dte-shared/index.d.ts +8 -0
  125. package/dist/vendor/dte-shared/index.js +7 -0
  126. package/dist/vendor/dte-shared/schedule-bindings.utils.d.ts +22 -0
  127. package/dist/vendor/dte-shared/schedule-bindings.utils.js +31 -0
  128. package/dist/vendor/dte-shared/styles/schedule.css +19 -0
  129. package/dist/vendor/dte-shared/types.d.ts +129 -0
  130. package/dist/vendor/dte-shared/types.js +1 -0
  131. package/package.json +7 -1
  132. package/src/__tests__/business-calendar-drawer.test.tsx +183 -0
  133. package/src/__tests__/business-calendar-requests.test.ts +166 -0
  134. package/src/__tests__/business-calendar-state.test.tsx +142 -0
  135. package/src/__tests__/store.business-calendar.test.ts +185 -0
  136. package/src/__tests__/unlayer.e-sign-types.test.ts +30 -0
  137. package/src/business-calendar/BusinessCalendarDrawer.tsx +76 -0
  138. package/src/business-calendar/business-calendar-requests.ts +80 -0
  139. package/src/business-calendar/business-calendar-state.ts +113 -0
  140. package/src/business-calendar/useBusinessCalendarRequests.ts +49 -0
  141. package/src/editor-core-source.ts +2 -2
  142. package/src/editor.tsx +15 -0
  143. package/src/index.ts +10 -0
  144. package/src/shared/const.ts +59 -0
  145. package/src/store.ts +67 -5
  146. package/src/unlayer-interface.tsx +15 -4
  147. package/src/unlayer.tsx +5 -5
@@ -1,15 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Chip, Divider } from '@servicetitan/anvil2';
3
3
  export function SeparatorWithChip({ color = '#94a3b8', label }) {
4
- return /*#__PURE__*/ _jsx(Divider, {
5
- alignContent: "center",
6
- spacing: "2",
7
- children: /*#__PURE__*/ _jsx(Chip, {
8
- label: label,
9
- size: "small",
10
- color: color
11
- })
12
- });
4
+ return (_jsx(Divider, { alignContent: "center", spacing: "2", children: _jsx(Chip, { label: label, size: "small", color: color }) }));
13
5
  }
14
-
15
6
  //# sourceMappingURL=SeparatorWithChip.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/display-conditions/SeparatorWithChip.tsx"],"sourcesContent":["import { Chip, Divider } from '@servicetitan/anvil2';\n\nexport interface SeparatorWithChipProps {\n label: string;\n color?: string;\n}\n\nexport function SeparatorWithChip({ color = '#94a3b8', label }: Readonly<SeparatorWithChipProps>) {\n return (\n <Divider alignContent=\"center\" spacing=\"2\">\n <Chip label={label} size=\"small\" color={color} />\n </Divider>\n );\n}\n"],"names":["Chip","Divider","SeparatorWithChip","color","label","alignContent","spacing","size"],"mappings":";AAAA,SAASA,IAAI,EAAEC,OAAO,QAAQ,uBAAuB;AAOrD,OAAO,SAASC,kBAAkB,EAAEC,QAAQ,SAAS,EAAEC,KAAK,EAAoC;IAC5F,qBACI,KAACH;QAAQI,cAAa;QAASC,SAAQ;kBACnC,cAAA,KAACN;YAAKI,OAAOA;YAAOG,MAAK;YAAQJ,OAAOA;;;AAGpD"}
1
+ {"version":3,"file":"SeparatorWithChip.js","sourceRoot":"","sources":["../../src/display-conditions/SeparatorWithChip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAOrD,MAAM,UAAU,iBAAiB,CAAC,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,EAAoC;IAC5F,OAAO,CACH,KAAC,OAAO,IAAC,YAAY,EAAC,QAAQ,EAAC,OAAO,EAAC,GAAG,YACtC,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,KAAK,GAAI,GAC3C,CACb,CAAC;AACN,CAAC"}
@@ -1,22 +1,17 @@
1
- export const generateId = ()=>Math.random().toString(36).slice(2, 11);
2
- export const defaultCondition = ()=>({
3
- dataPointKey: '',
4
- id: generateId(),
5
- operator: 'is_equal_to',
6
- value: ''
7
- });
8
- export const defaultGroup = ()=>({
9
- conditions: [
10
- defaultCondition()
11
- ],
12
- id: generateId()
13
- });
14
- export const defaultState = ()=>({
15
- behavior: 'show',
16
- groups: [
17
- defaultGroup()
18
- ]
19
- });
1
+ export const generateId = () => Math.random().toString(36).slice(2, 11);
2
+ export const defaultCondition = () => ({
3
+ dataPointKey: '',
4
+ id: generateId(),
5
+ operator: 'is_equal_to',
6
+ value: '',
7
+ });
8
+ export const defaultGroup = () => ({
9
+ conditions: [defaultCondition()],
10
+ id: generateId(),
11
+ });
12
+ export const defaultState = () => ({
13
+ behavior: 'show',
14
+ groups: [defaultGroup()],
15
+ });
20
16
  export const MODAL_CONTENT_MAX_HEIGHT = '70vh';
21
-
22
17
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/display-conditions/constants.ts"],"sourcesContent":["import { ConditionGroup, DisplayConditionState, SingleCondition } from './types';\n\nexport const generateId = () => Math.random().toString(36).slice(2, 11);\n\nexport const defaultCondition = (): SingleCondition => ({\n dataPointKey: '',\n id: generateId(),\n operator: 'is_equal_to',\n value: '',\n});\n\nexport const defaultGroup = (): ConditionGroup => ({\n conditions: [defaultCondition()],\n id: generateId(),\n});\n\nexport const defaultState = (): DisplayConditionState => ({\n behavior: 'show',\n groups: [defaultGroup()],\n});\n\nexport const MODAL_CONTENT_MAX_HEIGHT = '70vh';\n"],"names":["generateId","Math","random","toString","slice","defaultCondition","dataPointKey","id","operator","value","defaultGroup","conditions","defaultState","behavior","groups","MODAL_CONTENT_MAX_HEIGHT"],"mappings":"AAEA,OAAO,MAAMA,aAAa,IAAMC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG,IAAI;AAExE,OAAO,MAAMC,mBAAmB,IAAwB,CAAA;QACpDC,cAAc;QACdC,IAAIP;QACJQ,UAAU;QACVC,OAAO;IACX,CAAA,EAAG;AAEH,OAAO,MAAMC,eAAe,IAAuB,CAAA;QAC/CC,YAAY;YAACN;SAAmB;QAChCE,IAAIP;IACR,CAAA,EAAG;AAEH,OAAO,MAAMY,eAAe,IAA8B,CAAA;QACtDC,UAAU;QACVC,QAAQ;YAACJ;SAAe;IAC5B,CAAA,EAAG;AAEH,OAAO,MAAMK,2BAA2B,OAAO"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/display-conditions/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAoB,EAAE,CAAC,CAAC;IACpD,YAAY,EAAE,EAAE;IAChB,EAAE,EAAE,UAAU,EAAE;IAChB,QAAQ,EAAE,aAAa;IACvB,KAAK,EAAE,EAAE;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAmB,EAAE,CAAC,CAAC;IAC/C,UAAU,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAChC,EAAE,EAAE,UAAU,EAAE;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,GAA0B,EAAE,CAAC,CAAC;IACtD,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,CAAC,YAAY,EAAE,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC"}
@@ -1,8 +1,8 @@
1
1
  const DISPLAY_CONDITION_EVENT = 'dte:display-condition';
2
2
  const displayConditionEvents = new EventTarget();
3
3
  let activeListeners = 0;
4
- export const onDisplayCondition = (listener)=>{
5
- const handler = (event)=>{
4
+ export const onDisplayCondition = (listener) => {
5
+ const handler = (event) => {
6
6
  const detail = event.detail;
7
7
  if (!detail) {
8
8
  return;
@@ -11,19 +11,16 @@ export const onDisplayCondition = (listener)=>{
11
11
  };
12
12
  activeListeners += 1;
13
13
  displayConditionEvents.addEventListener(DISPLAY_CONDITION_EVENT, handler);
14
- return ()=>{
14
+ return () => {
15
15
  activeListeners = Math.max(0, activeListeners - 1);
16
16
  displayConditionEvents.removeEventListener(DISPLAY_CONDITION_EVENT, handler);
17
17
  };
18
18
  };
19
- export const emitDisplayCondition = (request)=>{
19
+ export const emitDisplayCondition = (request) => {
20
20
  if (activeListeners === 0) {
21
21
  request.done(request.data);
22
22
  return;
23
23
  }
24
- displayConditionEvents.dispatchEvent(new CustomEvent(DISPLAY_CONDITION_EVENT, {
25
- detail: request
26
- }));
24
+ displayConditionEvents.dispatchEvent(new CustomEvent(DISPLAY_CONDITION_EVENT, { detail: request }));
27
25
  };
28
-
29
26
  //# sourceMappingURL=displayConditionController.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/display-conditions/displayConditionController.ts"],"sourcesContent":["export interface DisplayConditionRequest {\n data: any;\n done: (condition: any) => void;\n}\n\ntype Listener = (request: DisplayConditionRequest) => void;\n\nconst DISPLAY_CONDITION_EVENT = 'dte:display-condition';\nconst displayConditionEvents = new EventTarget();\nlet activeListeners = 0;\n\nexport const onDisplayCondition = (listener: Listener) => {\n const handler = (event: Event) => {\n const detail = (event as CustomEvent<DisplayConditionRequest>).detail;\n if (!detail) {\n return;\n }\n listener(detail);\n };\n\n activeListeners += 1;\n displayConditionEvents.addEventListener(DISPLAY_CONDITION_EVENT, handler as EventListener);\n\n return () => {\n activeListeners = Math.max(0, activeListeners - 1);\n displayConditionEvents.removeEventListener(\n DISPLAY_CONDITION_EVENT,\n handler as EventListener,\n );\n };\n};\n\nexport const emitDisplayCondition = (request: DisplayConditionRequest) => {\n if (activeListeners === 0) {\n request.done(request.data);\n return;\n }\n\n displayConditionEvents.dispatchEvent(\n new CustomEvent<DisplayConditionRequest>(DISPLAY_CONDITION_EVENT, { detail: request }),\n );\n};\n"],"names":["DISPLAY_CONDITION_EVENT","displayConditionEvents","EventTarget","activeListeners","onDisplayCondition","listener","handler","event","detail","addEventListener","Math","max","removeEventListener","emitDisplayCondition","request","done","data","dispatchEvent","CustomEvent"],"mappings":"AAOA,MAAMA,0BAA0B;AAChC,MAAMC,yBAAyB,IAAIC;AACnC,IAAIC,kBAAkB;AAEtB,OAAO,MAAMC,qBAAqB,CAACC;IAC/B,MAAMC,UAAU,CAACC;QACb,MAAMC,SAAS,AAACD,MAA+CC,MAAM;QACrE,IAAI,CAACA,QAAQ;YACT;QACJ;QACAH,SAASG;IACb;IAEAL,mBAAmB;IACnBF,uBAAuBQ,gBAAgB,CAACT,yBAAyBM;IAEjE,OAAO;QACHH,kBAAkBO,KAAKC,GAAG,CAAC,GAAGR,kBAAkB;QAChDF,uBAAuBW,mBAAmB,CACtCZ,yBACAM;IAER;AACJ,EAAE;AAEF,OAAO,MAAMO,uBAAuB,CAACC;IACjC,IAAIX,oBAAoB,GAAG;QACvBW,QAAQC,IAAI,CAACD,QAAQE,IAAI;QACzB;IACJ;IAEAf,uBAAuBgB,aAAa,CAChC,IAAIC,YAAqClB,yBAAyB;QAAEQ,QAAQM;IAAQ;AAE5F,EAAE"}
1
+ {"version":3,"file":"displayConditionController.js","sourceRoot":"","sources":["../../src/display-conditions/displayConditionController.ts"],"names":[],"mappings":"AAOA,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AACxD,MAAM,sBAAsB,GAAG,IAAI,WAAW,EAAE,CAAC;AACjD,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAkB,EAAE,EAAE;IACrD,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAI,KAA8C,CAAC,MAAM,CAAC;QACtE,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO;QACX,CAAC;QACD,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,eAAe,IAAI,CAAC,CAAC;IACrB,sBAAsB,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,OAAwB,CAAC,CAAC;IAE3F,OAAO,GAAG,EAAE;QACR,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,CAAC;QACnD,sBAAsB,CAAC,mBAAmB,CACtC,uBAAuB,EACvB,OAAwB,CAC3B,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAgC,EAAE,EAAE;IACrE,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO;IACX,CAAC;IAED,sBAAsB,CAAC,aAAa,CAChC,IAAI,WAAW,CAA0B,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CACzF,CAAC;AACN,CAAC,CAAC"}
@@ -25,16 +25,17 @@
25
25
  * The host-side resolver is intentionally NOT implemented in this package. The
26
26
  * host listens via `onLookupOptionsRequest` and replies via
27
27
  * `emitLookupOptionsResponse`.
28
- */ /** The single dropdown option shape used end-to-end. */ export const LOOKUP_OPTIONS_REQUEST_EVENT = 'dte-unlayer:lookup-options-request';
28
+ */
29
+ export const LOOKUP_OPTIONS_REQUEST_EVENT = 'dte-unlayer:lookup-options-request';
29
30
  export const LOOKUP_OPTIONS_RESPONSE_EVENT = 'dte-unlayer:lookup-options-response';
30
31
  const lookupOptionsEvents = new EventTarget();
31
- /** editor -> host: ask the host to resolve options for a lookup source. */ export const emitLookupOptionsRequest = (request)=>{
32
- lookupOptionsEvents.dispatchEvent(new CustomEvent(LOOKUP_OPTIONS_REQUEST_EVENT, {
33
- detail: request
34
- }));
32
+ /** editor -> host: ask the host to resolve options for a lookup source. */
33
+ export const emitLookupOptionsRequest = (request) => {
34
+ lookupOptionsEvents.dispatchEvent(new CustomEvent(LOOKUP_OPTIONS_REQUEST_EVENT, { detail: request }));
35
35
  };
36
- /** host side: listen for editor requests. Returns an unsubscribe function. */ export const onLookupOptionsRequest = (listener)=>{
37
- const handler = (event)=>{
36
+ /** host side: listen for editor requests. Returns an unsubscribe function. */
37
+ export const onLookupOptionsRequest = (listener) => {
38
+ const handler = (event) => {
38
39
  const detail = event.detail;
39
40
  if (!detail) {
40
41
  return;
@@ -42,17 +43,17 @@ const lookupOptionsEvents = new EventTarget();
42
43
  listener(detail);
43
44
  };
44
45
  lookupOptionsEvents.addEventListener(LOOKUP_OPTIONS_REQUEST_EVENT, handler);
45
- return ()=>{
46
+ return () => {
46
47
  lookupOptionsEvents.removeEventListener(LOOKUP_OPTIONS_REQUEST_EVENT, handler);
47
48
  };
48
49
  };
49
- /** host -> editor: deliver resolved options back to the editor. */ export const emitLookupOptionsResponse = (response)=>{
50
- lookupOptionsEvents.dispatchEvent(new CustomEvent(LOOKUP_OPTIONS_RESPONSE_EVENT, {
51
- detail: response
52
- }));
50
+ /** host -> editor: deliver resolved options back to the editor. */
51
+ export const emitLookupOptionsResponse = (response) => {
52
+ lookupOptionsEvents.dispatchEvent(new CustomEvent(LOOKUP_OPTIONS_RESPONSE_EVENT, { detail: response }));
53
53
  };
54
- /** editor side: listen for host responses. Returns an unsubscribe function. */ export const onLookupOptionsResponse = (listener)=>{
55
- const handler = (event)=>{
54
+ /** editor side: listen for host responses. Returns an unsubscribe function. */
55
+ export const onLookupOptionsResponse = (listener) => {
56
+ const handler = (event) => {
56
57
  const detail = event.detail;
57
58
  if (!detail) {
58
59
  return;
@@ -60,9 +61,8 @@ const lookupOptionsEvents = new EventTarget();
60
61
  listener(detail);
61
62
  };
62
63
  lookupOptionsEvents.addEventListener(LOOKUP_OPTIONS_RESPONSE_EVENT, handler);
63
- return ()=>{
64
+ return () => {
64
65
  lookupOptionsEvents.removeEventListener(LOOKUP_OPTIONS_RESPONSE_EVENT, handler);
65
66
  };
66
67
  };
67
-
68
68
  //# sourceMappingURL=lookupOptionsController.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/display-conditions/lookupOptionsController.ts"],"sourcesContent":["/**\n * Host <-> editor contract for \"data-model lookup source\" dropdown options.\n *\n * A schema field can be tagged (in the template-type editor) with\n * `options.fieldLookupSource`. When such a field is selected in the conditional\n * UI, the editor does NOT own the option data — it asks the HOST for it over the\n * EventTarget bus below and renders whatever the host returns.\n *\n * Two host-driven modes are supported (the host decides, the editor adapts):\n * 1. Full-list source (e.g. \"state\", \"jobType\"): the host returns every option\n * on the first request and omits `searchable`. The editor caches that list\n * and filters it LOCALLY as the user types — no further requests are sent.\n * 2. Searchable source (e.g. \"city\"): the list is too large to send at once.\n * The host returns `searchable: true` (typically with an empty list on the\n * first, query-less request). The editor then re-requests with the typed\n * `query` on each keystroke and the host returns a fresh, server-filtered\n * list per query.\n *\n * Transport mirrors the existing `displayConditionController` EventBus pattern.\n *\n * Event names (host <-> editor):\n * - \"dte-unlayer:lookup-options-request\" (editor -> host)\n * - \"dte-unlayer:lookup-options-response\" (host -> editor)\n *\n * The host-side resolver is intentionally NOT implemented in this package. The\n * host listens via `onLookupOptionsRequest` and replies via\n * `emitLookupOptionsResponse`.\n */\n\n/** The single dropdown option shape used end-to-end. */\nexport interface LookupOption {\n /** Human-readable label shown in the dropdown. */\n label: string;\n /** Stable value baked into the stored condition. */\n key: string;\n}\n\n/** editor -> host */\nexport interface LookupOptionsRequest {\n /** Correlates a response to its originating request. */\n requestId: string;\n /** The selected field's `options.fieldLookupSource`. */\n sourceKey: string;\n /**\n * The text the user has typed. Sent on each (debounced) keystroke once the\n * host has declared the source `searchable`. Empty/omitted on the first\n * request, where the host decides whether the source is searchable.\n */\n query?: string;\n /**\n * Resolve mode: the editor is asking the host to return the option(s) for\n * these EXACT stored keys (not a text search). Used on open to turn a saved\n * searchable value (a bare key) back into a human-readable label. When\n * present the host should match by key and ignore `query`.\n */\n keys?: string[];\n}\n\n/** host -> editor */\nexport interface LookupOptionsResponse {\n requestId: string;\n options: LookupOption[];\n /**\n * Set to `true` by the host when the source must be searched per query\n * (server-side). When omitted/false the editor treats `options` as the\n * complete list and switches to local filtering. Only read from the first\n * (query-less) response for a given source.\n */\n searchable?: boolean;\n}\n\nexport const LOOKUP_OPTIONS_REQUEST_EVENT = 'dte-unlayer:lookup-options-request';\nexport const LOOKUP_OPTIONS_RESPONSE_EVENT = 'dte-unlayer:lookup-options-response';\n\nconst lookupOptionsEvents = new EventTarget();\n\n/** editor -> host: ask the host to resolve options for a lookup source. */\nexport const emitLookupOptionsRequest = (request: LookupOptionsRequest) => {\n lookupOptionsEvents.dispatchEvent(\n new CustomEvent<LookupOptionsRequest>(LOOKUP_OPTIONS_REQUEST_EVENT, { detail: request }),\n );\n};\n\n/** host side: listen for editor requests. Returns an unsubscribe function. */\nexport const onLookupOptionsRequest = (listener: (request: LookupOptionsRequest) => void) => {\n const handler = (event: Event) => {\n const detail = (event as CustomEvent<LookupOptionsRequest>).detail;\n if (!detail) {\n return;\n }\n listener(detail);\n };\n\n lookupOptionsEvents.addEventListener(LOOKUP_OPTIONS_REQUEST_EVENT, handler);\n\n return () => {\n lookupOptionsEvents.removeEventListener(LOOKUP_OPTIONS_REQUEST_EVENT, handler);\n };\n};\n\n/** host -> editor: deliver resolved options back to the editor. */\nexport const emitLookupOptionsResponse = (response: LookupOptionsResponse) => {\n lookupOptionsEvents.dispatchEvent(\n new CustomEvent<LookupOptionsResponse>(LOOKUP_OPTIONS_RESPONSE_EVENT, { detail: response }),\n );\n};\n\n/** editor side: listen for host responses. Returns an unsubscribe function. */\nexport const onLookupOptionsResponse = (listener: (response: LookupOptionsResponse) => void) => {\n const handler = (event: Event) => {\n const detail = (event as CustomEvent<LookupOptionsResponse>).detail;\n if (!detail) {\n return;\n }\n listener(detail);\n };\n\n lookupOptionsEvents.addEventListener(LOOKUP_OPTIONS_RESPONSE_EVENT, handler);\n\n return () => {\n lookupOptionsEvents.removeEventListener(LOOKUP_OPTIONS_RESPONSE_EVENT, handler);\n };\n};\n"],"names":["LOOKUP_OPTIONS_REQUEST_EVENT","LOOKUP_OPTIONS_RESPONSE_EVENT","lookupOptionsEvents","EventTarget","emitLookupOptionsRequest","request","dispatchEvent","CustomEvent","detail","onLookupOptionsRequest","listener","handler","event","addEventListener","removeEventListener","emitLookupOptionsResponse","response","onLookupOptionsResponse"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GAED,sDAAsD,GA0CtD,OAAO,MAAMA,+BAA+B,qCAAqC;AACjF,OAAO,MAAMC,gCAAgC,sCAAsC;AAEnF,MAAMC,sBAAsB,IAAIC;AAEhC,yEAAyE,GACzE,OAAO,MAAMC,2BAA2B,CAACC;IACrCH,oBAAoBI,aAAa,CAC7B,IAAIC,YAAkCP,8BAA8B;QAAEQ,QAAQH;IAAQ;AAE9F,EAAE;AAEF,4EAA4E,GAC5E,OAAO,MAAMI,yBAAyB,CAACC;IACnC,MAAMC,UAAU,CAACC;QACb,MAAMJ,SAAS,AAACI,MAA4CJ,MAAM;QAClE,IAAI,CAACA,QAAQ;YACT;QACJ;QACAE,SAASF;IACb;IAEAN,oBAAoBW,gBAAgB,CAACb,8BAA8BW;IAEnE,OAAO;QACHT,oBAAoBY,mBAAmB,CAACd,8BAA8BW;IAC1E;AACJ,EAAE;AAEF,iEAAiE,GACjE,OAAO,MAAMI,4BAA4B,CAACC;IACtCd,oBAAoBI,aAAa,CAC7B,IAAIC,YAAmCN,+BAA+B;QAAEO,QAAQQ;IAAS;AAEjG,EAAE;AAEF,6EAA6E,GAC7E,OAAO,MAAMC,0BAA0B,CAACP;IACpC,MAAMC,UAAU,CAACC;QACb,MAAMJ,SAAS,AAACI,MAA6CJ,MAAM;QACnE,IAAI,CAACA,QAAQ;YACT;QACJ;QACAE,SAASF;IACb;IAEAN,oBAAoBW,gBAAgB,CAACZ,+BAA+BU;IAEpE,OAAO;QACHT,oBAAoBY,mBAAmB,CAACb,+BAA+BU;IAC3E;AACJ,EAAE"}
1
+ {"version":3,"file":"lookupOptionsController.js","sourceRoot":"","sources":["../../src/display-conditions/lookupOptionsController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AA4CH,MAAM,CAAC,MAAM,4BAA4B,GAAG,oCAAoC,CAAC;AACjF,MAAM,CAAC,MAAM,6BAA6B,GAAG,qCAAqC,CAAC;AAEnF,MAAM,mBAAmB,GAAG,IAAI,WAAW,EAAE,CAAC;AAE9C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAA6B,EAAE,EAAE;IACtE,mBAAmB,CAAC,aAAa,CAC7B,IAAI,WAAW,CAAuB,4BAA4B,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAC3F,CAAC;AACN,CAAC,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,QAAiD,EAAE,EAAE;IACxF,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAI,KAA2C,CAAC,MAAM,CAAC;QACnE,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO;QACX,CAAC;QACD,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,mBAAmB,CAAC,gBAAgB,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;IAE5E,OAAO,GAAG,EAAE;QACR,mBAAmB,CAAC,mBAAmB,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,QAA+B,EAAE,EAAE;IACzE,mBAAmB,CAAC,aAAa,CAC7B,IAAI,WAAW,CAAwB,6BAA6B,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAC9F,CAAC;AACN,CAAC,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,QAAmD,EAAE,EAAE;IAC3F,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAI,KAA4C,CAAC,MAAM,CAAC;QACpE,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO;QACX,CAAC;QACD,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,mBAAmB,CAAC,gBAAgB,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;IAE7E,OAAO,GAAG,EAAE;QACR,mBAAmB,CAAC,mBAAmB,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC,CAAC;AACN,CAAC,CAAC"}