@plaidev/karte-action-sdk 1.1.267 → 1.1.268

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,7 +1,7 @@
1
1
  import { writable, get } from 'svelte/store';
2
2
  import { onMount as onMount$1, onDestroy as onDestroy$1, beforeUpdate as beforeUpdate$1, afterUpdate as afterUpdate$1, tick as tick$1, getContext, setContext, createEventDispatcher } from 'svelte';
3
3
  import { SvelteComponent, init, safe_not_equal, empty, head_selector, detach, append_hydration, noop, component_subscribe, element, claim_element, attr, insert_hydration, create_slot, create_component, space, claim_component, claim_space, mount_component, update_slot_base, get_all_dirty_from_scope, get_slot_changes, transition_in, transition_out, destroy_component, append_styles, group_outros, check_outros, children, null_to_empty, listen, assign, set_attributes, toggle_class, get_spread_update, prevent_default, is_function, add_render_callback, create_in_transition, binding_callbacks, set_style, svg_element, claim_svg_element, destroy_each, text, claim_text, set_data, src_url_equal, set_store_value, run_all, HtmlTagHydration, claim_html_tag, construct_svelte_component, subscribe, set_custom_element_data_map } from 'svelte/internal';
4
- import 'svelte/easing';
4
+ import { linear, elasticOut, cubicOut } from 'svelte/easing';
5
5
 
6
6
  /** @internal */
7
7
  const ACTION_HOOK_LABEL = '__ACTION_HOOK__';
@@ -35,9 +35,14 @@ const KARTE_MODAL_ROOT = 'karte-modal-root';
35
35
  /** @internal */
36
36
  const NOOP = (_args) => { }; // eslint-disable-line @typescript-eslint/no-unused-vars
37
37
  /** @internal */
38
- const isPreview = () => {
39
- return true;
40
- };
38
+ const isPreview = () => (true);
39
+ const isCanvasPreview = () => typeof document !== 'undefined'
40
+ ? (document?.querySelector('#preview')?.getAttribute('data-canvas-preview') ?? 'false') ===
41
+ 'true'
42
+ : false;
43
+ const isOnSite = () => typeof document !== 'undefined'
44
+ ? (document?.querySelector('#preview')?.getAttribute('data-on-site') ?? 'true') === 'true'
45
+ : true;
41
46
  /** @internal */
42
47
  const setPreviousFocus = () => {
43
48
  const previously_focused = typeof document !== 'undefined' && document.activeElement;
@@ -3381,6 +3386,54 @@ const execOnClickOperation = (onClickOperation) => {
3381
3386
  const haveFunction = (onClickOperation) => {
3382
3387
  return onClickOperation.operation !== 'none';
3383
3388
  };
3389
+ function getAnimation(animation) {
3390
+ switch (animation.type) {
3391
+ case 'fade':
3392
+ return `opacity: ${animation.progress}`;
3393
+ case 'bounce': {
3394
+ const translateX = animation.x;
3395
+ const translateY = animation.y;
3396
+ return `transform: translate3d(${translateX}%, ${translateY}%, 0) scale(${animation.progress});`;
3397
+ }
3398
+ case 'slide-down': {
3399
+ const translateX = animation.x;
3400
+ const translateY = animation.y - 100 * (1 - animation.progress);
3401
+ return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
3402
+ }
3403
+ case 'slide-up': {
3404
+ const translateX = animation.x;
3405
+ const translateY = animation.y + 100 * (1 - animation.progress);
3406
+ return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
3407
+ }
3408
+ case 'slide-left': {
3409
+ const translateX = animation.x + 100 * (1 - animation.progress);
3410
+ const translateY = animation.y;
3411
+ return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
3412
+ }
3413
+ case 'slide-right': {
3414
+ const translateX = animation.x - 100 * (1 - animation.progress);
3415
+ const translateY = animation.y;
3416
+ return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
3417
+ }
3418
+ case 'none': {
3419
+ const translateX = animation.x;
3420
+ const translateY = animation.y;
3421
+ return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
3422
+ }
3423
+ default:
3424
+ console.warn(`[action-sdk] invalid '${animation}', so we use 'transform: none' instead`);
3425
+ return 'transform: none';
3426
+ }
3427
+ }
3428
+ const EASING = {
3429
+ fade: linear,
3430
+ bounce: elasticOut,
3431
+ 'slide-down': cubicOut,
3432
+ 'slide-up': cubicOut,
3433
+ 'slide-left': cubicOut,
3434
+ 'slide-right': cubicOut,
3435
+ none: linear,
3436
+ };
3384
3437
  /**
3385
3438
  * The function to activate svelte animation.
3386
3439
  *
@@ -3392,9 +3445,23 @@ const haveFunction = (onClickOperation) => {
3392
3445
  * @internal
3393
3446
  */
3394
3447
  function customAnimation(node, { transforms, animationStyle, delay = 0, duration = 1000 }) {
3395
- {
3448
+ if (!isOnSite()) {
3396
3449
  return {};
3397
3450
  }
3451
+ let [x, y] = [0, 0];
3452
+ for (const { query, x: tx, y: ty } of transforms) {
3453
+ if (query == null || window.matchMedia(query).matches) {
3454
+ x = tx;
3455
+ y = ty;
3456
+ break;
3457
+ }
3458
+ }
3459
+ return {
3460
+ delay,
3461
+ duration,
3462
+ easing: EASING[animationStyle],
3463
+ css: (progress) => getAnimation({ type: animationStyle, x, y, progress }),
3464
+ };
3398
3465
  }
3399
3466
 
3400
3467
  /* src/components/BackgroundOverlay.svelte generated by Svelte v3.53.1 */
@@ -18651,7 +18718,7 @@ function add_css$9(target) {
18651
18718
  append_styles(target, "svelte-15b58xm", "*{box-sizing:border-box}.modal.svelte-15b58xm{position:fixed;z-index:2147483647;display:flex}.modal.svelte-15b58xm > .button{flex:auto;display:flex}@media screen and (min-width: 641px){.modal-bp.svelte-15b58xm{height:var(--modal-bp-height-pc) !important;width:var(--modal-bp-width-pc) !important;top:var(--modal-bp-top-pc) !important;left:var(--modal-bp-left-pc) !important;bottom:var(--modal-bp-bottom-pc) !important;right:var(--modal-bp-right-pc) !important;transform:var(--modal-bp-transform-pc);margin:var(--modal-bp-margin-pc) !important}.background-bp-pc{display:block}.background-bp-sp{display:none}}@media screen and (max-width: 640px){.modal-bp.svelte-15b58xm{height:var(--modal-bp-height-sp) !important;width:var(--modal-bp-width-sp) !important;top:var(--modal-bp-top-sp) !important;left:var(--modal-bp-left-sp) !important;bottom:var(--modal-bp-bottom-sp) !important;right:var(--modal-bp-right-sp) !important;transform:var(--modal-bp-transform-sp);margin:var(--modal-bp-margin-sp) !important}.background-bp-pc{display:none}.background-bp-sp{display:block}}");
18652
18719
  }
18653
18720
 
18654
- // (220:0) {:else}
18721
+ // (219:0) {:else}
18655
18722
  function create_else_block(ctx) {
18656
18723
  let backgroundoverlay;
18657
18724
  let current;
@@ -18698,7 +18765,7 @@ function create_else_block(ctx) {
18698
18765
  };
18699
18766
  }
18700
18767
 
18701
- // (209:24)
18768
+ // (208:24)
18702
18769
  function create_if_block_2(ctx) {
18703
18770
  let backgroundoverlay0;
18704
18771
  let t;
@@ -18772,7 +18839,7 @@ function create_if_block_2(ctx) {
18772
18839
  };
18773
18840
  }
18774
18841
 
18775
- // (207:0) {#if isCanvasPreview}
18842
+ // (206:0) {#if isCanvasPreview()}
18776
18843
  function create_if_block_1$1(ctx) {
18777
18844
  return {
18778
18845
  c: noop,
@@ -18785,14 +18852,14 @@ function create_if_block_1$1(ctx) {
18785
18852
  };
18786
18853
  }
18787
18854
 
18788
- // (223:0) {#if visible}
18855
+ // (222:0) {#if visible}
18789
18856
  function create_if_block$3(ctx) {
18790
18857
  let div;
18791
18858
  let div_class_value;
18792
18859
  let div_intro;
18793
18860
  let current;
18794
- const default_slot_template = /*#slots*/ ctx[26].default;
18795
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[25], null);
18861
+ const default_slot_template = /*#slots*/ ctx[25].default;
18862
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[24], null);
18796
18863
 
18797
18864
  return {
18798
18865
  c() {
@@ -18819,7 +18886,7 @@ function create_if_block$3(ctx) {
18819
18886
  attr(div, "role", "dialog");
18820
18887
  attr(div, "aria-modal", "true");
18821
18888
  attr(div, "data-layer-id", /*layerId*/ ctx[2]);
18822
- attr(div, "style", Array.from(/*modalStyles*/ ctx[14]).join(';'));
18889
+ attr(div, "style", Array.from(/*modalStyles*/ ctx[13]).join(';'));
18823
18890
  },
18824
18891
  m(target, anchor) {
18825
18892
  insert_hydration(target, div, anchor);
@@ -18828,22 +18895,22 @@ function create_if_block$3(ctx) {
18828
18895
  default_slot.m(div, null);
18829
18896
  }
18830
18897
 
18831
- /*div_binding*/ ctx[27](div);
18898
+ /*div_binding*/ ctx[26](div);
18832
18899
  current = true;
18833
18900
  },
18834
18901
  p(new_ctx, dirty) {
18835
18902
  ctx = new_ctx;
18836
18903
 
18837
18904
  if (default_slot) {
18838
- if (default_slot.p && (!current || dirty & /*$$scope*/ 33554432)) {
18905
+ if (default_slot.p && (!current || dirty & /*$$scope*/ 16777216)) {
18839
18906
  update_slot_base(
18840
18907
  default_slot,
18841
18908
  default_slot_template,
18842
18909
  ctx,
18843
- /*$$scope*/ ctx[25],
18910
+ /*$$scope*/ ctx[24],
18844
18911
  !current
18845
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
18846
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[25], dirty, null),
18912
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[24])
18913
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[24], dirty, null),
18847
18914
  null
18848
18915
  );
18849
18916
  }
@@ -18881,12 +18948,13 @@ function create_if_block$3(ctx) {
18881
18948
  d(detaching) {
18882
18949
  if (detaching) detach(div);
18883
18950
  if (default_slot) default_slot.d(detaching);
18884
- /*div_binding*/ ctx[27](null);
18951
+ /*div_binding*/ ctx[26](null);
18885
18952
  }
18886
18953
  };
18887
18954
  }
18888
18955
 
18889
18956
  function create_fragment$d(ctx) {
18957
+ let show_if;
18890
18958
  let current_block_type_index;
18891
18959
  let if_block0;
18892
18960
  let t;
@@ -18898,7 +18966,8 @@ function create_fragment$d(ctx) {
18898
18966
  const if_blocks = [];
18899
18967
 
18900
18968
  function select_block_type(ctx, dirty) {
18901
- if (/*isCanvasPreview*/ ctx[13]) return 0;
18969
+ if (show_if == null) show_if = !!isCanvasPreview();
18970
+ if (show_if) return 0;
18902
18971
  if (/*useBreakPoint*/ ctx[0]) return 1;
18903
18972
  return 2;
18904
18973
  }
@@ -19026,7 +19095,6 @@ function instance$d($$self, $$props, $$invalidate) {
19026
19095
  let { closeEventValue = null } = $$props;
19027
19096
  let { layerId = '' } = $$props;
19028
19097
  const { brandKit } = useBrandKit();
19029
- const isCanvasPreview = (document.querySelector('#preview')?.getAttribute('data-canvas-preview') ?? 'false') === 'true';
19030
19098
 
19031
19099
  // モーダル背景の設定
19032
19100
  const isExistBackgroundOverlayValue = placement && placement.backgroundOverlay !== undefined;
@@ -19059,20 +19127,20 @@ function instance$d($$self, $$props, $$invalidate) {
19059
19127
 
19060
19128
  $$self.$$set = $$props => {
19061
19129
  if ('useBreakPoint' in $$props) $$invalidate(0, useBreakPoint = $$props.useBreakPoint);
19062
- if ('placement' in $$props) $$invalidate(15, placement = $$props.placement);
19063
- if ('breakPoint' in $$props) $$invalidate(16, breakPoint = $$props.breakPoint);
19064
- if ('elasticity' in $$props) $$invalidate(17, elasticity = $$props.elasticity);
19130
+ if ('placement' in $$props) $$invalidate(14, placement = $$props.placement);
19131
+ if ('breakPoint' in $$props) $$invalidate(15, breakPoint = $$props.breakPoint);
19132
+ if ('elasticity' in $$props) $$invalidate(16, elasticity = $$props.elasticity);
19065
19133
  if ('animation' in $$props) $$invalidate(1, animation = $$props.animation);
19066
- if ('props' in $$props) $$invalidate(18, props = $$props.props);
19067
- if ('closeEventName' in $$props) $$invalidate(19, closeEventName = $$props.closeEventName);
19068
- if ('closeEventValue' in $$props) $$invalidate(20, closeEventValue = $$props.closeEventValue);
19134
+ if ('props' in $$props) $$invalidate(17, props = $$props.props);
19135
+ if ('closeEventName' in $$props) $$invalidate(18, closeEventName = $$props.closeEventName);
19136
+ if ('closeEventValue' in $$props) $$invalidate(19, closeEventValue = $$props.closeEventValue);
19069
19137
  if ('layerId' in $$props) $$invalidate(2, layerId = $$props.layerId);
19070
- if ('$$scope' in $$props) $$invalidate(25, $$scope = $$props.$$scope);
19138
+ if ('$$scope' in $$props) $$invalidate(24, $$scope = $$props.$$scope);
19071
19139
  };
19072
19140
 
19073
19141
  $$self.$$.update = () => {
19074
- if ($$self.$$.dirty & /*closeEventName, closeEventValue*/ 1572864) {
19075
- $$invalidate(24, close = () => {
19142
+ if ($$self.$$.dirty & /*closeEventName, closeEventValue*/ 786432) {
19143
+ $$invalidate(23, close = () => {
19076
19144
  const onClose = { operation: 'closeApp', args: ['button'] };
19077
19145
 
19078
19146
  if (closeEventName) {
@@ -19083,9 +19151,9 @@ function instance$d($$self, $$props, $$invalidate) {
19083
19151
  });
19084
19152
  }
19085
19153
 
19086
- if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint*/ 98305) {
19154
+ if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint*/ 49153) {
19087
19155
  {
19088
- if (!isCanvasPreview && isExistBackgroundOverlayValue) {
19156
+ if (!isCanvasPreview() && isExistBackgroundOverlayValue) {
19089
19157
  $$invalidate(4, backgroundOverlay = placement.backgroundOverlay);
19090
19158
  }
19091
19159
 
@@ -19098,29 +19166,29 @@ function instance$d($$self, $$props, $$invalidate) {
19098
19166
  }
19099
19167
  }
19100
19168
 
19101
- if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint*/ 98305) {
19169
+ if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint*/ 49153) {
19102
19170
  {
19103
19171
  if (placement && placement.backgroundClick) {
19104
- $$invalidate(21, backgroundClickFunction = placement.backgroundClick);
19172
+ $$invalidate(20, backgroundClickFunction = placement.backgroundClick);
19105
19173
  }
19106
19174
 
19107
19175
  if (useBreakPoint) {
19108
19176
  const pc = breakPoint?.PC?.placement?.backgroundClick;
19109
19177
 
19110
19178
  if (pc) {
19111
- $$invalidate(22, backgroundClickFunctionPC = pc);
19179
+ $$invalidate(21, backgroundClickFunctionPC = pc);
19112
19180
  }
19113
19181
 
19114
19182
  const sp = breakPoint?.SP?.placement?.backgroundClick;
19115
19183
 
19116
19184
  if (sp) {
19117
- $$invalidate(23, backgroundClickFunctionSP = sp);
19185
+ $$invalidate(22, backgroundClickFunctionSP = sp);
19118
19186
  }
19119
19187
  }
19120
19188
  }
19121
19189
  }
19122
19190
 
19123
- if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunction*/ 3670016) {
19191
+ if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunction*/ 1835008) {
19124
19192
  $$invalidate(12, backgroundClick = () => {
19125
19193
  if (closeEventName) {
19126
19194
  send_event(closeEventName, closeEventValue);
@@ -19130,7 +19198,7 @@ function instance$d($$self, $$props, $$invalidate) {
19130
19198
  });
19131
19199
  }
19132
19200
 
19133
- if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunctionPC*/ 5767168) {
19201
+ if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunctionPC*/ 2883584) {
19134
19202
  $$invalidate(11, backgroundClickPC = () => {
19135
19203
  if (closeEventName) {
19136
19204
  send_event(closeEventName, closeEventValue);
@@ -19140,7 +19208,7 @@ function instance$d($$self, $$props, $$invalidate) {
19140
19208
  });
19141
19209
  }
19142
19210
 
19143
- if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunctionSP*/ 9961472) {
19211
+ if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunctionSP*/ 4980736) {
19144
19212
  $$invalidate(10, backgroundClickSP = () => {
19145
19213
  if (closeEventName) {
19146
19214
  send_event(closeEventName, closeEventValue);
@@ -19150,13 +19218,13 @@ function instance$d($$self, $$props, $$invalidate) {
19150
19218
  });
19151
19219
  }
19152
19220
 
19153
- if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint, transforms*/ 98313) {
19221
+ if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint, transforms*/ 49161) {
19154
19222
  // 表示位置のスタイルとアニメーションの動きを設定
19155
19223
  {
19156
19224
  // 表示位置のスタイルの設定
19157
19225
  let position = DefaultModalPlacement.position;
19158
19226
 
19159
- if (!isCanvasPreview && placement && placement.position !== null) {
19227
+ if (!isCanvasPreview() && placement && placement.position !== null) {
19160
19228
  position = placement.position;
19161
19229
  }
19162
19230
 
@@ -19173,7 +19241,7 @@ function instance$d($$self, $$props, $$invalidate) {
19173
19241
  $$invalidate(3, transforms = []);
19174
19242
 
19175
19243
  DEVICE_IDS.forEach(deviceId => {
19176
- if (!isCanvasPreview && useBreakPoint) {
19244
+ if (!isCanvasPreview() && useBreakPoint) {
19177
19245
  const positionWithBp = breakPoint[deviceId]?.placement?.position;
19178
19246
 
19179
19247
  transforms.push({
@@ -19198,12 +19266,12 @@ function instance$d($$self, $$props, $$invalidate) {
19198
19266
  }
19199
19267
  }
19200
19268
 
19201
- if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint, props*/ 360449) {
19269
+ if ($$self.$$.dirty & /*placement, useBreakPoint, breakPoint, props*/ 180225) {
19202
19270
  // 表示位置の調整のスタイルを設定
19203
19271
  {
19204
19272
  let margin = DefaultModalPlacement.margin;
19205
19273
 
19206
- if (!isCanvasPreview && placement && placement.margin !== null) {
19274
+ if (!isCanvasPreview() && placement && placement.margin !== null) {
19207
19275
  margin = placement.margin;
19208
19276
  }
19209
19277
 
@@ -19214,7 +19282,7 @@ function instance$d($$self, $$props, $$invalidate) {
19214
19282
  }
19215
19283
 
19216
19284
  DEVICE_IDS.forEach(deviceId => {
19217
- if (!isCanvasPreview && useBreakPoint) {
19285
+ if (!isCanvasPreview() && useBreakPoint) {
19218
19286
  const marginWithBp = breakPoint[deviceId]?.placement?.margin;
19219
19287
  marginStyle = getMarginStyle(marginWithBp);
19220
19288
  }
@@ -19242,7 +19310,7 @@ function instance$d($$self, $$props, $$invalidate) {
19242
19310
  }
19243
19311
  }
19244
19312
 
19245
- if ($$self.$$.dirty & /*close*/ 16777216) {
19313
+ if ($$self.$$.dirty & /*close*/ 8388608) {
19246
19314
  $$invalidate(9, handle_keydown = handleKeydown({ Escape: close }));
19247
19315
  }
19248
19316
  };
@@ -19266,7 +19334,6 @@ function instance$d($$self, $$props, $$invalidate) {
19266
19334
  backgroundClickSP,
19267
19335
  backgroundClickPC,
19268
19336
  backgroundClick,
19269
- isCanvasPreview,
19270
19337
  modalStyles,
19271
19338
  placement,
19272
19339
  breakPoint,
@@ -19296,13 +19363,13 @@ class Modal extends SvelteComponent {
19296
19363
  safe_not_equal,
19297
19364
  {
19298
19365
  useBreakPoint: 0,
19299
- placement: 15,
19300
- breakPoint: 16,
19301
- elasticity: 17,
19366
+ placement: 14,
19367
+ breakPoint: 15,
19368
+ elasticity: 16,
19302
19369
  animation: 1,
19303
- props: 18,
19304
- closeEventName: 19,
19305
- closeEventValue: 20,
19370
+ props: 17,
19371
+ closeEventName: 18,
19372
+ closeEventValue: 19,
19306
19373
  layerId: 2
19307
19374
  },
19308
19375
  add_css$9
@@ -21091,7 +21158,7 @@ function getActionRoot() {
21091
21158
  return root.shadowRoot;
21092
21159
  }
21093
21160
  /** @internal */
21094
- function ensureActionRoot() {
21161
+ function ensureActionRoot(useShadow = true) {
21095
21162
  const systemConfig = getSystem();
21096
21163
  const rootAttrs = {
21097
21164
  class: `${KARTE_ACTION_ROOT} ${KARTE_MODAL_ROOT}`,
@@ -21106,7 +21173,7 @@ function ensureActionRoot() {
21106
21173
  el = h('div', rootAttrs);
21107
21174
  document.body.appendChild(el);
21108
21175
  }
21109
- const isShadow = !!document.body.attachShadow;
21176
+ const isShadow = !!document.body.attachShadow && useShadow;
21110
21177
  if (isShadow) {
21111
21178
  return el.shadowRoot ?? el.attachShadow({ mode: 'open' });
21112
21179
  }
@@ -21175,7 +21242,7 @@ function createApp(App, options = {
21175
21242
  },
21176
21243
  },
21177
21244
  };
21178
- const win = ensureModalRoot();
21245
+ const win = ensureModalRoot(true);
21179
21246
  appArgs.target = win;
21180
21247
  return {
21181
21248
  close,