@plaidev/karte-action-sdk 1.1.76 → 1.1.77
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.
- package/dist/hydrate/index.es.d.ts +26 -9
- package/dist/hydrate/index.es.js +117 -49
- package/dist/index.es.d.ts +26 -9
- package/dist/index.es.js +104 -48
- package/package.json +1 -1
|
@@ -78,6 +78,7 @@ type OperationArgumentTypes = {
|
|
|
78
78
|
State: string;
|
|
79
79
|
Url: string;
|
|
80
80
|
Handler: string;
|
|
81
|
+
Trigger: string;
|
|
81
82
|
};
|
|
82
83
|
type OperationArgumentType = keyof OperationArgumentTypes;
|
|
83
84
|
type BaseOperationOptions = ReadonlyArray<{
|
|
@@ -127,6 +128,10 @@ declare const OnClickOperationOptions: readonly [
|
|
|
127
128
|
{
|
|
128
129
|
readonly operation: "closeApp";
|
|
129
130
|
readonly args: readonly [
|
|
131
|
+
{
|
|
132
|
+
readonly type: "Trigger";
|
|
133
|
+
readonly default: "button";
|
|
134
|
+
}
|
|
130
135
|
];
|
|
131
136
|
},
|
|
132
137
|
{
|
|
@@ -235,15 +240,14 @@ type OPTIONS = {
|
|
|
235
240
|
isPreview?: boolean;
|
|
236
241
|
initialState?: string;
|
|
237
242
|
};
|
|
243
|
+
type CloseTrigger = "button" | "overlay";
|
|
238
244
|
type ActionEventHandler = (...args: any[]) => any | Promise<any>;
|
|
239
|
-
declare const
|
|
240
|
-
ALL_ACTION_ID: string;
|
|
241
|
-
STATE_EVENT: string;
|
|
242
|
-
};
|
|
245
|
+
declare const ALL_ACTION_ID = "KARTE_ALL_ACTION_ID";
|
|
243
246
|
declare const actionId: string;
|
|
244
247
|
declare const ACTION_SHOW_EVENT: string;
|
|
245
248
|
declare const ACTION_CLOSE_EVENT: string;
|
|
246
249
|
declare const ACTION_DESTROY_EVENT: string;
|
|
250
|
+
declare const ACTION_CHANGE_STATE_EVENT: string;
|
|
247
251
|
// Store to handle current state ID
|
|
248
252
|
declare const state: Store<string>;
|
|
249
253
|
// Store to handle all state IDs
|
|
@@ -284,7 +288,7 @@ declare const setMiximumZindex: (zindex?: number) => void;
|
|
|
284
288
|
declare const none: () => () => void;
|
|
285
289
|
declare const moveTo: (to: string) => () => void;
|
|
286
290
|
declare const linkTo: (to: string, targetBlank?: boolean) => () => void;
|
|
287
|
-
declare const closeApp: () => () => void;
|
|
291
|
+
declare const closeApp: (trigger: CloseTrigger) => () => void;
|
|
288
292
|
declare const runScript: (handlerName: string) => () => void;
|
|
289
293
|
declare const execOnClickOperation: (onClickOperation: OnClickOperation) => void;
|
|
290
294
|
declare const haveFunction: (onClickOperation: OnClickOperation) => boolean;
|
|
@@ -351,6 +355,14 @@ declare function applyGlobalCss(css: string): Promise<any>;
|
|
|
351
355
|
* @param {string} href Link of style file
|
|
352
356
|
*/
|
|
353
357
|
declare function loadGlobalStyle(href: string): Promise<any>;
|
|
358
|
+
/**
|
|
359
|
+
* {@link hashCode} generate hash with FNV-1a hash
|
|
360
|
+
*
|
|
361
|
+
* @param {string} s Inputed string
|
|
362
|
+
* @return {string} Hashed string
|
|
363
|
+
* @see https://stackoverflow.com/a/22429679
|
|
364
|
+
*/
|
|
365
|
+
declare function hashCode(s: string): string;
|
|
354
366
|
declare const handleFocus: (node: HTMLElement | null) => (e: any) => void;
|
|
355
367
|
declare const setPreviousFocus: () => void;
|
|
356
368
|
declare const handleKeydown: (handlers: {
|
|
@@ -441,7 +453,7 @@ interface ActionOptions<Props, Variables> {
|
|
|
441
453
|
*
|
|
442
454
|
* @default () => {}
|
|
443
455
|
*/
|
|
444
|
-
onClose?: (props: ActionProps<Props, Variables
|
|
456
|
+
onClose?: (props: ActionProps<Props, Variables>, trigger: CloseTrigger) => void | Promise<void>;
|
|
445
457
|
/**
|
|
446
458
|
* {@link onClose} function to hook the phase of changing action state in KARTE action.
|
|
447
459
|
*
|
|
@@ -488,7 +500,7 @@ declare function show(): void;
|
|
|
488
500
|
* Close KARTE action
|
|
489
501
|
*/
|
|
490
502
|
declare function close(): void;
|
|
491
|
-
declare const KARTE_ACTION_ROOT = "karte-
|
|
503
|
+
declare const KARTE_ACTION_ROOT = "karte-action-root";
|
|
492
504
|
declare const KARTE_ACTION_RID = "karte-action-rid";
|
|
493
505
|
declare function ensureActionRoot(useShadow?: boolean): ShadowRoot | HTMLElement;
|
|
494
506
|
/**
|
|
@@ -505,12 +517,13 @@ fn: (props: ActionProps<Props, Variables>) => void | Promise<void>): void;
|
|
|
505
517
|
* {@link onClose} function to set the function to hook the phase before closing action.
|
|
506
518
|
*
|
|
507
519
|
* @param {(props: ActionProps<Props, Variables>) => void | Promise<void>} fn Callback
|
|
520
|
+
* @param {ClosePlace} fn Callback
|
|
508
521
|
*/
|
|
509
522
|
declare function onClose<Props extends _Props, Variables>(/**
|
|
510
523
|
* @param {ActionProps<Props, Variables>} props Properties of KARTE action
|
|
511
524
|
* @returns {void|Promise<void>}
|
|
512
525
|
*/
|
|
513
|
-
fn: (props: ActionProps<Props, Variables
|
|
526
|
+
fn: (props: ActionProps<Props, Variables>, trigger: CloseTrigger) => void | Promise<void>): void;
|
|
514
527
|
/**
|
|
515
528
|
* {@link onDestory} function to set the function to hook the phase before destroying action.
|
|
516
529
|
*
|
|
@@ -533,6 +546,9 @@ declare function onChangeState<Props extends _Props, Variables>(/**
|
|
|
533
546
|
*/
|
|
534
547
|
fn: (props: ActionProps<Props, Variables>, newState: string) => void | Promise<void>): void;
|
|
535
548
|
declare const h: (type: string, props: any, ...children: Array<any>) => HTMLElement;
|
|
549
|
+
/**
|
|
550
|
+
* @deprecated
|
|
551
|
+
*/
|
|
536
552
|
declare function createFog({ color, opacity, zIndex, onclick }: {
|
|
537
553
|
color?: string;
|
|
538
554
|
opacity?: string;
|
|
@@ -544,6 +560,7 @@ declare function createFog({ color, opacity, zIndex, onclick }: {
|
|
|
544
560
|
};
|
|
545
561
|
type EmbedLogic = "replace" | "append" | "prepend" | "after" | "before";
|
|
546
562
|
declare function embed(target: HTMLElement, replace: HTMLElement, embed_method: EmbedLogic): void;
|
|
563
|
+
declare function getActionShadowRoot(): ShadowRoot | null;
|
|
547
564
|
/**
|
|
548
565
|
* {@link applyCss} apply CSS to KARTE action.
|
|
549
566
|
*
|
|
@@ -605,7 +622,7 @@ declare const collection: (config: {
|
|
|
605
622
|
} | null | undefined, cb: (err: Error | null, items?: any) => void): void;
|
|
606
623
|
set(key: string, value: string, cb: (err: Error | null) => void): void;
|
|
607
624
|
};
|
|
608
|
-
export { Store, getStoreState, ActionEventHandler,
|
|
625
|
+
export { Store, getStoreState, 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, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getTransform, getMarginStyle, 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, NOOP, 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 };
|
|
609
626
|
export { default as State } from './components/State.svelte';
|
|
610
627
|
export { default as StateItem } from './components/StateItem.svelte';
|
|
611
628
|
export { default as Modal } from './components/Modal.svelte';
|
package/dist/hydrate/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { writable, get } from 'svelte/store';
|
|
2
2
|
import 'svelte/easing';
|
|
3
|
-
import { SvelteComponent, init, safe_not_equal, append_styles, create_slot, create_component, space, claim_component, claim_space, mount_component, insert_hydration, update_slot_base, get_all_dirty_from_scope, get_slot_changes, transition_in, transition_out, destroy_component, detach, empty, group_outros, check_outros, component_subscribe,
|
|
3
|
+
import { SvelteComponent, init, safe_not_equal, append_styles, create_slot, create_component, space, claim_component, claim_space, mount_component, insert_hydration, update_slot_base, get_all_dirty_from_scope, get_slot_changes, transition_in, transition_out, destroy_component, detach, empty, group_outros, check_outros, component_subscribe, element, claim_element, children, attr, noop, listen, is_function, append_hydration, add_render_callback, create_in_transition, svg_element, claim_svg_element, binding_callbacks, destroy_each, text, claim_text, set_data, src_url_equal, null_to_empty } from 'https://esm.sh/svelte@3.53.1/internal';
|
|
4
4
|
import { createEventDispatcher, onMount, onDestroy as onDestroy$1, setContext, getContext } from 'https://esm.sh/svelte@3.53.1';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -133,15 +133,13 @@ function randStr(digit = 8) {
|
|
|
133
133
|
* UIから選択できる関数
|
|
134
134
|
*/
|
|
135
135
|
const getStoreState = get;
|
|
136
|
-
const
|
|
137
|
-
ALL_ACTION_ID: 'KARTE_ALL_ACTION_ID',
|
|
138
|
-
STATE_EVENT: 'KARTE-ACTION-CHANGE-STATE',
|
|
139
|
-
};
|
|
136
|
+
const ALL_ACTION_ID = 'KARTE_ALL_ACTION_ID';
|
|
140
137
|
const functionOptions = writable({});
|
|
141
138
|
const actionId = randStr();
|
|
142
139
|
const ACTION_SHOW_EVENT = `KARTE-ACTION-SHOW-${actionId}`;
|
|
143
140
|
const ACTION_CLOSE_EVENT = `KARTE-ACTION-CLOSE-${actionId}`;
|
|
144
141
|
const ACTION_DESTROY_EVENT = `KARTE-ACTION-DESTROY-${actionId}`;
|
|
142
|
+
const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
|
|
145
143
|
// Store to handle current state ID
|
|
146
144
|
const state = writable('/');
|
|
147
145
|
// Store to handle all state IDs
|
|
@@ -169,7 +167,7 @@ const setAutoStart = (on = true) => {
|
|
|
169
167
|
stopped.set(!on);
|
|
170
168
|
};
|
|
171
169
|
const setState = (event) => {
|
|
172
|
-
if (event.detail.actionId === actionId || event.detail.actionId ===
|
|
170
|
+
if (event.detail.actionId === actionId || event.detail.actionId === ALL_ACTION_ID) {
|
|
173
171
|
state.set(event.detail.to);
|
|
174
172
|
}
|
|
175
173
|
};
|
|
@@ -200,7 +198,7 @@ const setMiximumZindex = (zindex) => {
|
|
|
200
198
|
const none = () => () => { };
|
|
201
199
|
const moveTo = (to) => () => {
|
|
202
200
|
send_event('_message_state_changed', { state: to });
|
|
203
|
-
window.dispatchEvent(new CustomEvent(
|
|
201
|
+
window.dispatchEvent(new CustomEvent(ACTION_CHANGE_STATE_EVENT, { detail: { to, actionId } }));
|
|
204
202
|
};
|
|
205
203
|
const linkTo = (to, targetBlank = true) => () => {
|
|
206
204
|
send_event('message_click', { url: to });
|
|
@@ -211,8 +209,9 @@ const linkTo = (to, targetBlank = true) => () => {
|
|
|
211
209
|
location.href = to;
|
|
212
210
|
}
|
|
213
211
|
};
|
|
214
|
-
const closeApp = () => () => {
|
|
215
|
-
send_event('message_close',
|
|
212
|
+
const closeApp = (trigger) => () => {
|
|
213
|
+
send_event('message_close', { trigger });
|
|
214
|
+
window.dispatchEvent(new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } }));
|
|
216
215
|
closed.set(true);
|
|
217
216
|
};
|
|
218
217
|
const runScript = (handlerName) => () => {
|
|
@@ -235,7 +234,7 @@ const execOnClickOperation = (onClickOperation) => {
|
|
|
235
234
|
moveTo(...onClickOperation.args)();
|
|
236
235
|
}
|
|
237
236
|
else if (onClickOperation.operation === 'closeApp') {
|
|
238
|
-
closeApp()();
|
|
237
|
+
closeApp(onClickOperation.args[0] || 'button')();
|
|
239
238
|
}
|
|
240
239
|
else if (onClickOperation.operation === 'runScript') {
|
|
241
240
|
runScript(onClickOperation.args[0])();
|
|
@@ -298,6 +297,22 @@ async function loadGlobalStyle(href) {
|
|
|
298
297
|
link.addEventListener('error', () => reject(link));
|
|
299
298
|
});
|
|
300
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* {@link hashCode} generate hash with FNV-1a hash
|
|
302
|
+
*
|
|
303
|
+
* @param {string} s Inputed string
|
|
304
|
+
* @return {string} Hashed string
|
|
305
|
+
* @see https://stackoverflow.com/a/22429679
|
|
306
|
+
*/
|
|
307
|
+
function hashCode(s) {
|
|
308
|
+
const SEED = 0x41653150;
|
|
309
|
+
let hash = SEED;
|
|
310
|
+
Array.from(s).forEach((c, index) => {
|
|
311
|
+
hash ^= c.charCodeAt(index);
|
|
312
|
+
hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
|
|
313
|
+
});
|
|
314
|
+
return ('0000000' + (hash >>> 0).toString(16)).substr(-8);
|
|
315
|
+
}
|
|
301
316
|
|
|
302
317
|
const PropTypes = [
|
|
303
318
|
'BooleanKeyword',
|
|
@@ -355,7 +370,7 @@ const DefaultModalPlacement = {
|
|
|
355
370
|
bottom: '0px',
|
|
356
371
|
},
|
|
357
372
|
backgroundOverlay: false,
|
|
358
|
-
backgroundClick: { operation: 'closeApp', args: [] },
|
|
373
|
+
backgroundClick: { operation: 'closeApp', args: ['overlay'] },
|
|
359
374
|
};
|
|
360
375
|
const OnClickOperationOptions = [
|
|
361
376
|
{
|
|
@@ -386,7 +401,12 @@ const OnClickOperationOptions = [
|
|
|
386
401
|
},
|
|
387
402
|
{
|
|
388
403
|
operation: 'closeApp',
|
|
389
|
-
args: [
|
|
404
|
+
args: [
|
|
405
|
+
{
|
|
406
|
+
type: 'Trigger',
|
|
407
|
+
default: 'button',
|
|
408
|
+
},
|
|
409
|
+
],
|
|
390
410
|
},
|
|
391
411
|
{
|
|
392
412
|
operation: 'runScript',
|
|
@@ -468,26 +488,27 @@ function create(App, options = {
|
|
|
468
488
|
}) {
|
|
469
489
|
let app = null;
|
|
470
490
|
const data = { ...options.props, ...options.variables };
|
|
471
|
-
const close = () => {
|
|
491
|
+
const close = (event = {}) => {
|
|
472
492
|
if (!app) {
|
|
473
493
|
return;
|
|
474
494
|
}
|
|
475
495
|
closed.set(true);
|
|
476
|
-
window.removeEventListener(
|
|
496
|
+
window.removeEventListener(ACTION_CHANGE_STATE_EVENT, setState);
|
|
497
|
+
const trigger = event.detail?.trigger ? event.detail?.trigger : 'button';
|
|
477
498
|
if (options.onClose) {
|
|
478
|
-
options.onClose({ send: options.send, data });
|
|
499
|
+
options.onClose({ send: options.send, data }, trigger);
|
|
479
500
|
}
|
|
480
501
|
app.$destroy();
|
|
481
502
|
app = null;
|
|
482
503
|
};
|
|
483
504
|
window.addEventListener(ACTION_CLOSE_EVENT, close);
|
|
484
|
-
const show = () => {
|
|
505
|
+
const show = (_event = {}) => {
|
|
485
506
|
if (app) {
|
|
486
507
|
return;
|
|
487
508
|
}
|
|
488
509
|
options.send('message_open');
|
|
489
510
|
closed.set(false);
|
|
490
|
-
window.addEventListener(
|
|
511
|
+
window.addEventListener(ACTION_CHANGE_STATE_EVENT, setState);
|
|
491
512
|
app = new App({
|
|
492
513
|
target: ensureModalRoot(!true),
|
|
493
514
|
hydrate: true,
|
|
@@ -540,7 +561,7 @@ function create(App, options = {
|
|
|
540
561
|
* Dispatch the event to destroy KARTE action
|
|
541
562
|
*/
|
|
542
563
|
function dispatchDestroyEvent() {
|
|
543
|
-
const event = new
|
|
564
|
+
const event = new CustomEvent(ACTION_DESTROY_EVENT);
|
|
544
565
|
window.dispatchEvent(event);
|
|
545
566
|
}
|
|
546
567
|
/**
|
|
@@ -554,22 +575,25 @@ function destroy() {
|
|
|
554
575
|
* Show KARTE action
|
|
555
576
|
*/
|
|
556
577
|
function show() {
|
|
557
|
-
const event = new
|
|
578
|
+
const event = new CustomEvent(ACTION_SHOW_EVENT);
|
|
558
579
|
window.dispatchEvent(event);
|
|
559
580
|
}
|
|
560
581
|
/**
|
|
561
582
|
* Close KARTE action
|
|
562
583
|
*/
|
|
563
584
|
function close() {
|
|
564
|
-
const event = new
|
|
585
|
+
const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger: 'button' } });
|
|
565
586
|
window.dispatchEvent(event);
|
|
566
587
|
}
|
|
567
|
-
const KARTE_ACTION_ROOT = 'karte-
|
|
588
|
+
const KARTE_ACTION_ROOT = 'karte-action-root';
|
|
568
589
|
const KARTE_ACTION_RID = 'karte-action-rid';
|
|
569
590
|
function ensureActionRoot(useShadow = true) {
|
|
570
591
|
let el = document.querySelector(`.${KARTE_MODAL_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
|
571
592
|
if (el == null) {
|
|
572
|
-
el = h('div', {
|
|
593
|
+
el = h('div', {
|
|
594
|
+
class: `${KARTE_ACTION_ROOT} ${KARTE_MODAL_ROOT}`,
|
|
595
|
+
[`data-${KARTE_ACTION_RID}`]: actionId,
|
|
596
|
+
});
|
|
573
597
|
document.body.appendChild(el);
|
|
574
598
|
}
|
|
575
599
|
const isShadow = !!document.body.attachShadow && useShadow;
|
|
@@ -600,6 +624,7 @@ fn) {
|
|
|
600
624
|
* {@link onClose} function to set the function to hook the phase before closing action.
|
|
601
625
|
*
|
|
602
626
|
* @param {(props: ActionProps<Props, Variables>) => void | Promise<void>} fn Callback
|
|
627
|
+
* @param {ClosePlace} fn Callback
|
|
603
628
|
*/
|
|
604
629
|
function onClose(
|
|
605
630
|
/**
|
|
@@ -661,6 +686,9 @@ const h = (type, props, ...children) => {
|
|
|
661
686
|
}
|
|
662
687
|
return el;
|
|
663
688
|
};
|
|
689
|
+
/**
|
|
690
|
+
* @deprecated
|
|
691
|
+
*/
|
|
664
692
|
function createFog({ color = '#000', opacity = '50%', zIndex = 999, onclick, }) {
|
|
665
693
|
const root = ensureModalRoot(false);
|
|
666
694
|
if (root.querySelector('.__krt-fog')) {
|
|
@@ -749,7 +777,7 @@ async function loadStyle(href) {
|
|
|
749
777
|
}
|
|
750
778
|
// -------- The following codes are deprecated --------
|
|
751
779
|
const showModal = create; // @deprecated
|
|
752
|
-
const KARTE_MODAL_ROOT =
|
|
780
|
+
const KARTE_MODAL_ROOT = 'karte-modal-root'; // @deprecated
|
|
753
781
|
const ensureModalRoot = ensureActionRoot; // @deprecated
|
|
754
782
|
/**
|
|
755
783
|
* Create an application instance
|
|
@@ -865,14 +893,14 @@ function request(url, data, cb) {
|
|
|
865
893
|
|
|
866
894
|
/* src/components/Normalize.svelte generated by Svelte v3.53.1 */
|
|
867
895
|
|
|
868
|
-
function add_css$
|
|
896
|
+
function add_css$e(target) {
|
|
869
897
|
append_styles(target, "svelte-tr4qnr", "@import 'https://esm.sh/normalize.css';");
|
|
870
898
|
}
|
|
871
899
|
|
|
872
900
|
class Normalize extends SvelteComponent {
|
|
873
901
|
constructor(options) {
|
|
874
902
|
super();
|
|
875
|
-
init(this, options, null, null, safe_not_equal, {}, add_css$
|
|
903
|
+
init(this, options, null, null, safe_not_equal, {}, add_css$e);
|
|
876
904
|
}
|
|
877
905
|
}
|
|
878
906
|
|
|
@@ -961,19 +989,40 @@ class State extends SvelteComponent {
|
|
|
961
989
|
|
|
962
990
|
/* src/components/StateItem.svelte generated by Svelte v3.53.1 */
|
|
963
991
|
|
|
992
|
+
function add_css$d(target) {
|
|
993
|
+
append_styles(target, "svelte-2qb6dm", ".state-item.svelte-2qb6dm{position:absolute;display:none}");
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// (14:0) {#if $state === path}
|
|
964
997
|
function create_if_block$3(ctx) {
|
|
998
|
+
let div;
|
|
999
|
+
let t;
|
|
965
1000
|
let current;
|
|
966
1001
|
const default_slot_template = /*#slots*/ ctx[3].default;
|
|
967
1002
|
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[2], null);
|
|
968
1003
|
|
|
969
1004
|
return {
|
|
970
1005
|
c() {
|
|
1006
|
+
div = element("div");
|
|
1007
|
+
t = space();
|
|
971
1008
|
if (default_slot) default_slot.c();
|
|
1009
|
+
this.h();
|
|
972
1010
|
},
|
|
973
1011
|
l(nodes) {
|
|
1012
|
+
div = claim_element(nodes, "DIV", { "data-state-path": true, class: true });
|
|
1013
|
+
children(div).forEach(detach);
|
|
1014
|
+
t = claim_space(nodes);
|
|
974
1015
|
if (default_slot) default_slot.l(nodes);
|
|
1016
|
+
this.h();
|
|
1017
|
+
},
|
|
1018
|
+
h() {
|
|
1019
|
+
attr(div, "data-state-path", /*path*/ ctx[0]);
|
|
1020
|
+
attr(div, "class", "state-item svelte-2qb6dm");
|
|
975
1021
|
},
|
|
976
1022
|
m(target, anchor) {
|
|
1023
|
+
insert_hydration(target, div, anchor);
|
|
1024
|
+
insert_hydration(target, t, anchor);
|
|
1025
|
+
|
|
977
1026
|
if (default_slot) {
|
|
978
1027
|
default_slot.m(target, anchor);
|
|
979
1028
|
}
|
|
@@ -981,6 +1030,10 @@ function create_if_block$3(ctx) {
|
|
|
981
1030
|
current = true;
|
|
982
1031
|
},
|
|
983
1032
|
p(ctx, dirty) {
|
|
1033
|
+
if (!current || dirty & /*path*/ 1) {
|
|
1034
|
+
attr(div, "data-state-path", /*path*/ ctx[0]);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
984
1037
|
if (default_slot) {
|
|
985
1038
|
if (default_slot.p && (!current || dirty & /*$$scope*/ 4)) {
|
|
986
1039
|
update_slot_base(
|
|
@@ -1006,6 +1059,8 @@ function create_if_block$3(ctx) {
|
|
|
1006
1059
|
current = false;
|
|
1007
1060
|
},
|
|
1008
1061
|
d(detaching) {
|
|
1062
|
+
if (detaching) detach(div);
|
|
1063
|
+
if (detaching) detach(t);
|
|
1009
1064
|
if (default_slot) default_slot.d(detaching);
|
|
1010
1065
|
}
|
|
1011
1066
|
};
|
|
@@ -1098,7 +1153,7 @@ function instance$g($$self, $$props, $$invalidate) {
|
|
|
1098
1153
|
class StateItem extends SvelteComponent {
|
|
1099
1154
|
constructor(options) {
|
|
1100
1155
|
super();
|
|
1101
|
-
init(this, options, instance$g, create_fragment$g, safe_not_equal, { path: 0 });
|
|
1156
|
+
init(this, options, instance$g, create_fragment$g, safe_not_equal, { path: 0 }, add_css$d);
|
|
1102
1157
|
}
|
|
1103
1158
|
}
|
|
1104
1159
|
|
|
@@ -2183,8 +2238,8 @@ function create_fragment$b(ctx) {
|
|
|
2183
2238
|
let div1;
|
|
2184
2239
|
let div0;
|
|
2185
2240
|
let current;
|
|
2186
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
2187
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
2241
|
+
const default_slot_template = /*#slots*/ ctx[9].default;
|
|
2242
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[8], null);
|
|
2188
2243
|
|
|
2189
2244
|
return {
|
|
2190
2245
|
c() {
|
|
@@ -2194,7 +2249,12 @@ function create_fragment$b(ctx) {
|
|
|
2194
2249
|
this.h();
|
|
2195
2250
|
},
|
|
2196
2251
|
l(nodes) {
|
|
2197
|
-
div1 = claim_element(nodes, "DIV", {
|
|
2252
|
+
div1 = claim_element(nodes, "DIV", {
|
|
2253
|
+
class: true,
|
|
2254
|
+
"data-grid-item-id": true,
|
|
2255
|
+
style: true
|
|
2256
|
+
});
|
|
2257
|
+
|
|
2198
2258
|
var div1_nodes = children(div1);
|
|
2199
2259
|
div0 = claim_element(div1_nodes, "DIV", { class: true });
|
|
2200
2260
|
var div0_nodes = children(div0);
|
|
@@ -2206,6 +2266,7 @@ function create_fragment$b(ctx) {
|
|
|
2206
2266
|
h() {
|
|
2207
2267
|
attr(div0, "class", "grid-item-inner svelte-n7kdl3");
|
|
2208
2268
|
attr(div1, "class", "grid-item svelte-n7kdl3");
|
|
2269
|
+
attr(div1, "data-grid-item-id", /*gridItemId*/ ctx[1]);
|
|
2209
2270
|
attr(div1, "style", /*_style*/ ctx[0]);
|
|
2210
2271
|
},
|
|
2211
2272
|
m(target, anchor) {
|
|
@@ -2220,15 +2281,15 @@ function create_fragment$b(ctx) {
|
|
|
2220
2281
|
},
|
|
2221
2282
|
p(ctx, [dirty]) {
|
|
2222
2283
|
if (default_slot) {
|
|
2223
|
-
if (default_slot.p && (!current || dirty & /*$$scope*/
|
|
2284
|
+
if (default_slot.p && (!current || dirty & /*$$scope*/ 256)) {
|
|
2224
2285
|
update_slot_base(
|
|
2225
2286
|
default_slot,
|
|
2226
2287
|
default_slot_template,
|
|
2227
2288
|
ctx,
|
|
2228
|
-
/*$$scope*/ ctx[
|
|
2289
|
+
/*$$scope*/ ctx[8],
|
|
2229
2290
|
!current
|
|
2230
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
2231
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
2291
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[8])
|
|
2292
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[8], dirty, null),
|
|
2232
2293
|
null
|
|
2233
2294
|
);
|
|
2234
2295
|
}
|
|
@@ -2263,23 +2324,30 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
2263
2324
|
let { y2 } = $$props;
|
|
2264
2325
|
let { z } = $$props;
|
|
2265
2326
|
let { background = 'transparent' } = $$props;
|
|
2327
|
+
let gridItemIdRaw = `${y1}-${x1}-${y2}-${x2}`;
|
|
2328
|
+
|
|
2329
|
+
if (z) {
|
|
2330
|
+
gridItemIdRaw += `-${z}`;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
const gridItemId = hashCode(gridItemIdRaw);
|
|
2266
2334
|
|
|
2267
2335
|
onMount(() => {
|
|
2268
2336
|
setMiximumZindex(z);
|
|
2269
2337
|
});
|
|
2270
2338
|
|
|
2271
2339
|
$$self.$$set = $$props => {
|
|
2272
|
-
if ('x1' in $$props) $$invalidate(
|
|
2273
|
-
if ('x2' in $$props) $$invalidate(
|
|
2274
|
-
if ('y1' in $$props) $$invalidate(
|
|
2275
|
-
if ('y2' in $$props) $$invalidate(
|
|
2276
|
-
if ('z' in $$props) $$invalidate(
|
|
2277
|
-
if ('background' in $$props) $$invalidate(
|
|
2278
|
-
if ('$$scope' in $$props) $$invalidate(
|
|
2340
|
+
if ('x1' in $$props) $$invalidate(2, x1 = $$props.x1);
|
|
2341
|
+
if ('x2' in $$props) $$invalidate(3, x2 = $$props.x2);
|
|
2342
|
+
if ('y1' in $$props) $$invalidate(4, y1 = $$props.y1);
|
|
2343
|
+
if ('y2' in $$props) $$invalidate(5, y2 = $$props.y2);
|
|
2344
|
+
if ('z' in $$props) $$invalidate(6, z = $$props.z);
|
|
2345
|
+
if ('background' in $$props) $$invalidate(7, background = $$props.background);
|
|
2346
|
+
if ('$$scope' in $$props) $$invalidate(8, $$scope = $$props.$$scope);
|
|
2279
2347
|
};
|
|
2280
2348
|
|
|
2281
2349
|
$$self.$$.update = () => {
|
|
2282
|
-
if ($$self.$$.dirty & /*y1, x1, y2, x2, z, background*/
|
|
2350
|
+
if ($$self.$$.dirty & /*y1, x1, y2, x2, z, background*/ 252) {
|
|
2283
2351
|
$$invalidate(0, _style = [
|
|
2284
2352
|
`grid-area: ${y1 + 1} / ${x1 + 1} / ${y2 + 2} / ${x2 + 2}`,
|
|
2285
2353
|
`z-index: ${z}`,
|
|
@@ -2290,7 +2358,7 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
2290
2358
|
}
|
|
2291
2359
|
};
|
|
2292
2360
|
|
|
2293
|
-
return [_style, x1, x2, y1, y2, z, background, $$scope, slots];
|
|
2361
|
+
return [_style, gridItemId, x1, x2, y1, y2, z, background, $$scope, slots];
|
|
2294
2362
|
}
|
|
2295
2363
|
|
|
2296
2364
|
class GridItem extends SvelteComponent {
|
|
@@ -2304,12 +2372,12 @@ class GridItem extends SvelteComponent {
|
|
|
2304
2372
|
create_fragment$b,
|
|
2305
2373
|
safe_not_equal,
|
|
2306
2374
|
{
|
|
2307
|
-
x1:
|
|
2308
|
-
x2:
|
|
2309
|
-
y1:
|
|
2310
|
-
y2:
|
|
2311
|
-
z:
|
|
2312
|
-
background:
|
|
2375
|
+
x1: 2,
|
|
2376
|
+
x2: 3,
|
|
2377
|
+
y1: 4,
|
|
2378
|
+
y2: 5,
|
|
2379
|
+
z: 6,
|
|
2380
|
+
background: 7
|
|
2313
2381
|
},
|
|
2314
2382
|
add_css$a
|
|
2315
2383
|
);
|
|
@@ -3812,4 +3880,4 @@ class ImageBlock extends SvelteComponent {
|
|
|
3812
3880
|
}
|
|
3813
3881
|
}
|
|
3814
3882
|
|
|
3815
|
-
export { ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, Alignments, AnimationStyles, BackgroundSizes,
|
|
3883
|
+
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 };
|
package/dist/index.es.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ type OperationArgumentTypes = {
|
|
|
78
78
|
State: string;
|
|
79
79
|
Url: string;
|
|
80
80
|
Handler: string;
|
|
81
|
+
Trigger: string;
|
|
81
82
|
};
|
|
82
83
|
type OperationArgumentType = keyof OperationArgumentTypes;
|
|
83
84
|
type BaseOperationOptions = ReadonlyArray<{
|
|
@@ -127,6 +128,10 @@ declare const OnClickOperationOptions: readonly [
|
|
|
127
128
|
{
|
|
128
129
|
readonly operation: "closeApp";
|
|
129
130
|
readonly args: readonly [
|
|
131
|
+
{
|
|
132
|
+
readonly type: "Trigger";
|
|
133
|
+
readonly default: "button";
|
|
134
|
+
}
|
|
130
135
|
];
|
|
131
136
|
},
|
|
132
137
|
{
|
|
@@ -235,15 +240,14 @@ type OPTIONS = {
|
|
|
235
240
|
isPreview?: boolean;
|
|
236
241
|
initialState?: string;
|
|
237
242
|
};
|
|
243
|
+
type CloseTrigger = "button" | "overlay";
|
|
238
244
|
type ActionEventHandler = (...args: any[]) => any | Promise<any>;
|
|
239
|
-
declare const
|
|
240
|
-
ALL_ACTION_ID: string;
|
|
241
|
-
STATE_EVENT: string;
|
|
242
|
-
};
|
|
245
|
+
declare const ALL_ACTION_ID = "KARTE_ALL_ACTION_ID";
|
|
243
246
|
declare const actionId: string;
|
|
244
247
|
declare const ACTION_SHOW_EVENT: string;
|
|
245
248
|
declare const ACTION_CLOSE_EVENT: string;
|
|
246
249
|
declare const ACTION_DESTROY_EVENT: string;
|
|
250
|
+
declare const ACTION_CHANGE_STATE_EVENT: string;
|
|
247
251
|
// Store to handle current state ID
|
|
248
252
|
declare const state: Store<string>;
|
|
249
253
|
// Store to handle all state IDs
|
|
@@ -284,7 +288,7 @@ declare const setMiximumZindex: (zindex?: number) => void;
|
|
|
284
288
|
declare const none: () => () => void;
|
|
285
289
|
declare const moveTo: (to: string) => () => void;
|
|
286
290
|
declare const linkTo: (to: string, targetBlank?: boolean) => () => void;
|
|
287
|
-
declare const closeApp: () => () => void;
|
|
291
|
+
declare const closeApp: (trigger: CloseTrigger) => () => void;
|
|
288
292
|
declare const runScript: (handlerName: string) => () => void;
|
|
289
293
|
declare const execOnClickOperation: (onClickOperation: OnClickOperation) => void;
|
|
290
294
|
declare const haveFunction: (onClickOperation: OnClickOperation) => boolean;
|
|
@@ -351,6 +355,14 @@ declare function applyGlobalCss(css: string): Promise<any>;
|
|
|
351
355
|
* @param {string} href Link of style file
|
|
352
356
|
*/
|
|
353
357
|
declare function loadGlobalStyle(href: string): Promise<any>;
|
|
358
|
+
/**
|
|
359
|
+
* {@link hashCode} generate hash with FNV-1a hash
|
|
360
|
+
*
|
|
361
|
+
* @param {string} s Inputed string
|
|
362
|
+
* @return {string} Hashed string
|
|
363
|
+
* @see https://stackoverflow.com/a/22429679
|
|
364
|
+
*/
|
|
365
|
+
declare function hashCode(s: string): string;
|
|
354
366
|
declare const handleFocus: (node: HTMLElement | null) => (e: any) => void;
|
|
355
367
|
declare const setPreviousFocus: () => void;
|
|
356
368
|
declare const handleKeydown: (handlers: {
|
|
@@ -441,7 +453,7 @@ interface ActionOptions<Props, Variables> {
|
|
|
441
453
|
*
|
|
442
454
|
* @default () => {}
|
|
443
455
|
*/
|
|
444
|
-
onClose?: (props: ActionProps<Props, Variables
|
|
456
|
+
onClose?: (props: ActionProps<Props, Variables>, trigger: CloseTrigger) => void | Promise<void>;
|
|
445
457
|
/**
|
|
446
458
|
* {@link onClose} function to hook the phase of changing action state in KARTE action.
|
|
447
459
|
*
|
|
@@ -488,7 +500,7 @@ declare function show(): void;
|
|
|
488
500
|
* Close KARTE action
|
|
489
501
|
*/
|
|
490
502
|
declare function close(): void;
|
|
491
|
-
declare const KARTE_ACTION_ROOT = "karte-
|
|
503
|
+
declare const KARTE_ACTION_ROOT = "karte-action-root";
|
|
492
504
|
declare const KARTE_ACTION_RID = "karte-action-rid";
|
|
493
505
|
declare function ensureActionRoot(useShadow?: boolean): ShadowRoot | HTMLElement;
|
|
494
506
|
/**
|
|
@@ -505,12 +517,13 @@ fn: (props: ActionProps<Props, Variables>) => void | Promise<void>): void;
|
|
|
505
517
|
* {@link onClose} function to set the function to hook the phase before closing action.
|
|
506
518
|
*
|
|
507
519
|
* @param {(props: ActionProps<Props, Variables>) => void | Promise<void>} fn Callback
|
|
520
|
+
* @param {ClosePlace} fn Callback
|
|
508
521
|
*/
|
|
509
522
|
declare function onClose<Props extends _Props, Variables>(/**
|
|
510
523
|
* @param {ActionProps<Props, Variables>} props Properties of KARTE action
|
|
511
524
|
* @returns {void|Promise<void>}
|
|
512
525
|
*/
|
|
513
|
-
fn: (props: ActionProps<Props, Variables
|
|
526
|
+
fn: (props: ActionProps<Props, Variables>, trigger: CloseTrigger) => void | Promise<void>): void;
|
|
514
527
|
/**
|
|
515
528
|
* {@link onDestory} function to set the function to hook the phase before destroying action.
|
|
516
529
|
*
|
|
@@ -533,6 +546,9 @@ declare function onChangeState<Props extends _Props, Variables>(/**
|
|
|
533
546
|
*/
|
|
534
547
|
fn: (props: ActionProps<Props, Variables>, newState: string) => void | Promise<void>): void;
|
|
535
548
|
declare const h: (type: string, props: any, ...children: Array<any>) => HTMLElement;
|
|
549
|
+
/**
|
|
550
|
+
* @deprecated
|
|
551
|
+
*/
|
|
536
552
|
declare function createFog({ color, opacity, zIndex, onclick }: {
|
|
537
553
|
color?: string;
|
|
538
554
|
opacity?: string;
|
|
@@ -544,6 +560,7 @@ declare function createFog({ color, opacity, zIndex, onclick }: {
|
|
|
544
560
|
};
|
|
545
561
|
type EmbedLogic = "replace" | "append" | "prepend" | "after" | "before";
|
|
546
562
|
declare function embed(target: HTMLElement, replace: HTMLElement, embed_method: EmbedLogic): void;
|
|
563
|
+
declare function getActionShadowRoot(): ShadowRoot | null;
|
|
547
564
|
/**
|
|
548
565
|
* {@link applyCss} apply CSS to KARTE action.
|
|
549
566
|
*
|
|
@@ -605,7 +622,7 @@ declare const collection: (config: {
|
|
|
605
622
|
} | null | undefined, cb: (err: Error | null, items?: any) => void): void;
|
|
606
623
|
set(key: string, value: string, cb: (err: Error | null) => void): void;
|
|
607
624
|
};
|
|
608
|
-
export { Store, getStoreState, ActionEventHandler,
|
|
625
|
+
export { Store, getStoreState, 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, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getTransform, getMarginStyle, 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, NOOP, 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 };
|
|
609
626
|
export { default as State } from './components/State.svelte';
|
|
610
627
|
export { default as StateItem } from './components/StateItem.svelte';
|
|
611
628
|
export { default as Modal } from './components/Modal.svelte';
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { writable, get } from 'svelte/store';
|
|
2
2
|
import { linear, elasticOut, cubicOut } from 'svelte/easing';
|
|
3
|
-
import { SvelteComponent, init, safe_not_equal, append_styles, create_slot, create_component, space, mount_component, insert, update_slot_base, get_all_dirty_from_scope, get_slot_changes, transition_in, transition_out, destroy_component, detach, empty, group_outros, check_outros, component_subscribe,
|
|
3
|
+
import { SvelteComponent, init, safe_not_equal, append_styles, create_slot, create_component, space, mount_component, insert, update_slot_base, get_all_dirty_from_scope, get_slot_changes, transition_in, transition_out, destroy_component, detach, empty, group_outros, check_outros, component_subscribe, element, attr, noop, listen, is_function, append, add_render_callback, create_in_transition, svg_element, binding_callbacks, destroy_each, text, set_data, src_url_equal, null_to_empty } from 'svelte/internal';
|
|
4
4
|
import { createEventDispatcher, onMount, onDestroy as onDestroy$1, setContext, getContext } from 'svelte';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -133,15 +133,13 @@ function randStr(digit = 8) {
|
|
|
133
133
|
* UIから選択できる関数
|
|
134
134
|
*/
|
|
135
135
|
const getStoreState = get;
|
|
136
|
-
const
|
|
137
|
-
ALL_ACTION_ID: 'KARTE_ALL_ACTION_ID',
|
|
138
|
-
STATE_EVENT: 'KARTE-ACTION-CHANGE-STATE',
|
|
139
|
-
};
|
|
136
|
+
const ALL_ACTION_ID = 'KARTE_ALL_ACTION_ID';
|
|
140
137
|
const functionOptions = writable({});
|
|
141
138
|
const actionId = randStr();
|
|
142
139
|
const ACTION_SHOW_EVENT = `KARTE-ACTION-SHOW-${actionId}`;
|
|
143
140
|
const ACTION_CLOSE_EVENT = `KARTE-ACTION-CLOSE-${actionId}`;
|
|
144
141
|
const ACTION_DESTROY_EVENT = `KARTE-ACTION-DESTROY-${actionId}`;
|
|
142
|
+
const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
|
|
145
143
|
// Store to handle current state ID
|
|
146
144
|
const state = writable('/');
|
|
147
145
|
// Store to handle all state IDs
|
|
@@ -169,7 +167,7 @@ const setAutoStart = (on = true) => {
|
|
|
169
167
|
stopped.set(!on);
|
|
170
168
|
};
|
|
171
169
|
const setState = (event) => {
|
|
172
|
-
if (event.detail.actionId === actionId || event.detail.actionId ===
|
|
170
|
+
if (event.detail.actionId === actionId || event.detail.actionId === ALL_ACTION_ID) {
|
|
173
171
|
state.set(event.detail.to);
|
|
174
172
|
}
|
|
175
173
|
};
|
|
@@ -200,7 +198,7 @@ const setMiximumZindex = (zindex) => {
|
|
|
200
198
|
const none = () => () => { };
|
|
201
199
|
const moveTo = (to) => () => {
|
|
202
200
|
send_event('_message_state_changed', { state: to });
|
|
203
|
-
window.dispatchEvent(new CustomEvent(
|
|
201
|
+
window.dispatchEvent(new CustomEvent(ACTION_CHANGE_STATE_EVENT, { detail: { to, actionId } }));
|
|
204
202
|
};
|
|
205
203
|
const linkTo = (to, targetBlank = true) => () => {
|
|
206
204
|
send_event('message_click', { url: to });
|
|
@@ -211,8 +209,9 @@ const linkTo = (to, targetBlank = true) => () => {
|
|
|
211
209
|
location.href = to;
|
|
212
210
|
}
|
|
213
211
|
};
|
|
214
|
-
const closeApp = () => () => {
|
|
215
|
-
send_event('message_close',
|
|
212
|
+
const closeApp = (trigger) => () => {
|
|
213
|
+
send_event('message_close', { trigger });
|
|
214
|
+
window.dispatchEvent(new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger } }));
|
|
216
215
|
closed.set(true);
|
|
217
216
|
};
|
|
218
217
|
const runScript = (handlerName) => () => {
|
|
@@ -235,7 +234,7 @@ const execOnClickOperation = (onClickOperation) => {
|
|
|
235
234
|
moveTo(...onClickOperation.args)();
|
|
236
235
|
}
|
|
237
236
|
else if (onClickOperation.operation === 'closeApp') {
|
|
238
|
-
closeApp()();
|
|
237
|
+
closeApp(onClickOperation.args[0] || 'button')();
|
|
239
238
|
}
|
|
240
239
|
else if (onClickOperation.operation === 'runScript') {
|
|
241
240
|
runScript(onClickOperation.args[0])();
|
|
@@ -350,6 +349,22 @@ async function loadGlobalStyle(href) {
|
|
|
350
349
|
link.addEventListener('error', () => reject(link));
|
|
351
350
|
});
|
|
352
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* {@link hashCode} generate hash with FNV-1a hash
|
|
354
|
+
*
|
|
355
|
+
* @param {string} s Inputed string
|
|
356
|
+
* @return {string} Hashed string
|
|
357
|
+
* @see https://stackoverflow.com/a/22429679
|
|
358
|
+
*/
|
|
359
|
+
function hashCode(s) {
|
|
360
|
+
const SEED = 0x41653150;
|
|
361
|
+
let hash = SEED;
|
|
362
|
+
Array.from(s).forEach((c, index) => {
|
|
363
|
+
hash ^= c.charCodeAt(index);
|
|
364
|
+
hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
|
|
365
|
+
});
|
|
366
|
+
return ('0000000' + (hash >>> 0).toString(16)).substr(-8);
|
|
367
|
+
}
|
|
353
368
|
|
|
354
369
|
const PropTypes = [
|
|
355
370
|
'BooleanKeyword',
|
|
@@ -407,7 +422,7 @@ const DefaultModalPlacement = {
|
|
|
407
422
|
bottom: '0px',
|
|
408
423
|
},
|
|
409
424
|
backgroundOverlay: false,
|
|
410
|
-
backgroundClick: { operation: 'closeApp', args: [] },
|
|
425
|
+
backgroundClick: { operation: 'closeApp', args: ['overlay'] },
|
|
411
426
|
};
|
|
412
427
|
const OnClickOperationOptions = [
|
|
413
428
|
{
|
|
@@ -438,7 +453,12 @@ const OnClickOperationOptions = [
|
|
|
438
453
|
},
|
|
439
454
|
{
|
|
440
455
|
operation: 'closeApp',
|
|
441
|
-
args: [
|
|
456
|
+
args: [
|
|
457
|
+
{
|
|
458
|
+
type: 'Trigger',
|
|
459
|
+
default: 'button',
|
|
460
|
+
},
|
|
461
|
+
],
|
|
442
462
|
},
|
|
443
463
|
{
|
|
444
464
|
operation: 'runScript',
|
|
@@ -570,26 +590,27 @@ function create(App, options = {
|
|
|
570
590
|
}) {
|
|
571
591
|
let app = null;
|
|
572
592
|
const data = { ...options.props, ...options.variables };
|
|
573
|
-
const close = () => {
|
|
593
|
+
const close = (event = {}) => {
|
|
574
594
|
if (!app) {
|
|
575
595
|
return;
|
|
576
596
|
}
|
|
577
597
|
closed.set(true);
|
|
578
|
-
window.removeEventListener(
|
|
598
|
+
window.removeEventListener(ACTION_CHANGE_STATE_EVENT, setState);
|
|
599
|
+
const trigger = event.detail?.trigger ? event.detail?.trigger : 'button';
|
|
579
600
|
if (options.onClose) {
|
|
580
|
-
options.onClose({ send: options.send, data });
|
|
601
|
+
options.onClose({ send: options.send, data }, trigger);
|
|
581
602
|
}
|
|
582
603
|
app.$destroy();
|
|
583
604
|
app = null;
|
|
584
605
|
};
|
|
585
606
|
window.addEventListener(ACTION_CLOSE_EVENT, close);
|
|
586
|
-
const show = () => {
|
|
607
|
+
const show = (_event = {}) => {
|
|
587
608
|
if (app) {
|
|
588
609
|
return;
|
|
589
610
|
}
|
|
590
611
|
options.send('message_open');
|
|
591
612
|
closed.set(false);
|
|
592
|
-
window.addEventListener(
|
|
613
|
+
window.addEventListener(ACTION_CHANGE_STATE_EVENT, setState);
|
|
593
614
|
app = new App({
|
|
594
615
|
target: ensureModalRoot(!false),
|
|
595
616
|
hydrate: false,
|
|
@@ -650,7 +671,7 @@ function create(App, options = {
|
|
|
650
671
|
* Dispatch the event to destroy KARTE action
|
|
651
672
|
*/
|
|
652
673
|
function dispatchDestroyEvent() {
|
|
653
|
-
const event = new
|
|
674
|
+
const event = new CustomEvent(ACTION_DESTROY_EVENT);
|
|
654
675
|
window.dispatchEvent(event);
|
|
655
676
|
}
|
|
656
677
|
/**
|
|
@@ -664,22 +685,25 @@ function destroy() {
|
|
|
664
685
|
* Show KARTE action
|
|
665
686
|
*/
|
|
666
687
|
function show() {
|
|
667
|
-
const event = new
|
|
688
|
+
const event = new CustomEvent(ACTION_SHOW_EVENT);
|
|
668
689
|
window.dispatchEvent(event);
|
|
669
690
|
}
|
|
670
691
|
/**
|
|
671
692
|
* Close KARTE action
|
|
672
693
|
*/
|
|
673
694
|
function close() {
|
|
674
|
-
const event = new
|
|
695
|
+
const event = new CustomEvent(ACTION_CLOSE_EVENT, { detail: { trigger: 'button' } });
|
|
675
696
|
window.dispatchEvent(event);
|
|
676
697
|
}
|
|
677
|
-
const KARTE_ACTION_ROOT = 'karte-
|
|
698
|
+
const KARTE_ACTION_ROOT = 'karte-action-root';
|
|
678
699
|
const KARTE_ACTION_RID = 'karte-action-rid';
|
|
679
700
|
function ensureActionRoot(useShadow = true) {
|
|
680
701
|
let el = document.querySelector(`.${KARTE_MODAL_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
|
681
702
|
if (el == null) {
|
|
682
|
-
el = h('div', {
|
|
703
|
+
el = h('div', {
|
|
704
|
+
class: `${KARTE_ACTION_ROOT} ${KARTE_MODAL_ROOT}`,
|
|
705
|
+
[`data-${KARTE_ACTION_RID}`]: actionId,
|
|
706
|
+
});
|
|
683
707
|
document.body.appendChild(el);
|
|
684
708
|
}
|
|
685
709
|
const isShadow = !!document.body.attachShadow && useShadow;
|
|
@@ -710,6 +734,7 @@ fn) {
|
|
|
710
734
|
* {@link onClose} function to set the function to hook the phase before closing action.
|
|
711
735
|
*
|
|
712
736
|
* @param {(props: ActionProps<Props, Variables>) => void | Promise<void>} fn Callback
|
|
737
|
+
* @param {ClosePlace} fn Callback
|
|
713
738
|
*/
|
|
714
739
|
function onClose(
|
|
715
740
|
/**
|
|
@@ -771,6 +796,9 @@ const h = (type, props, ...children) => {
|
|
|
771
796
|
}
|
|
772
797
|
return el;
|
|
773
798
|
};
|
|
799
|
+
/**
|
|
800
|
+
* @deprecated
|
|
801
|
+
*/
|
|
774
802
|
function createFog({ color = '#000', opacity = '50%', zIndex = 999, onclick, }) {
|
|
775
803
|
const root = ensureModalRoot(false);
|
|
776
804
|
if (root.querySelector('.__krt-fog')) {
|
|
@@ -859,7 +887,7 @@ async function loadStyle(href) {
|
|
|
859
887
|
}
|
|
860
888
|
// -------- The following codes are deprecated --------
|
|
861
889
|
const showModal = create; // @deprecated
|
|
862
|
-
const KARTE_MODAL_ROOT =
|
|
890
|
+
const KARTE_MODAL_ROOT = 'karte-modal-root'; // @deprecated
|
|
863
891
|
const ensureModalRoot = ensureActionRoot; // @deprecated
|
|
864
892
|
/**
|
|
865
893
|
* Create an application instance
|
|
@@ -974,14 +1002,14 @@ function request(url, data, cb) {
|
|
|
974
1002
|
|
|
975
1003
|
/* src/components/Normalize.svelte generated by Svelte v3.53.1 */
|
|
976
1004
|
|
|
977
|
-
function add_css$
|
|
1005
|
+
function add_css$e(target) {
|
|
978
1006
|
append_styles(target, "svelte-tr4qnr", "@import 'https://esm.sh/normalize.css';");
|
|
979
1007
|
}
|
|
980
1008
|
|
|
981
1009
|
class Normalize extends SvelteComponent {
|
|
982
1010
|
constructor(options) {
|
|
983
1011
|
super();
|
|
984
|
-
init(this, options, null, null, safe_not_equal, {}, add_css$
|
|
1012
|
+
init(this, options, null, null, safe_not_equal, {}, add_css$e);
|
|
985
1013
|
}
|
|
986
1014
|
}
|
|
987
1015
|
|
|
@@ -1065,16 +1093,30 @@ class State extends SvelteComponent {
|
|
|
1065
1093
|
|
|
1066
1094
|
/* src/components/StateItem.svelte generated by Svelte v3.53.1 */
|
|
1067
1095
|
|
|
1096
|
+
function add_css$d(target) {
|
|
1097
|
+
append_styles(target, "svelte-2qb6dm", ".state-item.svelte-2qb6dm{position:absolute;display:none}");
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// (14:0) {#if $state === path}
|
|
1068
1101
|
function create_if_block$3(ctx) {
|
|
1102
|
+
let div;
|
|
1103
|
+
let t;
|
|
1069
1104
|
let current;
|
|
1070
1105
|
const default_slot_template = /*#slots*/ ctx[3].default;
|
|
1071
1106
|
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[2], null);
|
|
1072
1107
|
|
|
1073
1108
|
return {
|
|
1074
1109
|
c() {
|
|
1110
|
+
div = element("div");
|
|
1111
|
+
t = space();
|
|
1075
1112
|
if (default_slot) default_slot.c();
|
|
1113
|
+
attr(div, "data-state-path", /*path*/ ctx[0]);
|
|
1114
|
+
attr(div, "class", "state-item svelte-2qb6dm");
|
|
1076
1115
|
},
|
|
1077
1116
|
m(target, anchor) {
|
|
1117
|
+
insert(target, div, anchor);
|
|
1118
|
+
insert(target, t, anchor);
|
|
1119
|
+
|
|
1078
1120
|
if (default_slot) {
|
|
1079
1121
|
default_slot.m(target, anchor);
|
|
1080
1122
|
}
|
|
@@ -1082,6 +1124,10 @@ function create_if_block$3(ctx) {
|
|
|
1082
1124
|
current = true;
|
|
1083
1125
|
},
|
|
1084
1126
|
p(ctx, dirty) {
|
|
1127
|
+
if (!current || dirty & /*path*/ 1) {
|
|
1128
|
+
attr(div, "data-state-path", /*path*/ ctx[0]);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1085
1131
|
if (default_slot) {
|
|
1086
1132
|
if (default_slot.p && (!current || dirty & /*$$scope*/ 4)) {
|
|
1087
1133
|
update_slot_base(
|
|
@@ -1107,6 +1153,8 @@ function create_if_block$3(ctx) {
|
|
|
1107
1153
|
current = false;
|
|
1108
1154
|
},
|
|
1109
1155
|
d(detaching) {
|
|
1156
|
+
if (detaching) detach(div);
|
|
1157
|
+
if (detaching) detach(t);
|
|
1110
1158
|
if (default_slot) default_slot.d(detaching);
|
|
1111
1159
|
}
|
|
1112
1160
|
};
|
|
@@ -1195,7 +1243,7 @@ function instance$g($$self, $$props, $$invalidate) {
|
|
|
1195
1243
|
class StateItem extends SvelteComponent {
|
|
1196
1244
|
constructor(options) {
|
|
1197
1245
|
super();
|
|
1198
|
-
init(this, options, instance$g, create_fragment$g, safe_not_equal, { path: 0 });
|
|
1246
|
+
init(this, options, instance$g, create_fragment$g, safe_not_equal, { path: 0 }, add_css$d);
|
|
1199
1247
|
}
|
|
1200
1248
|
}
|
|
1201
1249
|
|
|
@@ -2191,8 +2239,8 @@ function create_fragment$b(ctx) {
|
|
|
2191
2239
|
let div1;
|
|
2192
2240
|
let div0;
|
|
2193
2241
|
let current;
|
|
2194
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
2195
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
2242
|
+
const default_slot_template = /*#slots*/ ctx[9].default;
|
|
2243
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[8], null);
|
|
2196
2244
|
|
|
2197
2245
|
return {
|
|
2198
2246
|
c() {
|
|
@@ -2201,6 +2249,7 @@ function create_fragment$b(ctx) {
|
|
|
2201
2249
|
if (default_slot) default_slot.c();
|
|
2202
2250
|
attr(div0, "class", "grid-item-inner svelte-n7kdl3");
|
|
2203
2251
|
attr(div1, "class", "grid-item svelte-n7kdl3");
|
|
2252
|
+
attr(div1, "data-grid-item-id", /*gridItemId*/ ctx[1]);
|
|
2204
2253
|
attr(div1, "style", /*_style*/ ctx[0]);
|
|
2205
2254
|
},
|
|
2206
2255
|
m(target, anchor) {
|
|
@@ -2215,15 +2264,15 @@ function create_fragment$b(ctx) {
|
|
|
2215
2264
|
},
|
|
2216
2265
|
p(ctx, [dirty]) {
|
|
2217
2266
|
if (default_slot) {
|
|
2218
|
-
if (default_slot.p && (!current || dirty & /*$$scope*/
|
|
2267
|
+
if (default_slot.p && (!current || dirty & /*$$scope*/ 256)) {
|
|
2219
2268
|
update_slot_base(
|
|
2220
2269
|
default_slot,
|
|
2221
2270
|
default_slot_template,
|
|
2222
2271
|
ctx,
|
|
2223
|
-
/*$$scope*/ ctx[
|
|
2272
|
+
/*$$scope*/ ctx[8],
|
|
2224
2273
|
!current
|
|
2225
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
2226
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
2274
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[8])
|
|
2275
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[8], dirty, null),
|
|
2227
2276
|
null
|
|
2228
2277
|
);
|
|
2229
2278
|
}
|
|
@@ -2258,23 +2307,30 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
2258
2307
|
let { y2 } = $$props;
|
|
2259
2308
|
let { z } = $$props;
|
|
2260
2309
|
let { background = 'transparent' } = $$props;
|
|
2310
|
+
let gridItemIdRaw = `${y1}-${x1}-${y2}-${x2}`;
|
|
2311
|
+
|
|
2312
|
+
if (z) {
|
|
2313
|
+
gridItemIdRaw += `-${z}`;
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
const gridItemId = hashCode(gridItemIdRaw);
|
|
2261
2317
|
|
|
2262
2318
|
onMount(() => {
|
|
2263
2319
|
setMiximumZindex(z);
|
|
2264
2320
|
});
|
|
2265
2321
|
|
|
2266
2322
|
$$self.$$set = $$props => {
|
|
2267
|
-
if ('x1' in $$props) $$invalidate(
|
|
2268
|
-
if ('x2' in $$props) $$invalidate(
|
|
2269
|
-
if ('y1' in $$props) $$invalidate(
|
|
2270
|
-
if ('y2' in $$props) $$invalidate(
|
|
2271
|
-
if ('z' in $$props) $$invalidate(
|
|
2272
|
-
if ('background' in $$props) $$invalidate(
|
|
2273
|
-
if ('$$scope' in $$props) $$invalidate(
|
|
2323
|
+
if ('x1' in $$props) $$invalidate(2, x1 = $$props.x1);
|
|
2324
|
+
if ('x2' in $$props) $$invalidate(3, x2 = $$props.x2);
|
|
2325
|
+
if ('y1' in $$props) $$invalidate(4, y1 = $$props.y1);
|
|
2326
|
+
if ('y2' in $$props) $$invalidate(5, y2 = $$props.y2);
|
|
2327
|
+
if ('z' in $$props) $$invalidate(6, z = $$props.z);
|
|
2328
|
+
if ('background' in $$props) $$invalidate(7, background = $$props.background);
|
|
2329
|
+
if ('$$scope' in $$props) $$invalidate(8, $$scope = $$props.$$scope);
|
|
2274
2330
|
};
|
|
2275
2331
|
|
|
2276
2332
|
$$self.$$.update = () => {
|
|
2277
|
-
if ($$self.$$.dirty & /*y1, x1, y2, x2, z, background*/
|
|
2333
|
+
if ($$self.$$.dirty & /*y1, x1, y2, x2, z, background*/ 252) {
|
|
2278
2334
|
$$invalidate(0, _style = [
|
|
2279
2335
|
`grid-area: ${y1 + 1} / ${x1 + 1} / ${y2 + 2} / ${x2 + 2}`,
|
|
2280
2336
|
`z-index: ${z}`,
|
|
@@ -2285,7 +2341,7 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
2285
2341
|
}
|
|
2286
2342
|
};
|
|
2287
2343
|
|
|
2288
|
-
return [_style, x1, x2, y1, y2, z, background, $$scope, slots];
|
|
2344
|
+
return [_style, gridItemId, x1, x2, y1, y2, z, background, $$scope, slots];
|
|
2289
2345
|
}
|
|
2290
2346
|
|
|
2291
2347
|
class GridItem extends SvelteComponent {
|
|
@@ -2299,12 +2355,12 @@ class GridItem extends SvelteComponent {
|
|
|
2299
2355
|
create_fragment$b,
|
|
2300
2356
|
safe_not_equal,
|
|
2301
2357
|
{
|
|
2302
|
-
x1:
|
|
2303
|
-
x2:
|
|
2304
|
-
y1:
|
|
2305
|
-
y2:
|
|
2306
|
-
z:
|
|
2307
|
-
background:
|
|
2358
|
+
x1: 2,
|
|
2359
|
+
x2: 3,
|
|
2360
|
+
y1: 4,
|
|
2361
|
+
y2: 5,
|
|
2362
|
+
z: 6,
|
|
2363
|
+
background: 7
|
|
2308
2364
|
},
|
|
2309
2365
|
add_css$a
|
|
2310
2366
|
);
|
|
@@ -3658,4 +3714,4 @@ class ImageBlock extends SvelteComponent {
|
|
|
3658
3714
|
}
|
|
3659
3715
|
}
|
|
3660
3716
|
|
|
3661
|
-
export { ACTION_CLOSE_EVENT, ACTION_DESTROY_EVENT, ACTION_SHOW_EVENT, Alignments, AnimationStyles, BackgroundSizes,
|
|
3717
|
+
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 };
|