@plaidev/karte-action-sdk 1.0.29 → 1.0.30
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/index.es.d.ts +45 -1
- package/dist/index.es.js +173 -1
- package/package.json +2 -1
package/dist/index.es.d.ts
CHANGED
|
@@ -230,7 +230,51 @@ declare function hasSuffix<Suffix extends "px" | "em" | "rem" | "%" | "fr" | "vw
|
|
|
230
230
|
declare function toBr(text: string): string;
|
|
231
231
|
declare function randStr(digit?: number): string;
|
|
232
232
|
declare const _default: "dummy";
|
|
233
|
-
|
|
233
|
+
declare function hideOnScroll<Props extends {
|
|
234
|
+
hide_on_scroll: boolean;
|
|
235
|
+
hide_on_scroll_rate: number;
|
|
236
|
+
show_on_scroll_reenter: boolean;
|
|
237
|
+
}>(props: Props, fn?: () => void): () => void;
|
|
238
|
+
declare function hideOnTime<Props extends {
|
|
239
|
+
hide_on_time: boolean;
|
|
240
|
+
hide_on_time_count: number;
|
|
241
|
+
}>(props: Props, fn?: () => void): () => void;
|
|
242
|
+
declare function showOnScroll<Props extends {
|
|
243
|
+
show_on_scroll: boolean;
|
|
244
|
+
show_on_scroll_rate: number;
|
|
245
|
+
show_on_scroll_reenter: boolean;
|
|
246
|
+
}>(props: Props, fn?: Function): () => void;
|
|
247
|
+
declare function showOnTime<Props extends {
|
|
248
|
+
show_on_time: boolean;
|
|
249
|
+
show_on_time_count: number;
|
|
250
|
+
}>(props: Props, fn?: Function): () => void;
|
|
251
|
+
declare function ensureModalRoot(useShadow?: boolean): ShadowRoot | HTMLElement;
|
|
252
|
+
declare const h: (type: string, props: any, ...children: Array<any>) => HTMLElement;
|
|
253
|
+
declare function createFog({ color, opacity, zIndex, onclick }: {
|
|
254
|
+
color?: string;
|
|
255
|
+
opacity?: string;
|
|
256
|
+
zIndex?: number;
|
|
257
|
+
onclick: () => void;
|
|
258
|
+
}): {
|
|
259
|
+
fog: HTMLDivElement;
|
|
260
|
+
close: () => void;
|
|
261
|
+
};
|
|
262
|
+
type EmbedLogic = "replace" | "append" | "prepend" | "after" | "before";
|
|
263
|
+
declare function embed(target: HTMLElement, replace: HTMLElement, embed_method: EmbedLogic): void;
|
|
264
|
+
declare const collection: (config: {
|
|
265
|
+
api_key: string;
|
|
266
|
+
table: string;
|
|
267
|
+
endpoint?: string;
|
|
268
|
+
}) => {
|
|
269
|
+
get(key: string | string[], cb: (err: Error | null, items?: any) => void): void;
|
|
270
|
+
getByQuery(query_name: string, params: {
|
|
271
|
+
[p: string]: string | number | boolean | (string | number | boolean)[];
|
|
272
|
+
}, options: {
|
|
273
|
+
ignore_fields?: string[];
|
|
274
|
+
} | null | undefined, cb: (err: Error | null, items?: any) => void): void;
|
|
275
|
+
set(key: string, value: string, cb: (err: Error | null) => void): void;
|
|
276
|
+
};
|
|
277
|
+
export { state, closed, maximumZindex, initialize, finalize, send_event, isPreview, setMiximumZindex, none, moveTo, linkTo, closeApp, _default, handleFocus, setPreviousFocus, handleKeydown, getPositionStyle, getMarginStyle, onScroll, onTime, hasSuffix, toBr, randStr, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, AnimationStyleTranslations, ModalPositions, ModalPosition, ModalPositionTranslations, ModalMarginTranslations, ModalMargin, ModalPlacement, DefaultModalPlacement, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, Repeats, Repeat, BackgroundSizes, BackgroundSize, Style, StateName, hideOnScroll, hideOnTime, showOnScroll, showOnTime, ensureModalRoot, h, createFog, EmbedLogic, embed, collection };
|
|
234
278
|
export { default as State } from './State.svelte';
|
|
235
279
|
export { default as GridModalState } from './GridModalState.svelte';
|
|
236
280
|
export { default as GridItem } from './GridItem.svelte';
|
package/dist/index.es.js
CHANGED
|
@@ -310,6 +310,178 @@ const ObjectFits = ['fill', 'contain', 'cover'];
|
|
|
310
310
|
const Repeats = ['repeat', 'space', 'round', 'no-repeat'];
|
|
311
311
|
const BackgroundSizes = ['cover', 'contain', 'auto'];
|
|
312
312
|
|
|
313
|
+
const NOOP = () => { };
|
|
314
|
+
function hideOnScroll(props, fn) {
|
|
315
|
+
return props.hide_on_scroll && props.hide_on_scroll_rate
|
|
316
|
+
? onScroll(() => {
|
|
317
|
+
fn && fn();
|
|
318
|
+
return props.show_on_scroll_reenter;
|
|
319
|
+
}, props.hide_on_scroll_rate / 100)
|
|
320
|
+
: NOOP;
|
|
321
|
+
}
|
|
322
|
+
function hideOnTime(props, fn) {
|
|
323
|
+
return props.hide_on_time && props.hide_on_time_count
|
|
324
|
+
? onTime(() => {
|
|
325
|
+
fn && fn();
|
|
326
|
+
}, props.hide_on_time_count * 1000)
|
|
327
|
+
: NOOP;
|
|
328
|
+
}
|
|
329
|
+
function showOnScroll(props, fn) {
|
|
330
|
+
return props.show_on_scroll && props.show_on_scroll_rate
|
|
331
|
+
? onScroll(() => {
|
|
332
|
+
fn && fn();
|
|
333
|
+
return props.show_on_scroll_reenter;
|
|
334
|
+
}, props.show_on_scroll_rate / 100)
|
|
335
|
+
: NOOP;
|
|
336
|
+
}
|
|
337
|
+
function showOnTime(props, fn) {
|
|
338
|
+
return props.show_on_time && props.show_on_time_count
|
|
339
|
+
? onTime(() => {
|
|
340
|
+
fn && fn();
|
|
341
|
+
}, props.show_on_time_count * 1000)
|
|
342
|
+
: NOOP;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const KARTE_MODAL_ROOT = 'karte-modal-root';
|
|
346
|
+
function ensureModalRoot(useShadow = true) {
|
|
347
|
+
let el = document.getElementById(KARTE_MODAL_ROOT);
|
|
348
|
+
if (el == null) {
|
|
349
|
+
el = h('div', { id: KARTE_MODAL_ROOT });
|
|
350
|
+
document.body.appendChild(el);
|
|
351
|
+
}
|
|
352
|
+
const isShadow = !!document.body.attachShadow && useShadow;
|
|
353
|
+
if (isShadow) {
|
|
354
|
+
return el.shadowRoot ?? el.attachShadow({ mode: 'open' });
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
return el;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const h = (type, props, ...children) => {
|
|
361
|
+
const el = document.createElement(type);
|
|
362
|
+
for (const key of Object.keys(props)) {
|
|
363
|
+
const v = props[key];
|
|
364
|
+
if (key === 'style') {
|
|
365
|
+
Object.assign(el.style, v);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
// @ts-ignore
|
|
369
|
+
el[key] = v;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
for (const child of children) {
|
|
373
|
+
el.appendChild(child);
|
|
374
|
+
}
|
|
375
|
+
return el;
|
|
376
|
+
};
|
|
377
|
+
function createFog({ color = '#000', opacity = '50%', zIndex = 999, onclick, }) {
|
|
378
|
+
const root = ensureModalRoot(false);
|
|
379
|
+
if (root.querySelector('.__krt-fog')) {
|
|
380
|
+
return { fog: null, close: () => { } };
|
|
381
|
+
}
|
|
382
|
+
const fog = document.createElement('div');
|
|
383
|
+
fog.className = '__krt-fog';
|
|
384
|
+
Object.assign(fog.style, {
|
|
385
|
+
position: 'fixed',
|
|
386
|
+
left: 0,
|
|
387
|
+
top: 0,
|
|
388
|
+
width: '100%',
|
|
389
|
+
height: '100%',
|
|
390
|
+
'z-index': zIndex,
|
|
391
|
+
'background-color': color,
|
|
392
|
+
opacity,
|
|
393
|
+
});
|
|
394
|
+
const close = () => {
|
|
395
|
+
onclick();
|
|
396
|
+
fog.remove();
|
|
397
|
+
};
|
|
398
|
+
fog.onclick = close;
|
|
399
|
+
root.appendChild(fog);
|
|
400
|
+
return { fog, close };
|
|
401
|
+
}
|
|
402
|
+
function embed(target, replace, embed_method) {
|
|
403
|
+
if (embed_method == 'replace') {
|
|
404
|
+
if (target.parentNode) {
|
|
405
|
+
target.parentNode.replaceChild(replace, target);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else if (embed_method == 'append') {
|
|
409
|
+
target.append(replace);
|
|
410
|
+
}
|
|
411
|
+
else if (embed_method == 'prepend') {
|
|
412
|
+
target.prepend(replace);
|
|
413
|
+
}
|
|
414
|
+
else if (embed_method == 'after') {
|
|
415
|
+
target.after(replace);
|
|
416
|
+
}
|
|
417
|
+
else if (embed_method == 'before') {
|
|
418
|
+
target.before(replace);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const ENDPOINT = 'https://t.karte.io/collection';
|
|
423
|
+
const collection = (config) => {
|
|
424
|
+
const endpoint = config.endpoint ?? ENDPOINT;
|
|
425
|
+
const api_key = config.api_key;
|
|
426
|
+
const table = config.table;
|
|
427
|
+
return {
|
|
428
|
+
get(key, cb) {
|
|
429
|
+
if (Array.isArray(key)) {
|
|
430
|
+
return request(`${endpoint}/getByKeys`, {
|
|
431
|
+
api_key,
|
|
432
|
+
name: table,
|
|
433
|
+
keys: key,
|
|
434
|
+
}, cb);
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
request(`${endpoint}/getByKey`, {
|
|
438
|
+
api_key,
|
|
439
|
+
name: table,
|
|
440
|
+
key,
|
|
441
|
+
}, cb);
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
getByQuery(query_name, params, options, cb) {
|
|
445
|
+
request(`${endpoint}/getByQuery`, {
|
|
446
|
+
api_key,
|
|
447
|
+
name: table,
|
|
448
|
+
query_name,
|
|
449
|
+
params,
|
|
450
|
+
options,
|
|
451
|
+
}, cb);
|
|
452
|
+
},
|
|
453
|
+
set(key, value, cb) {
|
|
454
|
+
request(`${endpoint}/set`, {
|
|
455
|
+
api_key,
|
|
456
|
+
name: table,
|
|
457
|
+
key,
|
|
458
|
+
value,
|
|
459
|
+
}, cb);
|
|
460
|
+
},
|
|
461
|
+
};
|
|
462
|
+
};
|
|
463
|
+
function request(url, data, cb) {
|
|
464
|
+
const xhr = new XMLHttpRequest();
|
|
465
|
+
xhr.onreadystatechange = () => {
|
|
466
|
+
if (xhr.readyState != 4) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (xhr.status != 200) {
|
|
470
|
+
return cb(new Error(`fail to send collection api request. reason: ${xhr.responseText}`));
|
|
471
|
+
}
|
|
472
|
+
try {
|
|
473
|
+
data = JSON.parse(xhr.responseText);
|
|
474
|
+
return cb(null, data);
|
|
475
|
+
}
|
|
476
|
+
catch (err) {
|
|
477
|
+
return cb(err);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
xhr.open('POST', url);
|
|
481
|
+
xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
|
|
482
|
+
xhr.send(JSON.stringify({ ...data }));
|
|
483
|
+
}
|
|
484
|
+
|
|
313
485
|
/* src/components/Normalize.svelte generated by Svelte v3.44.1 */
|
|
314
486
|
|
|
315
487
|
function add_css$9(target) {
|
|
@@ -2091,4 +2263,4 @@ class ImageBlock extends SvelteComponent {
|
|
|
2091
2263
|
}
|
|
2092
2264
|
}
|
|
2093
2265
|
|
|
2094
|
-
export { Alignments, AnimationStyleTranslations, AnimationStyles, BackgroundSizes, DefaultModalPlacement, Directions, Flex, FlexItem, GridItem, GridModalState, ImageBlock, Justifies, LengthUnits, MediaQueries, Modal, ModalMarginTranslations, ModalPositionTranslations, ModalPositions, ObjectFits, PropTypes, Repeats, State, TextBlock, TextButtonBlock, closeApp, closed, finalize, getMarginStyle, getPositionStyle, handleFocus, handleKeydown, hasSuffix, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, state, toBr };
|
|
2266
|
+
export { Alignments, AnimationStyleTranslations, AnimationStyles, BackgroundSizes, DefaultModalPlacement, Directions, Flex, FlexItem, GridItem, GridModalState, ImageBlock, Justifies, LengthUnits, MediaQueries, Modal, ModalMarginTranslations, ModalPositionTranslations, ModalPositions, ObjectFits, PropTypes, Repeats, State, TextBlock, TextButtonBlock, closeApp, closed, collection, createFog, embed, ensureModalRoot, finalize, getMarginStyle, getPositionStyle, h, handleFocus, handleKeydown, hasSuffix, hideOnScroll, hideOnTime, initialize, isPreview, linkTo, maximumZindex, moveTo, none, onScroll, onTime, randStr, send_event, setMiximumZindex, setPreviousFocus, showOnScroll, showOnTime, state, toBr };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaidev/karte-action-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"author": "Plaid Inc.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"node-fetch": "2.6.7",
|
|
44
44
|
"picocolors": "^1.0.0",
|
|
45
45
|
"playwright": "^1.23.4",
|
|
46
|
+
"preact": "10.5.7",
|
|
46
47
|
"rimraf": "^3.0.2",
|
|
47
48
|
"rollup": "^2.75.7",
|
|
48
49
|
"rollup-plugin-http-resolve": "4.0.1-alpha.0",
|