@plaidev/karte-action-sdk 1.1.73 → 1.1.74
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 +31 -5
- package/dist/hydrate/index.es.js +60 -17
- package/dist/index.es.d.ts +31 -5
- package/dist/index.es.js +60 -17
- package/package.json +1 -1
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* UIから選択できる関数
|
|
3
|
+
*/
|
|
4
|
+
import { get as get_ } from "svelte/store";
|
|
5
|
+
import { Writable as Writable_ } from "svelte/store";
|
|
2
6
|
import { SvelteComponentDev } from "svelte/internal";
|
|
3
7
|
declare const PropTypes: readonly [
|
|
4
8
|
"BooleanKeyword",
|
|
@@ -73,6 +77,7 @@ type OperationArgumentTypes = {
|
|
|
73
77
|
NumberKeyword: number;
|
|
74
78
|
State: string;
|
|
75
79
|
Url: string;
|
|
80
|
+
Handler: string;
|
|
76
81
|
};
|
|
77
82
|
type OperationArgumentType = keyof OperationArgumentTypes;
|
|
78
83
|
type BaseOperationOptions = ReadonlyArray<{
|
|
@@ -123,6 +128,15 @@ declare const OnClickOperationOptions: readonly [
|
|
|
123
128
|
readonly operation: "closeApp";
|
|
124
129
|
readonly args: readonly [
|
|
125
130
|
];
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
readonly operation: "runScript";
|
|
134
|
+
readonly args: readonly [
|
|
135
|
+
{
|
|
136
|
+
readonly type: "Handler";
|
|
137
|
+
readonly default: "";
|
|
138
|
+
}
|
|
139
|
+
];
|
|
126
140
|
}
|
|
127
141
|
];
|
|
128
142
|
type OnClickOperation = ConvertOperationOptions<typeof OnClickOperationOptions>;
|
|
@@ -177,19 +191,30 @@ declare const Overflows: string[];
|
|
|
177
191
|
type Overflow = typeof Overflows[number];
|
|
178
192
|
type Style = string;
|
|
179
193
|
type StateName = string;
|
|
194
|
+
// Svelteの機能の隠蔽
|
|
195
|
+
type Store<T> = Writable_<T>;
|
|
196
|
+
declare const getStoreState: typeof get_;
|
|
180
197
|
type OPTIONS = {
|
|
181
198
|
send?: (event_name: string, values?: any) => void;
|
|
182
199
|
isPreview?: boolean;
|
|
183
200
|
initialState?: string;
|
|
184
201
|
};
|
|
202
|
+
type ActionEventHandler = (...args: any[]) => any | Promise<any>;
|
|
185
203
|
declare const CONSTANTS: {
|
|
186
204
|
ALL_ACTION_ID: string;
|
|
187
205
|
STATE_EVENT: string;
|
|
188
206
|
};
|
|
189
207
|
declare const actionId: string;
|
|
190
|
-
|
|
191
|
-
declare const
|
|
192
|
-
|
|
208
|
+
// 現在のステートのストア
|
|
209
|
+
declare const state: Store<string>;
|
|
210
|
+
// アクションの表示を管理するストア
|
|
211
|
+
declare const closed: Store<boolean>;
|
|
212
|
+
// グリッドの最大z-indexを管理するストア
|
|
213
|
+
declare const maximumZindex: Store<number>;
|
|
214
|
+
// カスタムイベントハンドラを管理するストア
|
|
215
|
+
declare const customHandlers: Store<{
|
|
216
|
+
[key: string]: ActionEventHandler;
|
|
217
|
+
}>;
|
|
193
218
|
declare const initialize: (options?: OPTIONS) => () => void;
|
|
194
219
|
declare const finalize: () => void;
|
|
195
220
|
declare const send_event: (event_name: string, values?: any) => void;
|
|
@@ -200,6 +225,7 @@ declare const none: () => () => void;
|
|
|
200
225
|
declare const moveTo: (to: string) => () => void;
|
|
201
226
|
declare const linkTo: (to: string, targetBlank?: boolean) => () => void;
|
|
202
227
|
declare const closeApp: () => () => void;
|
|
228
|
+
declare const runScript: (handlerName: string) => () => void;
|
|
203
229
|
declare const execOnClickOperation: (onClickOperation: OnClickOperation) => void;
|
|
204
230
|
declare const haveFunction: (onClickOperation: OnClickOperation) => boolean;
|
|
205
231
|
/**
|
|
@@ -402,7 +428,7 @@ declare const collection: (config: {
|
|
|
402
428
|
} | null | undefined, cb: (err: Error | null, items?: any) => void): void;
|
|
403
429
|
set(key: string, value: string, cb: (err: Error | null) => void): void;
|
|
404
430
|
};
|
|
405
|
-
export { CONSTANTS, actionId, state, closed, maximumZindex, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, execOnClickOperation, haveFunction, customAnimation, 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, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ModalOptions, showModal, KARTE_MODAL_ROOT, KARTE_ACTION_RID, ensureModalRoot, h, createFog, EmbedLogic, embed, AppOptions, App, createApp, collection };
|
|
431
|
+
export { Store, getStoreState, ActionEventHandler, CONSTANTS, actionId, state, closed, maximumZindex, customHandlers, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, runScript, execOnClickOperation, haveFunction, customAnimation, 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, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ModalOptions, showModal, KARTE_MODAL_ROOT, KARTE_ACTION_RID, ensureModalRoot, h, createFog, EmbedLogic, embed, AppOptions, App, createApp, collection };
|
|
406
432
|
export { default as State } from './components/State.svelte';
|
|
407
433
|
export { default as StateItem } from './components/StateItem.svelte';
|
|
408
434
|
export { default as Modal } from './components/Modal.svelte';
|
package/dist/hydrate/index.es.js
CHANGED
|
@@ -132,15 +132,21 @@ function randStr(digit = 8) {
|
|
|
132
132
|
/**
|
|
133
133
|
* UIから選択できる関数
|
|
134
134
|
*/
|
|
135
|
+
const getStoreState = get;
|
|
135
136
|
const CONSTANTS = {
|
|
136
137
|
ALL_ACTION_ID: 'KARTE_ALL_ACTION_ID',
|
|
137
138
|
STATE_EVENT: 'KARTE-ACTION-CHANGE-STATE',
|
|
138
139
|
};
|
|
139
140
|
const functionOptions = writable({});
|
|
140
141
|
const actionId = randStr();
|
|
142
|
+
// 現在のステートのストア
|
|
141
143
|
const state = writable('/');
|
|
144
|
+
// アクションの表示を管理するストア
|
|
142
145
|
const closed = writable(false);
|
|
146
|
+
// グリッドの最大z-indexを管理するストア
|
|
143
147
|
const maximumZindex = writable(0);
|
|
148
|
+
// カスタムイベントハンドラを管理するストア
|
|
149
|
+
const customHandlers = writable({});
|
|
144
150
|
const setState = (event) => {
|
|
145
151
|
if (event.detail.actionId === actionId || event.detail.actionId === CONSTANTS.ALL_ACTION_ID) {
|
|
146
152
|
state.set(event.detail.to);
|
|
@@ -160,14 +166,14 @@ const finalize = () => {
|
|
|
160
166
|
functionOptions.set({});
|
|
161
167
|
};
|
|
162
168
|
const send_event = (event_name, values) => {
|
|
163
|
-
const options =
|
|
169
|
+
const options = getStoreState(functionOptions);
|
|
164
170
|
options?.send?.(event_name, values);
|
|
165
171
|
};
|
|
166
172
|
const isPreview = () => {
|
|
167
173
|
return true;
|
|
168
174
|
};
|
|
169
175
|
const setMiximumZindex = (zindex) => {
|
|
170
|
-
if (!zindex || zindex <
|
|
176
|
+
if (!zindex || zindex < getStoreState(maximumZindex))
|
|
171
177
|
return;
|
|
172
178
|
maximumZindex.set(zindex);
|
|
173
179
|
};
|
|
@@ -190,6 +196,18 @@ const closeApp = () => () => {
|
|
|
190
196
|
send_event('message_close', null);
|
|
191
197
|
closed.set(true);
|
|
192
198
|
};
|
|
199
|
+
const runScript = (handlerName) => () => {
|
|
200
|
+
const handlers = getStoreState(customHandlers);
|
|
201
|
+
const handler = handlers[handlerName];
|
|
202
|
+
if (!handler)
|
|
203
|
+
return;
|
|
204
|
+
try {
|
|
205
|
+
handler();
|
|
206
|
+
}
|
|
207
|
+
catch (e) {
|
|
208
|
+
console.warn('Failed to run custom handler', handlerName, e);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
193
211
|
const execOnClickOperation = (onClickOperation) => {
|
|
194
212
|
if (onClickOperation.operation === 'linkTo') {
|
|
195
213
|
linkTo(...onClickOperation.args)();
|
|
@@ -200,6 +218,9 @@ const execOnClickOperation = (onClickOperation) => {
|
|
|
200
218
|
else if (onClickOperation.operation === 'closeApp') {
|
|
201
219
|
closeApp()();
|
|
202
220
|
}
|
|
221
|
+
else if (onClickOperation.operation === 'runScript') {
|
|
222
|
+
runScript(onClickOperation.args[0])();
|
|
223
|
+
}
|
|
203
224
|
};
|
|
204
225
|
const haveFunction = (onClickOperation) => {
|
|
205
226
|
return onClickOperation.operation !== 'none';
|
|
@@ -272,7 +293,7 @@ const DefaultModalPlacement = {
|
|
|
272
293
|
bottom: '0px',
|
|
273
294
|
},
|
|
274
295
|
backgroundOverlay: false,
|
|
275
|
-
backgroundClick: { operation:
|
|
296
|
+
backgroundClick: { operation: 'closeApp', args: [] },
|
|
276
297
|
};
|
|
277
298
|
const OnClickOperationOptions = [
|
|
278
299
|
{
|
|
@@ -305,6 +326,15 @@ const OnClickOperationOptions = [
|
|
|
305
326
|
operation: 'closeApp',
|
|
306
327
|
args: [],
|
|
307
328
|
},
|
|
329
|
+
{
|
|
330
|
+
operation: 'runScript',
|
|
331
|
+
args: [
|
|
332
|
+
{
|
|
333
|
+
type: 'Handler',
|
|
334
|
+
default: '',
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
},
|
|
308
338
|
];
|
|
309
339
|
const LengthUnits = ['px', 'em', 'rem', 'vw', 'fr', '%'];
|
|
310
340
|
const Justifies = ['flex-start', 'center', 'flex-end'];
|
|
@@ -918,7 +948,7 @@ function add_css$9(target) {
|
|
|
918
948
|
append_styles(target, "svelte-1bxl6mz", ".modal.svelte-1bxl6mz{position:fixed;box-sizing:border-box;z-index:2147483647}.close.svelte-1bxl6mz{position:absolute;display:flex;justify-content:center;align-items:center;background-color:transparent;border:none;cursor:pointer;padding:0;transition:all 0.25s}.close.svelte-1bxl6mz:hover{transform:rotate(90deg)}");
|
|
919
949
|
}
|
|
920
950
|
|
|
921
|
-
// (
|
|
951
|
+
// (130:0) {#if visible}
|
|
922
952
|
function create_if_block$1(ctx) {
|
|
923
953
|
let div;
|
|
924
954
|
let t;
|
|
@@ -928,8 +958,8 @@ function create_if_block$1(ctx) {
|
|
|
928
958
|
let mounted;
|
|
929
959
|
let dispose;
|
|
930
960
|
let if_block = /*closable*/ ctx[13] && create_if_block_1(ctx);
|
|
931
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
932
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
961
|
+
const default_slot_template = /*#slots*/ ctx[27].default;
|
|
962
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], null);
|
|
933
963
|
|
|
934
964
|
return {
|
|
935
965
|
c() {
|
|
@@ -997,15 +1027,15 @@ function create_if_block$1(ctx) {
|
|
|
997
1027
|
}
|
|
998
1028
|
|
|
999
1029
|
if (default_slot) {
|
|
1000
|
-
if (default_slot.p && (!current || dirty & /*$$scope*/
|
|
1030
|
+
if (default_slot.p && (!current || dirty & /*$$scope*/ 67108864)) {
|
|
1001
1031
|
update_slot_base(
|
|
1002
1032
|
default_slot,
|
|
1003
1033
|
default_slot_template,
|
|
1004
1034
|
ctx,
|
|
1005
|
-
/*$$scope*/ ctx[
|
|
1035
|
+
/*$$scope*/ ctx[26],
|
|
1006
1036
|
!current
|
|
1007
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1008
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1037
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
1038
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, null),
|
|
1009
1039
|
null
|
|
1010
1040
|
);
|
|
1011
1041
|
}
|
|
@@ -1047,7 +1077,7 @@ function create_if_block$1(ctx) {
|
|
|
1047
1077
|
};
|
|
1048
1078
|
}
|
|
1049
1079
|
|
|
1050
|
-
// (
|
|
1080
|
+
// (147:4) {#if closable}
|
|
1051
1081
|
function create_if_block_1(ctx) {
|
|
1052
1082
|
let button;
|
|
1053
1083
|
let svg;
|
|
@@ -1146,7 +1176,10 @@ function create_fragment$c(ctx) {
|
|
|
1146
1176
|
}
|
|
1147
1177
|
});
|
|
1148
1178
|
|
|
1149
|
-
backgroundoverray.$on("click",
|
|
1179
|
+
backgroundoverray.$on("click", function () {
|
|
1180
|
+
if (is_function(/*backgroundClick*/ ctx[11])) /*backgroundClick*/ ctx[11].apply(this, arguments);
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1150
1183
|
let if_block = /*visible*/ ctx[6] && create_if_block$1(ctx);
|
|
1151
1184
|
|
|
1152
1185
|
return {
|
|
@@ -1233,6 +1266,7 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1233
1266
|
let close;
|
|
1234
1267
|
let closable;
|
|
1235
1268
|
let backgroundOverray;
|
|
1269
|
+
let backgroundClickFunction;
|
|
1236
1270
|
let backgroundClick;
|
|
1237
1271
|
let overwritePosition;
|
|
1238
1272
|
let overwriteMargin;
|
|
@@ -1262,7 +1296,6 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1262
1296
|
});
|
|
1263
1297
|
|
|
1264
1298
|
onDestroy(() => setPreviousFocus());
|
|
1265
|
-
const click_handler = () => execOnClickOperation(backgroundClick);
|
|
1266
1299
|
|
|
1267
1300
|
function div_binding($$value) {
|
|
1268
1301
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
@@ -1283,7 +1316,7 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1283
1316
|
if ('closeEventName' in $$props) $$invalidate(21, closeEventName = $$props.closeEventName);
|
|
1284
1317
|
if ('closeEventValue' in $$props) $$invalidate(22, closeEventValue = $$props.closeEventValue);
|
|
1285
1318
|
if ('_closeStyle' in $$props) $$invalidate(3, _closeStyle = $$props._closeStyle);
|
|
1286
|
-
if ('$$scope' in $$props) $$invalidate(
|
|
1319
|
+
if ('$$scope' in $$props) $$invalidate(26, $$scope = $$props.$$scope);
|
|
1287
1320
|
};
|
|
1288
1321
|
|
|
1289
1322
|
$$self.$$.update = () => {
|
|
@@ -1318,11 +1351,21 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1318
1351
|
}
|
|
1319
1352
|
|
|
1320
1353
|
if ($$self.$$.dirty & /*placement*/ 524288) {
|
|
1321
|
-
$$invalidate(
|
|
1354
|
+
$$invalidate(25, backgroundClickFunction = placement && placement.backgroundClick != null
|
|
1322
1355
|
? placement.backgroundClick
|
|
1323
1356
|
: DefaultModalPlacement.backgroundClick);
|
|
1324
1357
|
}
|
|
1325
1358
|
|
|
1359
|
+
if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunction*/ 39845888) {
|
|
1360
|
+
$$invalidate(11, backgroundClick = () => {
|
|
1361
|
+
if (closeEventName) {
|
|
1362
|
+
send_event(closeEventName, closeEventValue);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
execOnClickOperation(backgroundClickFunction);
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1326
1369
|
if ($$self.$$.dirty & /*placement*/ 524288) {
|
|
1327
1370
|
$$invalidate(24, overwritePosition = 'center'
|
|
1328
1371
|
);
|
|
@@ -1386,9 +1429,9 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1386
1429
|
closeEventValue,
|
|
1387
1430
|
overwriteMargin,
|
|
1388
1431
|
overwritePosition,
|
|
1432
|
+
backgroundClickFunction,
|
|
1389
1433
|
$$scope,
|
|
1390
1434
|
slots,
|
|
1391
|
-
click_handler,
|
|
1392
1435
|
div_binding
|
|
1393
1436
|
];
|
|
1394
1437
|
}
|
|
@@ -3177,4 +3220,4 @@ class ImageBlock extends SvelteComponent {
|
|
|
3177
3220
|
}
|
|
3178
3221
|
}
|
|
3179
3222
|
|
|
3180
|
-
export { Alignments, AnimationStyles, BackgroundSizes, CONSTANTS, Cursors, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_MODAL_ROOT, LengthUnits, MediaQueries, Modal, ModalPositions, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, closeApp, closed, collection, createApp, createFog, customAnimation, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, getTransform, h, handleFocus, handleKeydown, hasSuffix, haveFunction, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, showModal, showOnScroll, showOnTime, state, toBr };
|
|
3223
|
+
export { Alignments, AnimationStyles, BackgroundSizes, CONSTANTS, Cursors, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_MODAL_ROOT, LengthUnits, MediaQueries, Modal, ModalPositions, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, closeApp, closed, collection, createApp, createFog, customAnimation, customHandlers, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, getStoreState, getTransform, h, handleFocus, handleKeydown, hasSuffix, haveFunction, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, runScript, send_event, setMiximumZindex, setPreviousFocus, showModal, showOnScroll, showOnTime, state, toBr };
|
package/dist/index.es.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* UIから選択できる関数
|
|
3
|
+
*/
|
|
4
|
+
import { get as get_ } from "svelte/store";
|
|
5
|
+
import { Writable as Writable_ } from "svelte/store";
|
|
2
6
|
import { SvelteComponentDev } from "svelte/internal";
|
|
3
7
|
declare const PropTypes: readonly [
|
|
4
8
|
"BooleanKeyword",
|
|
@@ -73,6 +77,7 @@ type OperationArgumentTypes = {
|
|
|
73
77
|
NumberKeyword: number;
|
|
74
78
|
State: string;
|
|
75
79
|
Url: string;
|
|
80
|
+
Handler: string;
|
|
76
81
|
};
|
|
77
82
|
type OperationArgumentType = keyof OperationArgumentTypes;
|
|
78
83
|
type BaseOperationOptions = ReadonlyArray<{
|
|
@@ -123,6 +128,15 @@ declare const OnClickOperationOptions: readonly [
|
|
|
123
128
|
readonly operation: "closeApp";
|
|
124
129
|
readonly args: readonly [
|
|
125
130
|
];
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
readonly operation: "runScript";
|
|
134
|
+
readonly args: readonly [
|
|
135
|
+
{
|
|
136
|
+
readonly type: "Handler";
|
|
137
|
+
readonly default: "";
|
|
138
|
+
}
|
|
139
|
+
];
|
|
126
140
|
}
|
|
127
141
|
];
|
|
128
142
|
type OnClickOperation = ConvertOperationOptions<typeof OnClickOperationOptions>;
|
|
@@ -177,19 +191,30 @@ declare const Overflows: string[];
|
|
|
177
191
|
type Overflow = typeof Overflows[number];
|
|
178
192
|
type Style = string;
|
|
179
193
|
type StateName = string;
|
|
194
|
+
// Svelteの機能の隠蔽
|
|
195
|
+
type Store<T> = Writable_<T>;
|
|
196
|
+
declare const getStoreState: typeof get_;
|
|
180
197
|
type OPTIONS = {
|
|
181
198
|
send?: (event_name: string, values?: any) => void;
|
|
182
199
|
isPreview?: boolean;
|
|
183
200
|
initialState?: string;
|
|
184
201
|
};
|
|
202
|
+
type ActionEventHandler = (...args: any[]) => any | Promise<any>;
|
|
185
203
|
declare const CONSTANTS: {
|
|
186
204
|
ALL_ACTION_ID: string;
|
|
187
205
|
STATE_EVENT: string;
|
|
188
206
|
};
|
|
189
207
|
declare const actionId: string;
|
|
190
|
-
|
|
191
|
-
declare const
|
|
192
|
-
|
|
208
|
+
// 現在のステートのストア
|
|
209
|
+
declare const state: Store<string>;
|
|
210
|
+
// アクションの表示を管理するストア
|
|
211
|
+
declare const closed: Store<boolean>;
|
|
212
|
+
// グリッドの最大z-indexを管理するストア
|
|
213
|
+
declare const maximumZindex: Store<number>;
|
|
214
|
+
// カスタムイベントハンドラを管理するストア
|
|
215
|
+
declare const customHandlers: Store<{
|
|
216
|
+
[key: string]: ActionEventHandler;
|
|
217
|
+
}>;
|
|
193
218
|
declare const initialize: (options?: OPTIONS) => () => void;
|
|
194
219
|
declare const finalize: () => void;
|
|
195
220
|
declare const send_event: (event_name: string, values?: any) => void;
|
|
@@ -200,6 +225,7 @@ declare const none: () => () => void;
|
|
|
200
225
|
declare const moveTo: (to: string) => () => void;
|
|
201
226
|
declare const linkTo: (to: string, targetBlank?: boolean) => () => void;
|
|
202
227
|
declare const closeApp: () => () => void;
|
|
228
|
+
declare const runScript: (handlerName: string) => () => void;
|
|
203
229
|
declare const execOnClickOperation: (onClickOperation: OnClickOperation) => void;
|
|
204
230
|
declare const haveFunction: (onClickOperation: OnClickOperation) => boolean;
|
|
205
231
|
/**
|
|
@@ -402,7 +428,7 @@ declare const collection: (config: {
|
|
|
402
428
|
} | null | undefined, cb: (err: Error | null, items?: any) => void): void;
|
|
403
429
|
set(key: string, value: string, cb: (err: Error | null) => void): void;
|
|
404
430
|
};
|
|
405
|
-
export { CONSTANTS, actionId, state, closed, maximumZindex, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, execOnClickOperation, haveFunction, customAnimation, 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, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ModalOptions, showModal, KARTE_MODAL_ROOT, KARTE_ACTION_RID, ensureModalRoot, h, createFog, EmbedLogic, embed, AppOptions, App, createApp, collection };
|
|
431
|
+
export { Store, getStoreState, ActionEventHandler, CONSTANTS, actionId, state, closed, maximumZindex, customHandlers, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, runScript, execOnClickOperation, haveFunction, customAnimation, 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, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ModalOptions, showModal, KARTE_MODAL_ROOT, KARTE_ACTION_RID, ensureModalRoot, h, createFog, EmbedLogic, embed, AppOptions, App, createApp, collection };
|
|
406
432
|
export { default as State } from './components/State.svelte';
|
|
407
433
|
export { default as StateItem } from './components/StateItem.svelte';
|
|
408
434
|
export { default as Modal } from './components/Modal.svelte';
|
package/dist/index.es.js
CHANGED
|
@@ -132,15 +132,21 @@ function randStr(digit = 8) {
|
|
|
132
132
|
/**
|
|
133
133
|
* UIから選択できる関数
|
|
134
134
|
*/
|
|
135
|
+
const getStoreState = get;
|
|
135
136
|
const CONSTANTS = {
|
|
136
137
|
ALL_ACTION_ID: 'KARTE_ALL_ACTION_ID',
|
|
137
138
|
STATE_EVENT: 'KARTE-ACTION-CHANGE-STATE',
|
|
138
139
|
};
|
|
139
140
|
const functionOptions = writable({});
|
|
140
141
|
const actionId = randStr();
|
|
142
|
+
// 現在のステートのストア
|
|
141
143
|
const state = writable('/');
|
|
144
|
+
// アクションの表示を管理するストア
|
|
142
145
|
const closed = writable(false);
|
|
146
|
+
// グリッドの最大z-indexを管理するストア
|
|
143
147
|
const maximumZindex = writable(0);
|
|
148
|
+
// カスタムイベントハンドラを管理するストア
|
|
149
|
+
const customHandlers = writable({});
|
|
144
150
|
const setState = (event) => {
|
|
145
151
|
if (event.detail.actionId === actionId || event.detail.actionId === CONSTANTS.ALL_ACTION_ID) {
|
|
146
152
|
state.set(event.detail.to);
|
|
@@ -160,14 +166,14 @@ const finalize = () => {
|
|
|
160
166
|
functionOptions.set({});
|
|
161
167
|
};
|
|
162
168
|
const send_event = (event_name, values) => {
|
|
163
|
-
const options =
|
|
169
|
+
const options = getStoreState(functionOptions);
|
|
164
170
|
options?.send?.(event_name, values);
|
|
165
171
|
};
|
|
166
172
|
const isPreview = () => {
|
|
167
173
|
return false;
|
|
168
174
|
};
|
|
169
175
|
const setMiximumZindex = (zindex) => {
|
|
170
|
-
if (!zindex || zindex <
|
|
176
|
+
if (!zindex || zindex < getStoreState(maximumZindex))
|
|
171
177
|
return;
|
|
172
178
|
maximumZindex.set(zindex);
|
|
173
179
|
};
|
|
@@ -190,6 +196,18 @@ const closeApp = () => () => {
|
|
|
190
196
|
send_event('message_close', null);
|
|
191
197
|
closed.set(true);
|
|
192
198
|
};
|
|
199
|
+
const runScript = (handlerName) => () => {
|
|
200
|
+
const handlers = getStoreState(customHandlers);
|
|
201
|
+
const handler = handlers[handlerName];
|
|
202
|
+
if (!handler)
|
|
203
|
+
return;
|
|
204
|
+
try {
|
|
205
|
+
handler();
|
|
206
|
+
}
|
|
207
|
+
catch (e) {
|
|
208
|
+
console.warn('Failed to run custom handler', handlerName, e);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
193
211
|
const execOnClickOperation = (onClickOperation) => {
|
|
194
212
|
if (onClickOperation.operation === 'linkTo') {
|
|
195
213
|
linkTo(...onClickOperation.args)();
|
|
@@ -200,6 +218,9 @@ const execOnClickOperation = (onClickOperation) => {
|
|
|
200
218
|
else if (onClickOperation.operation === 'closeApp') {
|
|
201
219
|
closeApp()();
|
|
202
220
|
}
|
|
221
|
+
else if (onClickOperation.operation === 'runScript') {
|
|
222
|
+
runScript(onClickOperation.args[0])();
|
|
223
|
+
}
|
|
203
224
|
};
|
|
204
225
|
const haveFunction = (onClickOperation) => {
|
|
205
226
|
return onClickOperation.operation !== 'none';
|
|
@@ -324,7 +345,7 @@ const DefaultModalPlacement = {
|
|
|
324
345
|
bottom: '0px',
|
|
325
346
|
},
|
|
326
347
|
backgroundOverlay: false,
|
|
327
|
-
backgroundClick: { operation:
|
|
348
|
+
backgroundClick: { operation: 'closeApp', args: [] },
|
|
328
349
|
};
|
|
329
350
|
const OnClickOperationOptions = [
|
|
330
351
|
{
|
|
@@ -357,6 +378,15 @@ const OnClickOperationOptions = [
|
|
|
357
378
|
operation: 'closeApp',
|
|
358
379
|
args: [],
|
|
359
380
|
},
|
|
381
|
+
{
|
|
382
|
+
operation: 'runScript',
|
|
383
|
+
args: [
|
|
384
|
+
{
|
|
385
|
+
type: 'Handler',
|
|
386
|
+
default: '',
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
},
|
|
360
390
|
];
|
|
361
391
|
const LengthUnits = ['px', 'em', 'rem', 'vw', 'fr', '%'];
|
|
362
392
|
const Justifies = ['flex-start', 'center', 'flex-end'];
|
|
@@ -1006,7 +1036,7 @@ function add_css$9(target) {
|
|
|
1006
1036
|
append_styles(target, "svelte-1bxl6mz", ".modal.svelte-1bxl6mz{position:fixed;box-sizing:border-box;z-index:2147483647}.close.svelte-1bxl6mz{position:absolute;display:flex;justify-content:center;align-items:center;background-color:transparent;border:none;cursor:pointer;padding:0;transition:all 0.25s}.close.svelte-1bxl6mz:hover{transform:rotate(90deg)}");
|
|
1007
1037
|
}
|
|
1008
1038
|
|
|
1009
|
-
// (
|
|
1039
|
+
// (130:0) {#if visible}
|
|
1010
1040
|
function create_if_block$1(ctx) {
|
|
1011
1041
|
let div;
|
|
1012
1042
|
let t;
|
|
@@ -1016,8 +1046,8 @@ function create_if_block$1(ctx) {
|
|
|
1016
1046
|
let mounted;
|
|
1017
1047
|
let dispose;
|
|
1018
1048
|
let if_block = /*closable*/ ctx[13] && create_if_block_1(ctx);
|
|
1019
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1020
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1049
|
+
const default_slot_template = /*#slots*/ ctx[27].default;
|
|
1050
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], null);
|
|
1021
1051
|
|
|
1022
1052
|
return {
|
|
1023
1053
|
c() {
|
|
@@ -1067,15 +1097,15 @@ function create_if_block$1(ctx) {
|
|
|
1067
1097
|
}
|
|
1068
1098
|
|
|
1069
1099
|
if (default_slot) {
|
|
1070
|
-
if (default_slot.p && (!current || dirty & /*$$scope*/
|
|
1100
|
+
if (default_slot.p && (!current || dirty & /*$$scope*/ 67108864)) {
|
|
1071
1101
|
update_slot_base(
|
|
1072
1102
|
default_slot,
|
|
1073
1103
|
default_slot_template,
|
|
1074
1104
|
ctx,
|
|
1075
|
-
/*$$scope*/ ctx[
|
|
1105
|
+
/*$$scope*/ ctx[26],
|
|
1076
1106
|
!current
|
|
1077
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1078
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1107
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
1108
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, null),
|
|
1079
1109
|
null
|
|
1080
1110
|
);
|
|
1081
1111
|
}
|
|
@@ -1117,7 +1147,7 @@ function create_if_block$1(ctx) {
|
|
|
1117
1147
|
};
|
|
1118
1148
|
}
|
|
1119
1149
|
|
|
1120
|
-
// (
|
|
1150
|
+
// (147:4) {#if closable}
|
|
1121
1151
|
function create_if_block_1(ctx) {
|
|
1122
1152
|
let button;
|
|
1123
1153
|
let svg;
|
|
@@ -1188,7 +1218,10 @@ function create_fragment$c(ctx) {
|
|
|
1188
1218
|
}
|
|
1189
1219
|
});
|
|
1190
1220
|
|
|
1191
|
-
backgroundoverray.$on("click",
|
|
1221
|
+
backgroundoverray.$on("click", function () {
|
|
1222
|
+
if (is_function(/*backgroundClick*/ ctx[11])) /*backgroundClick*/ ctx[11].apply(this, arguments);
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1192
1225
|
let if_block = /*visible*/ ctx[6] && create_if_block$1(ctx);
|
|
1193
1226
|
|
|
1194
1227
|
return {
|
|
@@ -1269,6 +1302,7 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1269
1302
|
let close;
|
|
1270
1303
|
let closable;
|
|
1271
1304
|
let backgroundOverray;
|
|
1305
|
+
let backgroundClickFunction;
|
|
1272
1306
|
let backgroundClick;
|
|
1273
1307
|
let overwritePosition;
|
|
1274
1308
|
let overwriteMargin;
|
|
@@ -1298,7 +1332,6 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1298
1332
|
});
|
|
1299
1333
|
|
|
1300
1334
|
onDestroy(() => setPreviousFocus());
|
|
1301
|
-
const click_handler = () => execOnClickOperation(backgroundClick);
|
|
1302
1335
|
|
|
1303
1336
|
function div_binding($$value) {
|
|
1304
1337
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
@@ -1319,7 +1352,7 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1319
1352
|
if ('closeEventName' in $$props) $$invalidate(21, closeEventName = $$props.closeEventName);
|
|
1320
1353
|
if ('closeEventValue' in $$props) $$invalidate(22, closeEventValue = $$props.closeEventValue);
|
|
1321
1354
|
if ('_closeStyle' in $$props) $$invalidate(3, _closeStyle = $$props._closeStyle);
|
|
1322
|
-
if ('$$scope' in $$props) $$invalidate(
|
|
1355
|
+
if ('$$scope' in $$props) $$invalidate(26, $$scope = $$props.$$scope);
|
|
1323
1356
|
};
|
|
1324
1357
|
|
|
1325
1358
|
$$self.$$.update = () => {
|
|
@@ -1354,11 +1387,21 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1354
1387
|
}
|
|
1355
1388
|
|
|
1356
1389
|
if ($$self.$$.dirty & /*placement*/ 524288) {
|
|
1357
|
-
$$invalidate(
|
|
1390
|
+
$$invalidate(25, backgroundClickFunction = placement && placement.backgroundClick != null
|
|
1358
1391
|
? placement.backgroundClick
|
|
1359
1392
|
: DefaultModalPlacement.backgroundClick);
|
|
1360
1393
|
}
|
|
1361
1394
|
|
|
1395
|
+
if ($$self.$$.dirty & /*closeEventName, closeEventValue, backgroundClickFunction*/ 39845888) {
|
|
1396
|
+
$$invalidate(11, backgroundClick = () => {
|
|
1397
|
+
if (closeEventName) {
|
|
1398
|
+
send_event(closeEventName, closeEventValue);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
execOnClickOperation(backgroundClickFunction);
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1362
1405
|
if ($$self.$$.dirty & /*placement*/ 524288) {
|
|
1363
1406
|
$$invalidate(24, overwritePosition = placement && placement.position != null
|
|
1364
1407
|
? placement.position
|
|
@@ -1419,9 +1462,9 @@ function instance$c($$self, $$props, $$invalidate) {
|
|
|
1419
1462
|
closeEventValue,
|
|
1420
1463
|
overwriteMargin,
|
|
1421
1464
|
overwritePosition,
|
|
1465
|
+
backgroundClickFunction,
|
|
1422
1466
|
$$scope,
|
|
1423
1467
|
slots,
|
|
1424
|
-
click_handler,
|
|
1425
1468
|
div_binding
|
|
1426
1469
|
];
|
|
1427
1470
|
}
|
|
@@ -3046,4 +3089,4 @@ class ImageBlock extends SvelteComponent {
|
|
|
3046
3089
|
}
|
|
3047
3090
|
}
|
|
3048
3091
|
|
|
3049
|
-
export { Alignments, AnimationStyles, BackgroundSizes, CONSTANTS, Cursors, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_MODAL_ROOT, LengthUnits, MediaQueries, Modal, ModalPositions, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, closeApp, closed, collection, createApp, createFog, customAnimation, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, getTransform, h, handleFocus, handleKeydown, hasSuffix, haveFunction, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, showModal, showOnScroll, showOnTime, state, toBr };
|
|
3092
|
+
export { Alignments, AnimationStyles, BackgroundSizes, CONSTANTS, Cursors, DefaultModalPlacement, Directions, Flex, FlexItem, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_ACTION_RID, KARTE_MODAL_ROOT, LengthUnits, MediaQueries, Modal, ModalPositions, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextElement, actionId, closeApp, closed, collection, createApp, createFog, customAnimation, customHandlers, embed, ensureModalRoot, execOnClickOperation, finalize, getMarginStyle, getPositionStyle, getStoreState, getTransform, h, handleFocus, handleKeydown, hasSuffix, haveFunction, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, runScript, send_event, setMiximumZindex, setPreviousFocus, showModal, showOnScroll, showOnTime, state, toBr };
|