@shift-software/survey-web-component 0.0.0-stage → 0.1.1
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/ShiftSurveyElement.d.ts +48 -0
- package/dist/ShiftSurveyElement.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26854 -0
- package/dist/index.js.map +1 -0
- package/dist/library-fonts.d.ts +1 -0
- package/dist/library-fonts.d.ts.map +1 -0
- package/package.json +47 -4
- package/src/ShiftSurveyElement.tsx +273 -0
- package/src/index.ts +19 -0
- package/src/library-fonts.ts +7 -0
- package/src/styles.d.ts +6 -0
- package/README.md +0 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Survey, type SurveySubmission } from '@shift-software/survey-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* `<shift-survey>` — custom-element wrapper around `<SurveyRenderer>`.
|
|
4
|
+
*
|
|
5
|
+
* Two usage modes, pick whichever fits the host:
|
|
6
|
+
*
|
|
7
|
+
* 1. **API mode** (attribute-driven): the element fetches schema + submits
|
|
8
|
+
* responses against the Surveys API on its own.
|
|
9
|
+
* ```html
|
|
10
|
+
* <shift-survey
|
|
11
|
+
* instance-id="abc-123-guid"
|
|
12
|
+
* api-base="https://api.example.com/api/Surveys"
|
|
13
|
+
* locale="ar"></shift-survey>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* 2. **Schema mode** (property-driven): the host provides the schema + onSubmit
|
|
17
|
+
* directly as DOM properties. Used by the Blazor builder's live-preview
|
|
18
|
+
* (Phase 4) — the host pushes draft schemas via JS interop as the author
|
|
19
|
+
* types.
|
|
20
|
+
* ```ts
|
|
21
|
+
* const el = document.querySelector('shift-survey');
|
|
22
|
+
* el.schema = draftSchema;
|
|
23
|
+
* el.onSubmit = (submission) => { ... };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Lifecycle events bubble up as CustomEvents on the element (`survey:loaded`,
|
|
27
|
+
* `survey:screen-changed`, `survey:completed`, `survey:error`) — same vocabulary
|
|
28
|
+
* as the postMessage protocol, but dispatched as DOM events for page-level hosts.
|
|
29
|
+
* If the element also sits inside an iframe, postMessage emission still fires
|
|
30
|
+
* for the iframe parent; the two channels coexist.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ShiftSurveyElement extends HTMLElement {
|
|
33
|
+
#private;
|
|
34
|
+
static get observedAttributes(): string[];
|
|
35
|
+
constructor();
|
|
36
|
+
connectedCallback(): void;
|
|
37
|
+
disconnectedCallback(): void;
|
|
38
|
+
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
39
|
+
get schema(): Survey | null;
|
|
40
|
+
set schema(value: Survey | null);
|
|
41
|
+
get onSubmit(): ((submission: SurveySubmission) => void | Promise<void>) | null;
|
|
42
|
+
set onSubmit(value: ((submission: SurveySubmission) => void | Promise<void>) | null);
|
|
43
|
+
get activeScreenId(): string | null;
|
|
44
|
+
set activeScreenId(value: string | null);
|
|
45
|
+
get activeScreenJumpToken(): number;
|
|
46
|
+
set activeScreenJumpToken(value: number);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ShiftSurveyElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShiftSurveyElement.d.ts","sourceRoot":"","sources":["../src/ShiftSurveyElement.tsx"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,gBAAgB,EACtB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;;IACjD,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;;IAoBD,iBAAiB,IAAI,IAAI;IAoBzB,oBAAoB,IAAI,IAAI;IAgB5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAa1F,IAAI,MAAM,IAAI,MAAM,GAAG,IAAI,CAE1B;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAG9B;IAED,IAAI,QAAQ,IAAI,CAAC,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAE9E;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,EAGlF;IAOD,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAElC;IACD,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAGtC;IAKD,IAAI,qBAAqB,IAAI,MAAM,CAElC;IACD,IAAI,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAGtC;CAuHF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './library-fonts.js';
|
|
2
|
+
import { ShiftSurveyElement } from './ShiftSurveyElement.js';
|
|
3
|
+
export { ShiftSurveyElement };
|
|
4
|
+
/** Register the `<shift-survey>` custom element. Idempotent — calling twice on
|
|
5
|
+
* the same page is a no-op. Consumers who want a different tag name can import
|
|
6
|
+
* `ShiftSurveyElement` directly and call `customElements.define(...)` with it. */
|
|
7
|
+
export declare function registerShiftSurvey(tagName?: string): void;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B;;mFAEmF;AACnF,wBAAgB,mBAAmB,CAAC,OAAO,SAAiB,GAAG,IAAI,CAIlE"}
|