wafir 0.0.7 → 0.0.8

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.
@@ -1,7 +1,15 @@
1
1
  import type { paths } from ".";
2
2
  export declare const setBridgeUrl: (url: string) => void;
3
3
  export type WafirConfigBase = paths["/config/"]["get"]["responses"][200]["content"]["application/json"];
4
- export type WafirConfig = WafirConfigBase & {
4
+ type FieldConfigApiBase = NonNullable<NonNullable<WafirConfigBase["forms"]>[number]["body"]>[number];
5
+ export type FieldConfigApi = Omit<FieldConfigApiBase, "display"> & {
6
+ display?: FieldConfigApiBase["display"];
7
+ };
8
+ type FormConfigApiBase = NonNullable<WafirConfigBase["forms"]>[number];
9
+ export type FormConfigApi = Omit<FormConfigApiBase, "body"> & {
10
+ body?: FieldConfigApi[];
11
+ };
12
+ export type WafirConfig = Omit<WafirConfigBase, "forms"> & {
5
13
  targets: Array<{
6
14
  /** Unique identifier for this target, referenced by forms to route submissions. */
7
15
  id: string;
@@ -12,9 +20,8 @@ export type WafirConfig = WafirConfigBase & {
12
20
  /** Authentication reference used to authorize communication with the target. For GitHub types, this is the installation ID. */
13
21
  authRef: string;
14
22
  }>;
23
+ forms?: FormConfigApi[];
15
24
  };
16
- export type FormConfigApi = NonNullable<WafirConfig["forms"]>[number];
17
- export type FieldConfigApi = NonNullable<FormConfigApi["body"]>[number];
18
25
  export declare const checkBridgeHealth: (bridgeUrl?: string) => Promise<boolean>;
19
26
  /**
20
27
  * @deprecated The widget now fetches config directly from a user-hosted URL.
@@ -42,3 +49,4 @@ export interface SubmitIssueParams {
42
49
  fieldLabels?: Record<string, string>;
43
50
  }
44
51
  export declare const submitIssue: (params: SubmitIssueParams) => Promise<undefined>;
52
+ export {};
@@ -255,6 +255,12 @@ export interface paths {
255
255
  type: "input" | "email" | "textarea" | "dropdown" | "checkboxes" | "markdown" | "rating" | "date";
256
256
  /** @description Unique identifier for the field (used as key in JSON output/issue body). */
257
257
  id?: string;
258
+ /**
259
+ * @description Controls field visibility. 'none' hides the field from the UI but still includes its value in submissions. Defaults to 'visible'.
260
+ * @default visible
261
+ * @enum {string}
262
+ */
263
+ display: "visible" | "none";
258
264
  /** @description Visual and behavioral attributes for the field. */
259
265
  attributes?: {
260
266
  /** @description Display label for the field. */
package/dist/wafir.cjs CHANGED
@@ -4651,6 +4651,9 @@ let WafirForm = class extends lit.LitElement {
4651
4651
  <form @submit="${this._handleSubmit}">
4652
4652
  ${this.formLabel ? lit.html`<h2 class="form-title">${this.formLabel}</h2>` : ""}
4653
4653
  ${this.fields.map((field) => {
4654
+ if (field.display === "none") {
4655
+ return null;
4656
+ }
4654
4657
  if (field.type === "checkboxes")
4655
4658
  return lit.html`<div class="form-group">
4656
4659
  ${this._renderFieldInput(field)}
@@ -5277,7 +5280,11 @@ let WafirWidget = class extends lit.LitElement {
5277
5280
  const filteredFormData = {};
5278
5281
  for (const field of submitFields) {
5279
5282
  const id = String(field.id);
5280
- if (formData2[id] !== void 0) filteredFormData[id] = formData2[id];
5283
+ if (formData2[id] !== void 0) {
5284
+ filteredFormData[id] = formData2[id];
5285
+ } else if (field.type === "rating") {
5286
+ filteredFormData[id] = 0;
5287
+ }
5281
5288
  }
5282
5289
  const resolvedConfigUrl = this.configUrl ? this._resolveConfigUrl(this.configUrl) : "";
5283
5290
  await submitIssue({
package/dist/wafir.js CHANGED
@@ -4649,6 +4649,9 @@ let WafirForm = class extends LitElement {
4649
4649
  <form @submit="${this._handleSubmit}">
4650
4650
  ${this.formLabel ? html$2`<h2 class="form-title">${this.formLabel}</h2>` : ""}
4651
4651
  ${this.fields.map((field) => {
4652
+ if (field.display === "none") {
4653
+ return null;
4654
+ }
4652
4655
  if (field.type === "checkboxes")
4653
4656
  return html$2`<div class="form-group">
4654
4657
  ${this._renderFieldInput(field)}
@@ -5275,7 +5278,11 @@ let WafirWidget = class extends LitElement {
5275
5278
  const filteredFormData = {};
5276
5279
  for (const field of submitFields) {
5277
5280
  const id = String(field.id);
5278
- if (formData2[id] !== void 0) filteredFormData[id] = formData2[id];
5281
+ if (formData2[id] !== void 0) {
5282
+ filteredFormData[id] = formData2[id];
5283
+ } else if (field.type === "rating") {
5284
+ filteredFormData[id] = 0;
5285
+ }
5279
5286
  }
5280
5287
  const resolvedConfigUrl = this.configUrl ? this._resolveConfigUrl(this.configUrl) : "";
5281
5288
  await submitIssue({
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "README.md",
15
15
  "LICENSE"
16
16
  ],
17
- "version": "0.0.7",
17
+ "version": "0.0.8",
18
18
  "type": "module",
19
19
  "main": "dist/wafir.cjs",
20
20
  "module": "dist/wafir.js",