@shift-software/survey-web-component 0.1.1 → 0.1.2
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.map +1 -1
- package/dist/index.js +7015 -6926
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/ShiftSurveyElement.tsx +29 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shift-software/survey-web-component",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Custom-element wrapper around @shift-software/survey-renderer. Exposes <shift-survey> so non-React hosts (Blazor live-preview, plain HTML embeds, Stencil apps) can mount a survey without pulling React into the host. Ships React + renderer inside the bundle.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test.watch": "vitest"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@shift-software/survey-renderer": "^0.1.
|
|
35
|
+
"@shift-software/survey-renderer": "^0.1.2",
|
|
36
36
|
"@shift-software/survey-sdk": "^0.1.1",
|
|
37
37
|
"react": "^19.0.0",
|
|
38
38
|
"react-dom": "^19.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createRoot, type Root } from 'react-dom/client';
|
|
3
|
-
import { SurveyRenderer } from '@shift-software/survey-renderer';
|
|
3
|
+
import { SurveyRenderer, resolveLocaleConfig } from '@shift-software/survey-renderer';
|
|
4
4
|
// Relative path on purpose — the renderer's `exports` map is strict and doesn't
|
|
5
5
|
// whitelist `?inline`; reaching through the workspace path is the most robust
|
|
6
6
|
// way to inline the stylesheet at build time.
|
|
@@ -197,6 +197,34 @@ export class ShiftSurveyElement extends HTMLElement {
|
|
|
197
197
|
const schema = this.#schema ?? this.#apiSchema;
|
|
198
198
|
|
|
199
199
|
if (this.#apiError && !schema) {
|
|
200
|
+
// An answered or closed link is an end state for whoever opened it, not a fault:
|
|
201
|
+
// say so in their language instead of showing the API's wording.
|
|
202
|
+
const code = (this.#apiError as { code?: unknown }).code;
|
|
203
|
+
if (code === 'conflict' || code === 'gone') {
|
|
204
|
+
const ui = resolveLocaleConfig(locale ?? 'en', undefined);
|
|
205
|
+
const answered = code === 'conflict';
|
|
206
|
+
this.#root.render(
|
|
207
|
+
createElement(
|
|
208
|
+
'div',
|
|
209
|
+
{ className: 'survey-root survey-root--done', dir: ui.direction, lang: locale },
|
|
210
|
+
createElement(
|
|
211
|
+
'div',
|
|
212
|
+
{ className: 'survey-screen survey-screen--enter', role: 'status' },
|
|
213
|
+
createElement(
|
|
214
|
+
'h2',
|
|
215
|
+
{ className: 'survey-screen__title' },
|
|
216
|
+
answered ? ui.strings.alreadyAnsweredTitle : ui.strings.surveyClosedTitle,
|
|
217
|
+
),
|
|
218
|
+
createElement(
|
|
219
|
+
'p',
|
|
220
|
+
{ className: 'survey-screen__description' },
|
|
221
|
+
answered ? ui.strings.alreadyAnsweredBody : ui.strings.surveyClosedBody,
|
|
222
|
+
),
|
|
223
|
+
),
|
|
224
|
+
),
|
|
225
|
+
);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
200
228
|
this.#root.render(
|
|
201
229
|
createElement(
|
|
202
230
|
'div',
|