@plaidev/karte-action-sdk 1.1.81 → 1.1.82

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.
@@ -243,7 +243,7 @@ type OPTIONS = {
243
243
  type CustomVariables = {
244
244
  [key: string]: any;
245
245
  };
246
- type CloseTrigger = "button" | "overlay";
246
+ type CloseTrigger = "button" | "overlay" | "auto" | "none";
247
247
  type ActionEventHandler = (...args: any[]) => any | Promise<any>;
248
248
  declare const ALL_ACTION_ID = "KARTE_ALL_ACTION_ID";
249
249
  declare const actionId: string;
@@ -251,27 +251,50 @@ declare const ACTION_SHOW_EVENT: string;
251
251
  declare const ACTION_CLOSE_EVENT: string;
252
252
  declare const ACTION_DESTROY_EVENT: string;
253
253
  declare const ACTION_CHANGE_STATE_EVENT: string;
254
- // Store to handle current state ID
254
+ /**
255
+ * Store to handle current state ID
256
+ */
255
257
  declare const state: Store<string>;
256
- // Store to handle all state IDs
258
+ /**
259
+ * Store to handle all state IDs
260
+ */
257
261
  declare const states: Store<string[]>;
258
- // Store to handle visibility of action
259
- declare const closed: Store<boolean>;
260
- // Store to handle max z-index for grid items
262
+ /**
263
+ * Store to handle visibility of action
264
+ */
265
+ declare const opened: Store<boolean>;
266
+ /**
267
+ * Store to handle visibility of action
268
+ * @deprecated
269
+ */
270
+ declare const closed: Store<boolean>; // deprecated
271
+ /**
272
+ * Store to handle max z-index for grid items
273
+ */
261
274
  declare const maximumZindex: Store<number>;
262
- // Store to handle internal event handlers
275
+ /**
276
+ * Store to handle internal event handlers
277
+ */
263
278
  declare const internalHandlers: Store<{
264
279
  [key: string]: ActionEventHandler;
265
280
  }>;
266
- // Store to handle custom event handlers
281
+ /**
282
+ * Store to handle custom event handlers
283
+ */
267
284
  declare const customHandlers: Store<{
268
285
  [key: string]: ActionEventHandler;
269
286
  }>;
270
- // Store to handle destruction of action
287
+ /**
288
+ * Store to handle destruction of action
289
+ */
271
290
  declare const destroyed: Store<boolean>;
272
- // Store to handle stop of action
291
+ /**
292
+ * Store to handle stop of action
293
+ */
273
294
  declare const stopped: Store<boolean>;
274
- // Store to handle custom variables
295
+ /**
296
+ * Store to handle custom variables
297
+ */
275
298
  declare const customVariables: Store<{
276
299
  [key: string]: any;
277
300
  }>;
@@ -566,11 +589,11 @@ declare function destroy(): void;
566
589
  /**
567
590
  * Show KARTE action
568
591
  */
569
- declare function show(): void;
592
+ declare function showAction(): void;
570
593
  /**
571
594
  * Close KARTE action
572
595
  */
573
- declare function close(): void;
596
+ declare function closeAction(trigger?: CloseTrigger): void;
574
597
  declare const KARTE_ACTION_ROOT = "karte-action-root";
575
598
  declare const KARTE_ACTION_RID = "karte-action-rid";
576
599
  declare function ensureActionRoot(useShadow?: boolean): ShadowRoot | HTMLElement;
@@ -649,6 +672,8 @@ declare const showModal: typeof create; // @deprecated
649
672
  type ModalOptions<Props, Variables> = ActionOptions<Props, Variables>; // @deprecated
650
673
  declare const KARTE_MODAL_ROOT = "karte-modal-root"; // @deprecated
651
674
  declare const ensureModalRoot: typeof ensureActionRoot; // @deprecated
675
+ declare const show: typeof showAction; // deprecated
676
+ declare const close: typeof closeAction; // deprecated
652
677
  /**
653
678
  * An options for {@link createApp}
654
679
  * @deprecated
@@ -693,7 +718,7 @@ declare const collection: (config: {
693
718
  } | null | undefined, cb: (err: Error | null, items?: any) => void): void;
694
719
  set(key: string, value: string, cb: (err: Error | null) => void): void;
695
720
  };
696
- export { Store, getStoreState, CustomVariables, CloseTrigger, ActionEventHandler, ALL_ACTION_ID, actionId, ACTION_SHOW_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_CHANGE_STATE_EVENT, state, states, closed, maximumZindex, internalHandlers, customHandlers, destroyed, stopped, customVariables, setAutoStart, setState, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, runScript, execOnClickOperation, haveFunction, customAnimation, loadGlobalScript, applyGlobalCss, loadGlobalStyle, hashCode, NOOP, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getTransform, getMarginStyle, ScrollDirection, OnScrollContext, OnScrollFunction, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, Style, StateName, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorStripe, DefaultListSeparator, ListDirection, ListItemSize, DefaultListItemSize, ListContext, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ActionProps, ActionOptions, create, dispatchDestroyEvent, destroy, show, close, KARTE_ACTION_ROOT, KARTE_ACTION_RID, ensureActionRoot, onShow, onClose, onDestroy, onChangeState, h, createFog, EmbedLogic, embed, getActionShadowRoot, applyCss, loadStyle, showModal, ModalOptions, KARTE_MODAL_ROOT, ensureModalRoot, AppOptions, App, createApp, collection };
721
+ export { Store, getStoreState, CustomVariables, CloseTrigger, ActionEventHandler, ALL_ACTION_ID, actionId, ACTION_SHOW_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_CHANGE_STATE_EVENT, state, states, opened, closed, maximumZindex, internalHandlers, customHandlers, destroyed, stopped, customVariables, setAutoStart, setState, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, runScript, execOnClickOperation, haveFunction, customAnimation, loadGlobalScript, applyGlobalCss, loadGlobalStyle, hashCode, NOOP, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getTransform, getMarginStyle, ScrollDirection, OnScrollContext, OnScrollFunction, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, Style, StateName, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorStripe, DefaultListSeparator, ListDirection, ListItemSize, DefaultListItemSize, ListContext, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ActionProps, ActionOptions, create, dispatchDestroyEvent, destroy, showAction, closeAction, KARTE_ACTION_ROOT, KARTE_ACTION_RID, ensureActionRoot, onShow, onClose, onDestroy, onChangeState, h, createFog, EmbedLogic, embed, getActionShadowRoot, applyCss, loadStyle, showModal, ModalOptions, KARTE_MODAL_ROOT, ensureModalRoot, show, close, AppOptions, App, createApp, collection };
697
722
  export { default as State } from './components/State.svelte';
698
723
  export { default as StateItem } from './components/StateItem.svelte';
699
724
  export { default as Modal } from './components/Modal.svelte';
@@ -198,23 +198,46 @@ const ACTION_SHOW_EVENT = `KARTE-ACTION-SHOW-${actionId}`;
198
198
  const ACTION_CLOSE_EVENT = `KARTE-ACTION-CLOSE-${actionId}`;
199
199
  const ACTION_DESTROY_EVENT = `KARTE-ACTION-DESTROY-${actionId}`;
200
200
  const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
201
- // Store to handle current state ID
201
+ /**
202
+ * Store to handle current state ID
203
+ */
202
204
  const state = writable('/');
203
- // Store to handle all state IDs
205
+ /**
206
+ * Store to handle all state IDs
207
+ */
204
208
  const states = writable([]);
205
- // Store to handle visibility of action
206
- const closed = writable(false);
207
- // Store to handle max z-index for grid items
209
+ /**
210
+ * Store to handle visibility of action
211
+ */
212
+ const opened = writable(true);
213
+ /**
214
+ * Store to handle visibility of action
215
+ * @deprecated
216
+ */
217
+ const closed = writable(false); // deprecated
218
+ /**
219
+ * Store to handle max z-index for grid items
220
+ */
208
221
  const maximumZindex = writable(0);
209
- // Store to handle internal event handlers
222
+ /**
223
+ * Store to handle internal event handlers
224
+ */
210
225
  const internalHandlers = writable({});
211
- // Store to handle custom event handlers
226
+ /**
227
+ * Store to handle custom event handlers
228
+ */
212
229
  const customHandlers = writable({});
213
- // Store to handle destruction of action
230
+ /**
231
+ * Store to handle destruction of action
232
+ */
214
233
  const destroyed = writable(false);
215
- // Store to handle stop of action
234
+ /**
235
+ * Store to handle stop of action
236
+ */
216
237
  const stopped = writable(false);
217
- // Store to handle custom variables
238
+ /**
239
+ * Store to handle custom variables
240
+ */
218
241
  const customVariables = writable({});
219
242
  /**
220
243
  * {@link setAutoStart} function to set auto start flag.
@@ -233,7 +256,8 @@ const initialize = (options) => {
233
256
  if (options?.initialState) {
234
257
  state.set(options?.initialState);
235
258
  }
236
- closed.set(false);
259
+ opened.set(true);
260
+ closed.set(false); // deprecated
237
261
  functionOptions.set(options ?? {});
238
262
  return () => finalize();
239
263
  };
@@ -268,9 +292,7 @@ const linkTo = (to, targetBlank = true) => () => {
268
292
  }
269
293
  };
270
294
  const closeApp = (trigger) => () => {
271
- send_event('message_close', { trigger, state: getStoreState(state) });
272
295
  window.dispatchEvent(new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } }));
273
- closed.set(true);
274
296
  };
275
297
  const runScript = (handlerName) => () => {
276
298
  const handlers = getStoreState(customHandlers);
@@ -592,29 +614,35 @@ function create(App, options = {
592
614
  }) {
593
615
  let app = null;
594
616
  const data = { ...options.props, ...options.variables };
595
- const close = (event = {}) => {
617
+ const close = (trigger = 'none') => {
596
618
  if (!app) {
597
619
  return;
598
620
  }
599
- closed.set(true);
621
+ options.send('message_close', { trigger, state: getStoreState(state) });
622
+ opened.set(false);
623
+ closed.set(true); // deprecated
600
624
  window.removeEventListener(ACTION_CHANGE_STATE_EVENT, setState);
601
- const trigger = event.detail?.trigger ? event.detail?.trigger : 'button';
602
625
  if (options.onClose) {
603
626
  options.onClose({ send: options.send, data: { ...data, ...getStoreState(customVariables) } }, trigger);
604
627
  }
605
628
  app.$destroy();
606
629
  app = null;
607
630
  };
608
- window.addEventListener(ACTION_CLOSE_EVENT, close);
609
- const show = (_event = {}) => {
631
+ const handleClose = (event) => {
632
+ const trigger = event.detail?.trigger ? event.detail?.trigger : 'none';
633
+ close(trigger);
634
+ };
635
+ window.addEventListener(ACTION_CLOSE_EVENT, handleClose);
636
+ const show = () => {
610
637
  if (app) {
611
638
  return;
612
639
  }
613
640
  options.send('message_open', { state: getStoreState(state) });
614
- closed.set(false);
641
+ opened.set(true);
642
+ closed.set(false); // deprecated
615
643
  window.addEventListener(ACTION_CHANGE_STATE_EVENT, setState);
616
644
  app = new App({
617
- target: ensureModalRoot(!true),
645
+ target: ensureActionRoot(!true),
618
646
  hydrate: true,
619
647
  props: {
620
648
  send: options.send,
@@ -658,7 +686,7 @@ function create(App, options = {
658
686
  hideCleanup();
659
687
  showCleanup();
660
688
  window.removeEventListener(ACTION_SHOW_EVENT, show);
661
- window.removeEventListener(ACTION_CLOSE_EVENT, close);
689
+ window.removeEventListener(ACTION_CLOSE_EVENT, handleClose);
662
690
  };
663
691
  }
664
692
  /**
@@ -678,15 +706,15 @@ function destroy() {
678
706
  /**
679
707
  * Show KARTE action
680
708
  */
681
- function show() {
709
+ function showAction() {
682
710
  const event = new CustomEvent(ACTION_SHOW_EVENT);
683
711
  window.dispatchEvent(event);
684
712
  }
685
713
  /**
686
714
  * Close KARTE action
687
715
  */
688
- function close() {
689
- const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger: 'button' } });
716
+ function closeAction(trigger = 'none') {
717
+ const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } });
690
718
  window.dispatchEvent(event);
691
719
  }
692
720
  const KARTE_ACTION_ROOT = 'karte-action-root';
@@ -883,6 +911,8 @@ async function loadStyle(href) {
883
911
  const showModal = create; // @deprecated
884
912
  const KARTE_MODAL_ROOT = 'karte-modal-root'; // @deprecated
885
913
  const ensureModalRoot = ensureActionRoot; // @deprecated
914
+ const show = showAction; // deprecated
915
+ const close = closeAction; // deprecated
886
916
  /**
887
917
  * Create an application instance
888
918
  * @deprecated
@@ -3984,4 +4014,4 @@ class ImageBlock extends SvelteComponent {
3984
4014
  }
3985
4015
  }
3986
4016
 
3987
- export { ACTION_CHANGE_STATE_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, ALL_ACTION_ID, Alignments, AnimationStyles, BackgroundSizes, Cursors, DefaultListItemSize, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorNone, DefaultListSeparatorStripe, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_ACTION_ROOT, KARTE_MODAL_ROOT, LengthUnits, List, ListItem, MediaQueries, Modal, ModalPositions, NOOP, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, applyCss, applyGlobalCss, close, closeApp, closed, collection, create, createApp, createFog, customAnimation, customHandlers, customVariables, destroy, destroyed, dispatchDestroyEvent, embed, ensureActionRoot, ensureModalRoot, execOnClickOperation, finalize, getActionShadowRoot, getMarginStyle, getPositionStyle, getStoreState, getTransform, h, handleFocus, handleKeydown, hasSuffix, hashCode, haveFunction, hideOnScroll, hideOnTime, initialize, internalHandlers, isPreview, linkTo, loadGlobalScript, loadGlobalStyle, loadStyle, maximumZindex, moveTo, none, onChangeState, onClose, onDestroy, onScroll, onShow, onTime, randStr, runScript, send_event, setAutoStart, setMiximumZindex, setPreviousFocus, setState, show, showModal, showOnScroll, showOnTime, state, states, stopped, toBr };
4017
+ export { ACTION_CHANGE_STATE_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, ALL_ACTION_ID, Alignments, AnimationStyles, BackgroundSizes, Cursors, DefaultListItemSize, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorNone, DefaultListSeparatorStripe, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_ACTION_ROOT, KARTE_MODAL_ROOT, LengthUnits, List, ListItem, MediaQueries, Modal, ModalPositions, NOOP, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, applyCss, applyGlobalCss, close, closeAction, closeApp, closed, collection, create, createApp, createFog, customAnimation, customHandlers, customVariables, destroy, destroyed, dispatchDestroyEvent, embed, ensureActionRoot, ensureModalRoot, execOnClickOperation, finalize, getActionShadowRoot, getMarginStyle, getPositionStyle, getStoreState, getTransform, h, handleFocus, handleKeydown, hasSuffix, hashCode, haveFunction, hideOnScroll, hideOnTime, initialize, internalHandlers, isPreview, linkTo, loadGlobalScript, loadGlobalStyle, loadStyle, maximumZindex, moveTo, none, onChangeState, onClose, onDestroy, onScroll, onShow, onTime, opened, randStr, runScript, send_event, setAutoStart, setMiximumZindex, setPreviousFocus, setState, show, showAction, showModal, showOnScroll, showOnTime, state, states, stopped, toBr };
@@ -243,7 +243,7 @@ type OPTIONS = {
243
243
  type CustomVariables = {
244
244
  [key: string]: any;
245
245
  };
246
- type CloseTrigger = "button" | "overlay";
246
+ type CloseTrigger = "button" | "overlay" | "auto" | "none";
247
247
  type ActionEventHandler = (...args: any[]) => any | Promise<any>;
248
248
  declare const ALL_ACTION_ID = "KARTE_ALL_ACTION_ID";
249
249
  declare const actionId: string;
@@ -251,27 +251,50 @@ declare const ACTION_SHOW_EVENT: string;
251
251
  declare const ACTION_CLOSE_EVENT: string;
252
252
  declare const ACTION_DESTROY_EVENT: string;
253
253
  declare const ACTION_CHANGE_STATE_EVENT: string;
254
- // Store to handle current state ID
254
+ /**
255
+ * Store to handle current state ID
256
+ */
255
257
  declare const state: Store<string>;
256
- // Store to handle all state IDs
258
+ /**
259
+ * Store to handle all state IDs
260
+ */
257
261
  declare const states: Store<string[]>;
258
- // Store to handle visibility of action
259
- declare const closed: Store<boolean>;
260
- // Store to handle max z-index for grid items
262
+ /**
263
+ * Store to handle visibility of action
264
+ */
265
+ declare const opened: Store<boolean>;
266
+ /**
267
+ * Store to handle visibility of action
268
+ * @deprecated
269
+ */
270
+ declare const closed: Store<boolean>; // deprecated
271
+ /**
272
+ * Store to handle max z-index for grid items
273
+ */
261
274
  declare const maximumZindex: Store<number>;
262
- // Store to handle internal event handlers
275
+ /**
276
+ * Store to handle internal event handlers
277
+ */
263
278
  declare const internalHandlers: Store<{
264
279
  [key: string]: ActionEventHandler;
265
280
  }>;
266
- // Store to handle custom event handlers
281
+ /**
282
+ * Store to handle custom event handlers
283
+ */
267
284
  declare const customHandlers: Store<{
268
285
  [key: string]: ActionEventHandler;
269
286
  }>;
270
- // Store to handle destruction of action
287
+ /**
288
+ * Store to handle destruction of action
289
+ */
271
290
  declare const destroyed: Store<boolean>;
272
- // Store to handle stop of action
291
+ /**
292
+ * Store to handle stop of action
293
+ */
273
294
  declare const stopped: Store<boolean>;
274
- // Store to handle custom variables
295
+ /**
296
+ * Store to handle custom variables
297
+ */
275
298
  declare const customVariables: Store<{
276
299
  [key: string]: any;
277
300
  }>;
@@ -566,11 +589,11 @@ declare function destroy(): void;
566
589
  /**
567
590
  * Show KARTE action
568
591
  */
569
- declare function show(): void;
592
+ declare function showAction(): void;
570
593
  /**
571
594
  * Close KARTE action
572
595
  */
573
- declare function close(): void;
596
+ declare function closeAction(trigger?: CloseTrigger): void;
574
597
  declare const KARTE_ACTION_ROOT = "karte-action-root";
575
598
  declare const KARTE_ACTION_RID = "karte-action-rid";
576
599
  declare function ensureActionRoot(useShadow?: boolean): ShadowRoot | HTMLElement;
@@ -649,6 +672,8 @@ declare const showModal: typeof create; // @deprecated
649
672
  type ModalOptions<Props, Variables> = ActionOptions<Props, Variables>; // @deprecated
650
673
  declare const KARTE_MODAL_ROOT = "karte-modal-root"; // @deprecated
651
674
  declare const ensureModalRoot: typeof ensureActionRoot; // @deprecated
675
+ declare const show: typeof showAction; // deprecated
676
+ declare const close: typeof closeAction; // deprecated
652
677
  /**
653
678
  * An options for {@link createApp}
654
679
  * @deprecated
@@ -693,7 +718,7 @@ declare const collection: (config: {
693
718
  } | null | undefined, cb: (err: Error | null, items?: any) => void): void;
694
719
  set(key: string, value: string, cb: (err: Error | null) => void): void;
695
720
  };
696
- export { Store, getStoreState, CustomVariables, CloseTrigger, ActionEventHandler, ALL_ACTION_ID, actionId, ACTION_SHOW_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_CHANGE_STATE_EVENT, state, states, closed, maximumZindex, internalHandlers, customHandlers, destroyed, stopped, customVariables, setAutoStart, setState, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, runScript, execOnClickOperation, haveFunction, customAnimation, loadGlobalScript, applyGlobalCss, loadGlobalStyle, hashCode, NOOP, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getTransform, getMarginStyle, ScrollDirection, OnScrollContext, OnScrollFunction, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, Style, StateName, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorStripe, DefaultListSeparator, ListDirection, ListItemSize, DefaultListItemSize, ListContext, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ActionProps, ActionOptions, create, dispatchDestroyEvent, destroy, show, close, KARTE_ACTION_ROOT, KARTE_ACTION_RID, ensureActionRoot, onShow, onClose, onDestroy, onChangeState, h, createFog, EmbedLogic, embed, getActionShadowRoot, applyCss, loadStyle, showModal, ModalOptions, KARTE_MODAL_ROOT, ensureModalRoot, AppOptions, App, createApp, collection };
721
+ export { Store, getStoreState, CustomVariables, CloseTrigger, ActionEventHandler, ALL_ACTION_ID, actionId, ACTION_SHOW_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_CHANGE_STATE_EVENT, state, states, opened, closed, maximumZindex, internalHandlers, customHandlers, destroyed, stopped, customVariables, setAutoStart, setState, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, runScript, execOnClickOperation, haveFunction, customAnimation, loadGlobalScript, applyGlobalCss, loadGlobalStyle, hashCode, NOOP, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getTransform, getMarginStyle, ScrollDirection, OnScrollContext, OnScrollFunction, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, Style, StateName, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorStripe, DefaultListSeparator, ListDirection, ListItemSize, DefaultListItemSize, ListContext, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ActionProps, ActionOptions, create, dispatchDestroyEvent, destroy, showAction, closeAction, KARTE_ACTION_ROOT, KARTE_ACTION_RID, ensureActionRoot, onShow, onClose, onDestroy, onChangeState, h, createFog, EmbedLogic, embed, getActionShadowRoot, applyCss, loadStyle, showModal, ModalOptions, KARTE_MODAL_ROOT, ensureModalRoot, show, close, AppOptions, App, createApp, collection };
697
722
  export { default as State } from './components/State.svelte';
698
723
  export { default as StateItem } from './components/StateItem.svelte';
699
724
  export { default as Modal } from './components/Modal.svelte';
package/dist/index.es.js CHANGED
@@ -198,23 +198,46 @@ const ACTION_SHOW_EVENT = `KARTE-ACTION-SHOW-${actionId}`;
198
198
  const ACTION_CLOSE_EVENT = `KARTE-ACTION-CLOSE-${actionId}`;
199
199
  const ACTION_DESTROY_EVENT = `KARTE-ACTION-DESTROY-${actionId}`;
200
200
  const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
201
- // Store to handle current state ID
201
+ /**
202
+ * Store to handle current state ID
203
+ */
202
204
  const state = writable('/');
203
- // Store to handle all state IDs
205
+ /**
206
+ * Store to handle all state IDs
207
+ */
204
208
  const states = writable([]);
205
- // Store to handle visibility of action
206
- const closed = writable(false);
207
- // Store to handle max z-index for grid items
209
+ /**
210
+ * Store to handle visibility of action
211
+ */
212
+ const opened = writable(true);
213
+ /**
214
+ * Store to handle visibility of action
215
+ * @deprecated
216
+ */
217
+ const closed = writable(false); // deprecated
218
+ /**
219
+ * Store to handle max z-index for grid items
220
+ */
208
221
  const maximumZindex = writable(0);
209
- // Store to handle internal event handlers
222
+ /**
223
+ * Store to handle internal event handlers
224
+ */
210
225
  const internalHandlers = writable({});
211
- // Store to handle custom event handlers
226
+ /**
227
+ * Store to handle custom event handlers
228
+ */
212
229
  const customHandlers = writable({});
213
- // Store to handle destruction of action
230
+ /**
231
+ * Store to handle destruction of action
232
+ */
214
233
  const destroyed = writable(false);
215
- // Store to handle stop of action
234
+ /**
235
+ * Store to handle stop of action
236
+ */
216
237
  const stopped = writable(false);
217
- // Store to handle custom variables
238
+ /**
239
+ * Store to handle custom variables
240
+ */
218
241
  const customVariables = writable({});
219
242
  /**
220
243
  * {@link setAutoStart} function to set auto start flag.
@@ -233,7 +256,8 @@ const initialize = (options) => {
233
256
  if (options?.initialState) {
234
257
  state.set(options?.initialState);
235
258
  }
236
- closed.set(false);
259
+ opened.set(true);
260
+ closed.set(false); // deprecated
237
261
  functionOptions.set(options ?? {});
238
262
  return () => finalize();
239
263
  };
@@ -268,9 +292,7 @@ const linkTo = (to, targetBlank = true) => () => {
268
292
  }
269
293
  };
270
294
  const closeApp = (trigger) => () => {
271
- send_event('message_close', { trigger, state: getStoreState(state) });
272
295
  window.dispatchEvent(new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } }));
273
- closed.set(true);
274
296
  };
275
297
  const runScript = (handlerName) => () => {
276
298
  const handlers = getStoreState(customHandlers);
@@ -694,29 +716,35 @@ function create(App, options = {
694
716
  }) {
695
717
  let app = null;
696
718
  const data = { ...options.props, ...options.variables };
697
- const close = (event = {}) => {
719
+ const close = (trigger = 'none') => {
698
720
  if (!app) {
699
721
  return;
700
722
  }
701
- closed.set(true);
723
+ options.send('message_close', { trigger, state: getStoreState(state) });
724
+ opened.set(false);
725
+ closed.set(true); // deprecated
702
726
  window.removeEventListener(ACTION_CHANGE_STATE_EVENT, setState);
703
- const trigger = event.detail?.trigger ? event.detail?.trigger : 'button';
704
727
  if (options.onClose) {
705
728
  options.onClose({ send: options.send, data: { ...data, ...getStoreState(customVariables) } }, trigger);
706
729
  }
707
730
  app.$destroy();
708
731
  app = null;
709
732
  };
710
- window.addEventListener(ACTION_CLOSE_EVENT, close);
711
- const show = (_event = {}) => {
733
+ const handleClose = (event) => {
734
+ const trigger = event.detail?.trigger ? event.detail?.trigger : 'none';
735
+ close(trigger);
736
+ };
737
+ window.addEventListener(ACTION_CLOSE_EVENT, handleClose);
738
+ const show = () => {
712
739
  if (app) {
713
740
  return;
714
741
  }
715
742
  options.send('message_open', { state: getStoreState(state) });
716
- closed.set(false);
743
+ opened.set(true);
744
+ closed.set(false); // deprecated
717
745
  window.addEventListener(ACTION_CHANGE_STATE_EVENT, setState);
718
746
  app = new App({
719
- target: ensureModalRoot(!false),
747
+ target: ensureActionRoot(!false),
720
748
  hydrate: false,
721
749
  props: {
722
750
  send: options.send,
@@ -728,6 +756,9 @@ function create(App, options = {
728
756
  });
729
757
  };
730
758
  window.addEventListener(ACTION_SHOW_EVENT, show);
759
+ const autoClose = () => {
760
+ return close('auto');
761
+ };
731
762
  const _show = () => {
732
763
  show();
733
764
  return close;
@@ -738,16 +769,16 @@ function create(App, options = {
738
769
  const curried = fn => hideOnScroll(options.props, fn, show);
739
770
  // if in hydrate mode (preview), nothing is done, since action will be disposed and closed in the preview module
740
771
  if (options.props.hide_and_condition) {
741
- cleanup = and(close, curried, currying(hideOnTime, options)) || NOOP;
772
+ cleanup = and(autoClose, curried, currying(hideOnTime, options)) || NOOP;
742
773
  }
743
774
  else {
744
- cleanup = or(close, curried, currying(hideOnTime, options)) || NOOP;
775
+ cleanup = or(autoClose, curried, currying(hideOnTime, options)) || NOOP;
745
776
  }
746
777
  return cleanup;
747
778
  };
748
779
  const startShow = () => {
749
780
  let cleanup;
750
- const curried = fn => showOnScroll(options.props, fn, close);
781
+ const curried = fn => showOnScroll(options.props, fn, autoClose);
751
782
  // if in hydrate mode (preview), always show action
752
783
  if (options.props.show_and_condition) {
753
784
  cleanup = and(show, curried, currying(showOnTime, options)) || _show();
@@ -769,7 +800,7 @@ function create(App, options = {
769
800
  hideCleanup();
770
801
  showCleanup();
771
802
  window.removeEventListener(ACTION_SHOW_EVENT, show);
772
- window.removeEventListener(ACTION_CLOSE_EVENT, close);
803
+ window.removeEventListener(ACTION_CLOSE_EVENT, handleClose);
773
804
  };
774
805
  }
775
806
  /**
@@ -789,15 +820,15 @@ function destroy() {
789
820
  /**
790
821
  * Show KARTE action
791
822
  */
792
- function show() {
823
+ function showAction() {
793
824
  const event = new CustomEvent(ACTION_SHOW_EVENT);
794
825
  window.dispatchEvent(event);
795
826
  }
796
827
  /**
797
828
  * Close KARTE action
798
829
  */
799
- function close() {
800
- const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger: 'button' } });
830
+ function closeAction(trigger = 'none') {
831
+ const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } });
801
832
  window.dispatchEvent(event);
802
833
  }
803
834
  const KARTE_ACTION_ROOT = 'karte-action-root';
@@ -994,6 +1025,8 @@ async function loadStyle(href) {
994
1025
  const showModal = create; // @deprecated
995
1026
  const KARTE_MODAL_ROOT = 'karte-modal-root'; // @deprecated
996
1027
  const ensureModalRoot = ensureActionRoot; // @deprecated
1028
+ const show = showAction; // deprecated
1029
+ const close = closeAction; // deprecated
997
1030
  /**
998
1031
  * Create an application instance
999
1032
  * @deprecated
@@ -3819,4 +3852,4 @@ class ImageBlock extends SvelteComponent {
3819
3852
  }
3820
3853
  }
3821
3854
 
3822
- export { ACTION_CHANGE_STATE_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, ALL_ACTION_ID, Alignments, AnimationStyles, BackgroundSizes, Cursors, DefaultListItemSize, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorNone, DefaultListSeparatorStripe, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_ACTION_ROOT, KARTE_MODAL_ROOT, LengthUnits, List, ListItem, MediaQueries, Modal, ModalPositions, NOOP, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, applyCss, applyGlobalCss, close, closeApp, closed, collection, create, createApp, createFog, customAnimation, customHandlers, customVariables, destroy, destroyed, dispatchDestroyEvent, embed, ensureActionRoot, ensureModalRoot, execOnClickOperation, finalize, getActionShadowRoot, getMarginStyle, getPositionStyle, getStoreState, getTransform, h, handleFocus, handleKeydown, hasSuffix, hashCode, haveFunction, hideOnScroll, hideOnTime, initialize, internalHandlers, isPreview, linkTo, loadGlobalScript, loadGlobalStyle, loadStyle, maximumZindex, moveTo, none, onChangeState, onClose, onDestroy, onScroll, onShow, onTime, randStr, runScript, send_event, setAutoStart, setMiximumZindex, setPreviousFocus, setState, show, showModal, showOnScroll, showOnTime, state, states, stopped, toBr };
3855
+ export { ACTION_CHANGE_STATE_EVENT, ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, ALL_ACTION_ID, Alignments, AnimationStyles, BackgroundSizes, Cursors, DefaultListItemSize, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorNone, DefaultListSeparatorStripe, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_ACTION_ROOT, KARTE_MODAL_ROOT, LengthUnits, List, ListItem, MediaQueries, Modal, ModalPositions, NOOP, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, applyCss, applyGlobalCss, close, closeAction, closeApp, closed, collection, create, createApp, createFog, customAnimation, customHandlers, customVariables, destroy, destroyed, dispatchDestroyEvent, embed, ensureActionRoot, ensureModalRoot, execOnClickOperation, finalize, getActionShadowRoot, getMarginStyle, getPositionStyle, getStoreState, getTransform, h, handleFocus, handleKeydown, hasSuffix, hashCode, haveFunction, hideOnScroll, hideOnTime, initialize, internalHandlers, isPreview, linkTo, loadGlobalScript, loadGlobalStyle, loadStyle, maximumZindex, moveTo, none, onChangeState, onClose, onDestroy, onScroll, onShow, onTime, opened, randStr, runScript, send_event, setAutoStart, setMiximumZindex, setPreviousFocus, setState, show, showAction, showModal, showOnScroll, showOnTime, state, states, stopped, toBr };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.81",
3
+ "version": "1.1.82",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",