@greghowe79/the-lib 1.0.8 → 1.0.9

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.
@@ -26,7 +26,7 @@ const uploadImage = qwik.$(async (_event, input, currentFile, selectedFile, imag
26
26
  if (selectedFile) selectedFile.value = file.name;
27
27
  }
28
28
  });
29
- const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate$, onInput$, bgLight, currentFile, selectedFile, icon, prefix, required = false, name, checked }) => {
29
+ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate$, onInput$, bgLight, currentFile, selectedFile, icon, prefix, required = false, color, nameAttribute, label, selectedValue }) => {
30
30
  qwik.useStylesScoped$(styles);
31
31
  const internalError = qwik.useSignal(null);
32
32
  const showError = error ?? internalError;
@@ -39,12 +39,6 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
39
39
  return;
40
40
  }
41
41
  }
42
- if (type === "radio") {
43
- if (value) {
44
- elem.value = value.value;
45
- }
46
- return;
47
- }
48
42
  if (value) value.value = elem.value;
49
43
  if (onInput$) {
50
44
  await onInput$();
@@ -119,14 +113,25 @@ const Input = qwik.component$(({ id, type, placeholder, value, error, onValidate
119
113
  })
120
114
  ]
121
115
  })
122
- }) : type === "radio" ? /* @__PURE__ */ jsxRuntime.jsx("input", {
123
- id,
124
- type: "radio",
125
- name,
126
- checked: checked?.value,
127
- required,
128
- "bind:value": value,
129
- onInput$: inputHandler
116
+ }) : type === "radio" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
117
+ children: [
118
+ /* @__PURE__ */ jsxRuntime.jsx("input", {
119
+ type: "radio",
120
+ id,
121
+ name: nameAttribute,
122
+ value: color,
123
+ checked: selectedValue?.value === color,
124
+ onChange$: (e) => {
125
+ if (selectedValue) {
126
+ selectedValue.value = e.target.value;
127
+ }
128
+ }
129
+ }),
130
+ /* @__PURE__ */ jsxRuntime.jsx("label", {
131
+ for: id,
132
+ children: label
133
+ })
134
+ ]
130
135
  }) : /* @__PURE__ */ jsxRuntime.jsx("label", {
131
136
  class: `input-label ${bgLight ? "bg_light" : ""}`,
132
137
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -24,7 +24,7 @@ const uploadImage = $(async (_event, input, currentFile, selectedFile, imageUrl)
24
24
  if (selectedFile) selectedFile.value = file.name;
25
25
  }
26
26
  });
27
- const Input = component$(({ id, type, placeholder, value, error, onValidate$, onInput$, bgLight, currentFile, selectedFile, icon, prefix, required = false, name, checked }) => {
27
+ const Input = component$(({ id, type, placeholder, value, error, onValidate$, onInput$, bgLight, currentFile, selectedFile, icon, prefix, required = false, color, nameAttribute, label, selectedValue }) => {
28
28
  useStylesScoped$(styles);
29
29
  const internalError = useSignal(null);
30
30
  const showError = error ?? internalError;
@@ -37,12 +37,6 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
37
37
  return;
38
38
  }
39
39
  }
40
- if (type === "radio") {
41
- if (value) {
42
- elem.value = value.value;
43
- }
44
- return;
45
- }
46
40
  if (value) value.value = elem.value;
47
41
  if (onInput$) {
48
42
  await onInput$();
@@ -117,14 +111,25 @@ const Input = component$(({ id, type, placeholder, value, error, onValidate$, on
117
111
  })
118
112
  ]
119
113
  })
120
- }) : type === "radio" ? /* @__PURE__ */ jsx("input", {
121
- id,
122
- type: "radio",
123
- name,
124
- checked: checked?.value,
125
- required,
126
- "bind:value": value,
127
- onInput$: inputHandler
114
+ }) : type === "radio" ? /* @__PURE__ */ jsxs(Fragment, {
115
+ children: [
116
+ /* @__PURE__ */ jsx("input", {
117
+ type: "radio",
118
+ id,
119
+ name: nameAttribute,
120
+ value: color,
121
+ checked: selectedValue?.value === color,
122
+ onChange$: (e) => {
123
+ if (selectedValue) {
124
+ selectedValue.value = e.target.value;
125
+ }
126
+ }
127
+ }),
128
+ /* @__PURE__ */ jsx("label", {
129
+ for: id,
130
+ children: label
131
+ })
132
+ ]
128
133
  }) : /* @__PURE__ */ jsx("label", {
129
134
  class: `input-label ${bgLight ? "bg_light" : ""}`,
130
135
  children: /* @__PURE__ */ jsxs("div", {
@@ -5,7 +5,6 @@ export interface InputProps {
5
5
  id: string;
6
6
  type: InputType;
7
7
  placeholder?: string;
8
- name?: string;
9
8
  value?: Signal<string>;
10
9
  error?: Signal<string | null>;
11
10
  onValidate$?: QRL<(value: string) => Promise<string>>;
@@ -16,7 +15,12 @@ export interface InputProps {
16
15
  icon?: JSXOutput | Component<unknown>;
17
16
  prefix?: string;
18
17
  required?: boolean;
19
- checked?: Signal<boolean>;
18
+ onChange?: QRL<(_: Event, el: HTMLInputElement) => Promise<void>>;
19
+ checked?: boolean;
20
+ color?: string;
21
+ nameAttribute?: string;
22
+ label?: string;
23
+ selectedValue?: Signal<string>;
20
24
  }
21
25
  export declare const displayLocalImage: QRL<(file: File, imageUrl?: Signal<string>) => void>;
22
26
  export declare const uploadImage: QRL<(_event: Event, input: HTMLInputElement, currentFile?: Signal<any>, selectedFile?: Signal<string>, imageUrl?: Signal<string>) => Promise<void>>;
@@ -7,5 +7,4 @@ export declare const Email: Story;
7
7
  export declare const InputLightBackground: Story;
8
8
  export declare const InputWithIcon: Story;
9
9
  export declare const PhoneInput: Story;
10
- export declare const RadioInput: Story;
11
10
  export declare const FileUpload: Story;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greghowe79/the-lib",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Collection of fast components for Qwik",
5
5
  "main": "./lib/index.qwik.mjs",
6
6
  "qwik": "./lib/index.qwik.mjs",