@supersoniks/concorde 1.1.34 → 1.1.36

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.
@@ -17,6 +17,7 @@ declare const Fetch_base: {
17
17
  firstUpdated(): void;
18
18
  onIntersection(entries: IntersectionObserverEntry[]): void;
19
19
  props: any;
20
+ propertyMap: Object;
20
21
  isConnected: boolean;
21
22
  getAncestorAttributeValue(attributeName: string): string;
22
23
  hasAncestorAttribute(attributeName: string): boolean;
@@ -10,3 +10,4 @@ import "./router/redirect";
10
10
  import "./states/states";
11
11
  import "./sonic-scope/sonic-scope";
12
12
  import "./example/example";
13
+ import "./sdui/sdui";
@@ -10,3 +10,4 @@ import "./router/redirect";
10
10
  import "./states/states";
11
11
  import "./sonic-scope/sonic-scope";
12
12
  import "./example/example";
13
+ import "./sdui/sdui";
@@ -19,6 +19,7 @@ declare const List_base: {
19
19
  firstUpdated(): void;
20
20
  onIntersection(entries: IntersectionObserverEntry[]): void;
21
21
  props: any;
22
+ propertyMap: Object;
22
23
  isConnected: boolean;
23
24
  getAncestorAttributeValue(attributeName: string): string;
24
25
  hasAncestorAttribute(attributeName: string): boolean;
@@ -0,0 +1,67 @@
1
+ import { LitElement } from "lit";
2
+ declare type SDUIDescriptor = {
3
+ js?: Array<string>;
4
+ css?: Array<string>;
5
+ library?: Record<string, SDUINode>;
6
+ nodes?: Array<SDUINode>;
7
+ };
8
+ declare type SDUINode = {
9
+ library?: string;
10
+ markup?: string;
11
+ type?: string;
12
+ attributes: Record<string, string>;
13
+ nodes?: Array<SDUINode>;
14
+ innerHTML?: string;
15
+ prefix?: string;
16
+ suffix?: string;
17
+ };
18
+ declare const SonicComponent_base: {
19
+ new (...args: any[]): {
20
+ api: import("../../../utils/api").default | null;
21
+ key: String;
22
+ isFirstLoad: boolean;
23
+ isLoading: boolean;
24
+ iObserver: IntersectionObserver | null;
25
+ isDefaultLoaderEnabled: boolean;
26
+ isFetchEnabled: boolean;
27
+ _endPoint: string;
28
+ endPoint: string;
29
+ _fetchData(): Promise<void>;
30
+ onInvalidate: any;
31
+ disconnectedCallback(): void;
32
+ connectedCallback(): void;
33
+ firstUpdated(): void;
34
+ onIntersection(entries: IntersectionObserverEntry[]): void;
35
+ props: any;
36
+ propertyMap: Object;
37
+ isConnected: boolean;
38
+ getAncestorAttributeValue(attributeName: string): string;
39
+ hasAncestorAttribute(attributeName: string): boolean;
40
+ querySelectorAll(selector: string): NodeListOf<Element>;
41
+ publisher: any;
42
+ dataProvider: string | null;
43
+ noShadowDom: string | null;
44
+ debug: HTMLElement | null;
45
+ defferedDebug: boolean | null;
46
+ dispatchEvent(event: Event): void;
47
+ setAttribute(name: string, value: string): void;
48
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
49
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
50
+ removeAttribute(name: string): void;
51
+ initPublisher(): void;
52
+ getApiConfiguration(): import("../../../utils/api").APIConfiguration;
53
+ requestUpdate(): void;
54
+ getAttribute(name: string): string;
55
+ hasAttribute(attributeName: String): boolean;
56
+ };
57
+ } & (new (...args: any[]) => import("../../../mixins/Subscriber").SubscriberInterface) & typeof LitElement;
58
+ export declare class SonicComponent extends SonicComponent_base {
59
+ connectedCallback(): void;
60
+ get props(): SDUIDescriptor;
61
+ loadJS(src: string): Promise<unknown>;
62
+ loadCSS(src: string): Promise<unknown>;
63
+ set props(value: SDUIDescriptor);
64
+ updateContents(): Promise<void>;
65
+ parseChild(props: SDUINode): HTMLElement;
66
+ }
67
+ export {};
@@ -0,0 +1,130 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ import { LitElement } from "lit";
17
+ import { customElement, property } from "lit/decorators.js";
18
+ import { Fetcher, Subscriber } from "@supersoniks/concorde/mixins";
19
+ const tagName = "sonic-sdui"; // For Astro.build
20
+ let SonicComponent = class SonicComponent extends Fetcher(Subscriber(LitElement)) {
21
+ connectedCallback() {
22
+ this.noShadowDom = "";
23
+ this.isFetchEnabled = this.hasAttribute("fetch");
24
+ super.connectedCallback();
25
+ }
26
+ get props() {
27
+ return super.props;
28
+ }
29
+ loadJS(src) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const p = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
32
+ let script = document.createElement("script");
33
+ script.src = src;
34
+ script.onload = () => resolve(true);
35
+ script.onerror = () => resolve(true);
36
+ document.head.appendChild(script);
37
+ }));
38
+ return p;
39
+ });
40
+ }
41
+ loadCSS(src) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const p = new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
44
+ var cssnode = document.createElement("link");
45
+ cssnode.type = "text/css";
46
+ cssnode.rel = "stylesheet";
47
+ cssnode.href = src;
48
+ cssnode.onload = () => resolve(true);
49
+ cssnode.onerror = () => resolve(true);
50
+ document.head.appendChild(cssnode);
51
+ }));
52
+ return p;
53
+ });
54
+ }
55
+ set props(value) {
56
+ super.props = value;
57
+ this.updateContents();
58
+ }
59
+ updateContents() {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ while ([...this.children].filter((elt) => elt.nodeName != "SLOT").length > 0) {
62
+ this.removeChild(this.children[0]);
63
+ }
64
+ if (!this.props)
65
+ return;
66
+ try {
67
+ if (this.props.js) {
68
+ for (const src of this.props.js)
69
+ this.loadJS(src);
70
+ }
71
+ if (this.props.css) {
72
+ for (const src of this.props.css)
73
+ this.loadCSS(src);
74
+ }
75
+ }
76
+ catch (e) { }
77
+ let children = this.props.nodes;
78
+ if (!children)
79
+ return;
80
+ for (let child of children) {
81
+ this.appendChild(this.parseChild(child));
82
+ }
83
+ });
84
+ }
85
+ parseChild(props) {
86
+ let type = props.type || "div";
87
+ let element;
88
+ if (props.markup) {
89
+ element = document.createElement("div");
90
+ element.style.display = "contents";
91
+ element.innerHTML = props.markup;
92
+ return element;
93
+ }
94
+ if (props.library && this.props.library) {
95
+ element = this.parseChild(this.props.library[props.library] || { type: "div" });
96
+ }
97
+ else
98
+ element = document.createElement(type);
99
+ let attributes = props.attributes;
100
+ for (let k in attributes) {
101
+ element.setAttribute(k, attributes[k]);
102
+ }
103
+ if (props.innerHTML) {
104
+ element.innerHTML = props.innerHTML;
105
+ }
106
+ if (props.nodes) {
107
+ let children = props.nodes;
108
+ for (let child of children) {
109
+ if (element.shadowRoot)
110
+ element.shadowRoot.appendChild(this.parseChild(child));
111
+ else
112
+ element.appendChild(this.parseChild(child));
113
+ }
114
+ }
115
+ if (props.prefix || props.suffix) {
116
+ const container = document.createElement("div");
117
+ container.innerHTML = (props.prefix || "") + element.outerHTML + (props.suffix || "");
118
+ container.style.display = "contents";
119
+ return container;
120
+ }
121
+ return element;
122
+ }
123
+ };
124
+ __decorate([
125
+ property()
126
+ ], SonicComponent.prototype, "props", null);
127
+ SonicComponent = __decorate([
128
+ customElement(tagName)
129
+ ], SonicComponent);
130
+ export { SonicComponent };
@@ -123,7 +123,8 @@ let Submit = class Submit extends Subscriber(LitElement) {
123
123
  ? formPublisher
124
124
  : null;
125
125
  if (captchaPublisher) {
126
- captchaPublisher.action = method + "//" + ((_c = (_b = dataProvider === null || dataProvider === void 0 ? void 0 : dataProvider.split("?")[0]) !== null && _b !== void 0 ? _b : this.getAncestorAttributeValue("formDataProvider")) !== null && _c !== void 0 ? _c : "submit");
126
+ captchaPublisher.captchaMethod = method;
127
+ captchaPublisher.captchaAction = (_c = (_b = dataProvider === null || dataProvider === void 0 ? void 0 : dataProvider.split("?")[0]) !== null && _b !== void 0 ? _b : this.getAncestorAttributeValue("formDataProvider")) !== null && _c !== void 0 ? _c : "submit";
127
128
  captchaPublisher.captchaToken = "request_token";
128
129
  captchaPublisher.captchaToken.onAssign((token) => {
129
130
  if (token != "request_token")
@@ -25,7 +25,13 @@ declare const Button_base: {
25
25
  _name: string;
26
26
  name: string;
27
27
  props: any;
28
- isConnected: boolean;
28
+ propertyMap: Object;
29
+ isConnected: boolean; /**
30
+ * Un bouton simple avec deux slots, un nommé préfix et un nomé suffix de manière à pouvoir mettre (par exemple) une icone avant ou après le contenu.
31
+ * * L'objet et ses slot sont en display flex avec direction / alignement et justifications configurables
32
+ * * Le bouton est comparable au badge car il possèdent tous les deux les propriétés *type* (primary...), *variant*(outline, ghost), size(xs...)...
33
+ * * Le bouton possède cependant et notamment une propriété href contrairement à un badge
34
+ */
29
35
  getAncestorAttributeValue(attributeName: string): string;
30
36
  hasAncestorAttribute(attributeName: string): boolean;
31
37
  querySelectorAll(selector: string): NodeListOf<Element>;
@@ -36,14 +36,16 @@ let Captcha = class Captcha extends Subscriber(LitElement) {
36
36
  });
37
37
  }
38
38
  requestToken() {
39
- var _a, _b, _c;
39
+ var _a, _b, _c, _d;
40
40
  const win = window;
41
41
  // On récupère l'action liée au recaptcha,
42
42
  // et on vérifie qu'il ne contienne que des caractères alpha-numériques, underscore et slash
43
- let action = ((_c = (_a = this.action) !== null && _a !== void 0 ? _a : (_b = this.formPublisher.action) === null || _b === void 0 ? void 0 : _b.get()) !== null && _c !== void 0 ? _c : "submit").replace(/[^\w_\/]/g, "_");
44
- delete this.formPublisher.action;
43
+ let action = ((_c = (_a = this.action) !== null && _a !== void 0 ? _a : (_b = this.formPublisher.captchaAction) === null || _b === void 0 ? void 0 : _b.get()) !== null && _c !== void 0 ? _c : "submit").replace(/[^\w_\/]/g, "_");
44
+ let method = ((_d = this.formPublisher.captchaMethod.get()) !== null && _d !== void 0 ? _d : "POST").toUpperCase();
45
+ delete this.formPublisher.captchaAction;
46
+ delete this.formPublisher.captchaMethod;
45
47
  win.grecaptcha.ready(() => {
46
- win.grecaptcha.execute(this.key, { action: action }).then((token) => {
48
+ win.grecaptcha.execute(this.key, { action: method + "//" + action }).then((token) => {
47
49
  this.formPublisher.captchaToken = token;
48
50
  });
49
51
  });
@@ -26,6 +26,7 @@ declare const Checkbox_base: {
26
26
  _name: string;
27
27
  name: string;
28
28
  props: any;
29
+ propertyMap: Object;
29
30
  isConnected: boolean;
30
31
  getAncestorAttributeValue(attributeName: string): string;
31
32
  hasAncestorAttribute(attributeName: string): boolean;
@@ -74,6 +75,7 @@ declare const Checkbox_base: {
74
75
  _name: string;
75
76
  name: string;
76
77
  props: any;
78
+ propertyMap: Object;
77
79
  isConnected: boolean;
78
80
  getAncestorAttributeValue(attributeName: string): string;
79
81
  hasAncestorAttribute(attributeName: string): boolean;
@@ -26,6 +26,7 @@ declare const Input_base: {
26
26
  _name: string;
27
27
  name: string;
28
28
  props: any;
29
+ propertyMap: Object;
29
30
  isConnected: boolean;
30
31
  getAncestorAttributeValue(attributeName: string): string;
31
32
  hasAncestorAttribute(attributeName: string): boolean;
@@ -26,6 +26,7 @@ declare const Textarea_base: {
26
26
  _name: string;
27
27
  name: string;
28
28
  props: any;
29
+ propertyMap: Object;
29
30
  isConnected: boolean;
30
31
  getAncestorAttributeValue(attributeName: string): string;
31
32
  hasAncestorAttribute(attributeName: string): boolean;
@@ -49,8 +49,12 @@ declare const Fetcher: <T extends Constructor<SubscriberInterface>>(superClass:
49
49
  firstUpdated(): void;
50
50
  onIntersection(entries: IntersectionObserverEntry[]): void;
51
51
  props: any;
52
+ propertyMap: Object;
52
53
  isConnected: boolean;
53
- getAncestorAttributeValue(attributeName: string): string;
54
+ getAncestorAttributeValue(attributeName: string): string; /**
55
+ * Après le chargement des données on traverse l'objet reçu en fonctione de la cible exprimées dans cette propriété avec la dot syntaxe.
56
+ * C'est cette donnée cible qui est injectée dans les pros et donc disponible via le publisher disponible globalement via PublisherManager.get(dataProvider)
57
+ */
54
58
  hasAncestorAttribute(attributeName: string): boolean;
55
59
  querySelectorAll(selector: string): NodeListOf<Element>;
56
60
  publisher: any;
@@ -99,7 +99,7 @@ const Fetcher = (superClass) => {
99
99
  if (this.key) {
100
100
  let response = data._sonic_http_response_;
101
101
  data = Objects.traverse(data, this.key.split("."), false);
102
- if (data)
102
+ if (data && Objects.isObject(data))
103
103
  data._sonic_http_response_ = response;
104
104
  }
105
105
  this.props = data;
@@ -47,6 +47,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
47
47
  _name: string;
48
48
  name: string;
49
49
  props: any;
50
+ propertyMap: Object;
50
51
  isConnected: boolean;
51
52
  getAncestorAttributeValue(attributeName: string): string;
52
53
  hasAncestorAttribute(attributeName: string): boolean;
@@ -39,6 +39,7 @@ const Form = (superClass) => {
39
39
  return this._value;
40
40
  }
41
41
  set value(value) {
42
+ console.log(value);
42
43
  if (this.hasAttribute("value") && !this.forceAutoFill)
43
44
  value = this.getAttribute("value");
44
45
  if (this._value == value)
@@ -32,6 +32,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
32
32
  _name: string;
33
33
  name: string;
34
34
  props: any;
35
+ propertyMap: Object;
35
36
  isConnected: boolean;
36
37
  getAncestorAttributeValue(attributeName: string): string;
37
38
  hasAncestorAttribute(attributeName: string): boolean;
@@ -3,6 +3,7 @@ import { APIConfiguration } from "@supersoniks/concorde/core/utils/api";
3
3
  declare type Constructor<T> = new (...args: any[]) => T;
4
4
  export interface SubscriberInterface {
5
5
  props: any;
6
+ propertyMap: Object;
6
7
  isConnected: boolean;
7
8
  getAncestorAttributeValue(attributeName: string): string;
8
9
  hasAncestorAttribute(attributeName: string): boolean;
package/core/utils/api.js CHANGED
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import HTML from "@supersoniks/concorde/core/utils/HTML";
11
+ import Objects from "./Objects";
11
12
  class API {
12
13
  constructor(config) {
13
14
  this.serviceURL = config.serviceURL;
@@ -52,7 +53,9 @@ class API {
52
53
  let result = yield fetch(url, { headers: headers });
53
54
  try {
54
55
  let json = yield result.json();
55
- json._sonic_http_response_ = result;
56
+ if (Objects.isObject(json)) {
57
+ json._sonic_http_response_ = result;
58
+ }
56
59
  resolve(json);
57
60
  }
58
61
  catch (e) {
package/mixins.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare const Fetcher: <T extends new (...args: any[]) => mySubscriber.Su
16
16
  firstUpdated(): void;
17
17
  onIntersection(entries: IntersectionObserverEntry[]): void;
18
18
  props: any;
19
+ propertyMap: Object;
19
20
  isConnected: boolean;
20
21
  getAncestorAttributeValue(attributeName: string): string;
21
22
  hasAncestorAttribute(attributeName: string): boolean;
@@ -63,6 +64,7 @@ export declare const FormCheckable: <T extends new (...args: any[]) => myFormEle
63
64
  _name: string;
64
65
  name: string;
65
66
  props: any;
67
+ propertyMap: Object;
66
68
  isConnected: boolean;
67
69
  getAncestorAttributeValue(attributeName: string): string;
68
70
  hasAncestorAttribute(attributeName: string): boolean;
@@ -114,6 +116,7 @@ export declare const FormInput: <T extends new (...args: any[]) => myFormElement
114
116
  _name: string;
115
117
  name: string;
116
118
  props: any;
119
+ propertyMap: Object;
117
120
  isConnected: boolean;
118
121
  getAncestorAttributeValue(attributeName: string): string;
119
122
  hasAncestorAttribute(attributeName: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersoniks/concorde",
3
- "version": "1.1.34",
3
+ "version": "1.1.36",
4
4
  "customElements": "custom-elements.json",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -46,6 +46,8 @@
46
46
  "./functional/router/redirect": "./core/components/functional/router/redirect.js",
47
47
  "./core/components/functional/router/router": "./core/components/functional/router/router.js",
48
48
  "./functional/router": "./core/components/functional/router/router.js",
49
+ "./core/components/functional/sdui/sdui": "./core/components/functional/sdui/sdui.js",
50
+ "./functional/sdui": "./core/components/functional/sdui/sdui.js",
49
51
  "./core/components/functional/sonic-scope/sonic-scope": "./core/components/functional/sonic-scope/sonic-scope.js",
50
52
  "./functional/sonic-scope": "./core/components/functional/sonic-scope/sonic-scope.js",
51
53
  "./core/components/functional/states/states": "./core/components/functional/states/states.js",