@plaidev/karte-action-sdk 1.1.57 → 1.1.58

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,4 +1,5 @@
1
1
  import { Writable } from "svelte/store";
2
+ import { SvelteComponentDev } from "svelte/internal";
2
3
  declare const PropTypes: readonly [
3
4
  "BooleanKeyword",
4
5
  "NumberKeyword",
@@ -338,6 +339,52 @@ declare function showOnTime<Props extends {
338
339
  show_on_time: boolean;
339
340
  show_on_time_count: number;
340
341
  }>(props: Props, fn?: Function): () => void;
342
+ /**
343
+ * An options for {@link createApp}
344
+ */
345
+ interface AppOptions<Props, Variables> {
346
+ /**
347
+ * {@link Send} function to receive events triggered in Karte action.
348
+ *
349
+ * @default () => {}
350
+ */
351
+ send?: Function;
352
+ /**
353
+ * {@link Props} used in Karte action.
354
+ *
355
+ * @default {}
356
+ */
357
+ props?: Props;
358
+ /**
359
+ * {@link Variables} in which user variables or action table used in Karte action.
360
+ *
361
+ * @default {}
362
+ */
363
+ variables?: Variables;
364
+ }
365
+ /**
366
+ * App application instance that is with {@link createApp}
367
+ *
368
+ * @description Currently, svelte component is supported only.
369
+ */
370
+ interface App {
371
+ /**
372
+ * The method to destroy an app instance.
373
+ */
374
+ close: () => void;
375
+ /**
376
+ * The method to show an app instance.
377
+ */
378
+ show: () => void;
379
+ }
380
+ /**
381
+ * Create an application instance.
382
+ *
383
+ * @param App - An entry point of svelte component.
384
+ * @param options - An {@link AppOptions | options}
385
+ * @return An {@link App | app} instance
386
+ */
387
+ declare const createApp: <Props, Variables>(App: typeof SvelteComponentDev, options?: AppOptions<Props, Variables>) => App;
341
388
  declare function ensureModalRoot(useShadow?: boolean): ShadowRoot | HTMLElement;
342
389
  declare const h: (type: string, props: any, ...children: Array<any>) => HTMLElement;
343
390
  declare function createFog({ color, opacity, zIndex, onclick }: {
@@ -364,7 +411,7 @@ declare const collection: (config: {
364
411
  } | null | undefined, cb: (err: Error | null, items?: any) => void): void;
365
412
  set(key: string, value: string, cb: (err: Error | null) => void): void;
366
413
  };
367
- export { state, closed, maximumZindex, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, execOnClickOperation, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getMarginStyle, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, AnimationStyleTranslations, ModalPositions, ModalPosition, ModalPositionTranslations, ModalMarginTranslations, ModalMargin, ModalPlacement, DefaultModalPlacement, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ensureModalRoot, h, createFog, EmbedLogic, embed, collection };
414
+ export { state, closed, maximumZindex, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, execOnClickOperation, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getMarginStyle, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, AnimationStyleTranslations, ModalPositions, ModalPosition, ModalPositionTranslations, ModalMarginTranslations, ModalMargin, ModalPlacement, DefaultModalPlacement, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, AppOptions, App, createApp, ensureModalRoot, h, createFog, EmbedLogic, embed, collection };
368
415
  export { default as State } from './components/State.svelte';
369
416
  export { default as StateItem } from './components/StateItem.svelte';
370
417
  export { default as Modal } from './components/Modal.svelte';
@@ -366,6 +366,51 @@ function showOnTime(props, fn) {
366
366
  : NOOP;
367
367
  }
368
368
 
369
+ /**
370
+ * Create an application instance.
371
+ *
372
+ * @param App - An entry point of svelte component.
373
+ * @param options - An {@link AppOptions | options}
374
+ * @return An {@link App | app} instance
375
+ */
376
+ const createApp = (App, options = {
377
+ send: () => { },
378
+ props: {},
379
+ variables: {},
380
+ }) => {
381
+ let app = null;
382
+ const close = () => {
383
+ if (app) {
384
+ app.$destory();
385
+ app = null;
386
+ }
387
+ };
388
+ const appArgs = {
389
+ target: null,
390
+ props: {
391
+ send: options.send,
392
+ close,
393
+ data: {
394
+ ...options.props,
395
+ ...options.variables,
396
+ },
397
+ },
398
+ };
399
+ {
400
+ const win = ensureModalRoot(false);
401
+ appArgs.target = win;
402
+ appArgs.hydrate = true;
403
+ }
404
+ return {
405
+ close,
406
+ show: () => {
407
+ if (app) {
408
+ return;
409
+ }
410
+ app = new App(appArgs);
411
+ },
412
+ };
413
+ };
369
414
  const KARTE_MODAL_ROOT = 'karte-modal-root';
370
415
  function ensureModalRoot(useShadow = true) {
371
416
  let el = document.getElementById(KARTE_MODAL_ROOT);
@@ -2535,4 +2580,4 @@ class ImageBlock extends SvelteComponent {
2535
2580
  }
2536
2581
  }
2537
2582
 
2538
- export { Alignments, AnimationStyleTranslations, AnimationStyles, BackgroundSizes, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, Justifies, LengthUnits, MediaQueries, Modal, ModalMarginTranslations, ModalPositionTranslations, ModalPositions, ObjectFits, OnClickOperationOptions, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, closeApp, closed, collection, createFog, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, h, handleFocus, handleKeydown, hasSuffix, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, showOnScroll, showOnTime, state, toBr };
2583
+ export { Alignments, AnimationStyleTranslations, AnimationStyles, BackgroundSizes, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, Justifies, LengthUnits, MediaQueries, Modal, ModalMarginTranslations, ModalPositionTranslations, ModalPositions, ObjectFits, OnClickOperationOptions, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, closeApp, closed, collection, createApp, createFog, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, h, handleFocus, handleKeydown, hasSuffix, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, showOnScroll, showOnTime, state, toBr };
@@ -1,4 +1,5 @@
1
1
  import { Writable } from "svelte/store";
2
+ import { SvelteComponentDev } from "svelte/internal";
2
3
  declare const PropTypes: readonly [
3
4
  "BooleanKeyword",
4
5
  "NumberKeyword",
@@ -338,6 +339,52 @@ declare function showOnTime<Props extends {
338
339
  show_on_time: boolean;
339
340
  show_on_time_count: number;
340
341
  }>(props: Props, fn?: Function): () => void;
342
+ /**
343
+ * An options for {@link createApp}
344
+ */
345
+ interface AppOptions<Props, Variables> {
346
+ /**
347
+ * {@link Send} function to receive events triggered in Karte action.
348
+ *
349
+ * @default () => {}
350
+ */
351
+ send?: Function;
352
+ /**
353
+ * {@link Props} used in Karte action.
354
+ *
355
+ * @default {}
356
+ */
357
+ props?: Props;
358
+ /**
359
+ * {@link Variables} in which user variables or action table used in Karte action.
360
+ *
361
+ * @default {}
362
+ */
363
+ variables?: Variables;
364
+ }
365
+ /**
366
+ * App application instance that is with {@link createApp}
367
+ *
368
+ * @description Currently, svelte component is supported only.
369
+ */
370
+ interface App {
371
+ /**
372
+ * The method to destroy an app instance.
373
+ */
374
+ close: () => void;
375
+ /**
376
+ * The method to show an app instance.
377
+ */
378
+ show: () => void;
379
+ }
380
+ /**
381
+ * Create an application instance.
382
+ *
383
+ * @param App - An entry point of svelte component.
384
+ * @param options - An {@link AppOptions | options}
385
+ * @return An {@link App | app} instance
386
+ */
387
+ declare const createApp: <Props, Variables>(App: typeof SvelteComponentDev, options?: AppOptions<Props, Variables>) => App;
341
388
  declare function ensureModalRoot(useShadow?: boolean): ShadowRoot | HTMLElement;
342
389
  declare const h: (type: string, props: any, ...children: Array<any>) => HTMLElement;
343
390
  declare function createFog({ color, opacity, zIndex, onclick }: {
@@ -364,7 +411,7 @@ declare const collection: (config: {
364
411
  } | null | undefined, cb: (err: Error | null, items?: any) => void): void;
365
412
  set(key: string, value: string, cb: (err: Error | null) => void): void;
366
413
  };
367
- export { state, closed, maximumZindex, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, execOnClickOperation, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getMarginStyle, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, AnimationStyleTranslations, ModalPositions, ModalPosition, ModalPositionTranslations, ModalMarginTranslations, ModalMargin, ModalPlacement, DefaultModalPlacement, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ensureModalRoot, h, createFog, EmbedLogic, embed, collection };
414
+ export { state, closed, maximumZindex, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, execOnClickOperation, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getMarginStyle, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, AnimationStyleTranslations, ModalPositions, ModalPosition, ModalPositionTranslations, ModalMarginTranslations, ModalMargin, ModalPlacement, DefaultModalPlacement, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, AppOptions, App, createApp, ensureModalRoot, h, createFog, EmbedLogic, embed, collection };
368
415
  export { default as State } from './components/State.svelte';
369
416
  export { default as StateItem } from './components/StateItem.svelte';
370
417
  export { default as Modal } from './components/Modal.svelte';
package/dist/index.es.js CHANGED
@@ -366,6 +366,50 @@ function showOnTime(props, fn) {
366
366
  : NOOP;
367
367
  }
368
368
 
369
+ /**
370
+ * Create an application instance.
371
+ *
372
+ * @param App - An entry point of svelte component.
373
+ * @param options - An {@link AppOptions | options}
374
+ * @return An {@link App | app} instance
375
+ */
376
+ const createApp = (App, options = {
377
+ send: () => { },
378
+ props: {},
379
+ variables: {},
380
+ }) => {
381
+ let app = null;
382
+ const close = () => {
383
+ if (app) {
384
+ app.$destory();
385
+ app = null;
386
+ }
387
+ };
388
+ const appArgs = {
389
+ target: null,
390
+ props: {
391
+ send: options.send,
392
+ close,
393
+ data: {
394
+ ...options.props,
395
+ ...options.variables,
396
+ },
397
+ },
398
+ };
399
+ {
400
+ const win = ensureModalRoot(true);
401
+ appArgs.target = win;
402
+ }
403
+ return {
404
+ close,
405
+ show: () => {
406
+ if (app) {
407
+ return;
408
+ }
409
+ app = new App(appArgs);
410
+ },
411
+ };
412
+ };
369
413
  const KARTE_MODAL_ROOT = 'karte-modal-root';
370
414
  function ensureModalRoot(useShadow = true) {
371
415
  let el = document.getElementById(KARTE_MODAL_ROOT);
@@ -2351,4 +2395,4 @@ class ImageBlock extends SvelteComponent {
2351
2395
  }
2352
2396
  }
2353
2397
 
2354
- export { Alignments, AnimationStyleTranslations, AnimationStyles, BackgroundSizes, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, Justifies, LengthUnits, MediaQueries, Modal, ModalMarginTranslations, ModalPositionTranslations, ModalPositions, ObjectFits, OnClickOperationOptions, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, closeApp, closed, collection, createFog, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, h, handleFocus, handleKeydown, hasSuffix, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, showOnScroll, showOnTime, state, toBr };
2398
+ export { Alignments, AnimationStyleTranslations, AnimationStyles, BackgroundSizes, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, Justifies, LengthUnits, MediaQueries, Modal, ModalMarginTranslations, ModalPositionTranslations, ModalPositions, ObjectFits, OnClickOperationOptions, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, closeApp, closed, collection, createApp, createFog, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, h, handleFocus, handleKeydown, hasSuffix, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, showOnScroll, showOnTime, state, toBr };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.57",
3
+ "version": "1.1.58",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",
@@ -67,6 +67,7 @@
67
67
  },
68
68
  "scripts": {
69
69
  "dev": "jiti ./scripts/preview.ts",
70
+ "dev:hydrate": "jiti ./scripts/preview.ts --hydrate",
70
71
  "setup:default": "jiti ./scripts/default.ts",
71
72
  "setup:template": "jiti ./scripts/template.ts",
72
73
  "setup:concat": "jiti ./scripts/concat.ts",