@codelitdev/design-system 0.1.0-alpha.5 → 0.1.0-alpha.7

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,4 +1,6 @@
1
- import React from "react";
1
+ "use client";
2
+
3
+ import type React from "react";
2
4
 
3
5
  export interface SelectProps {
4
6
  label?: React.ReactNode;
@@ -19,19 +21,36 @@ export function Select({ label, hint, options = [], style, ...rest }: SelectProp
19
21
  <select {...rest}>
20
22
  {options.map((o) =>
21
23
  typeof o === "string" ? (
22
- <option key={o} value={o}>{o}</option>
24
+ <option key={o} value={o}>
25
+ {o}
26
+ </option>
23
27
  ) : (
24
- <option key={o.value} value={o.value}>{o.label}</option>
25
- )
28
+ <option key={o.value} value={o.value}>
29
+ {o.label}
30
+ </option>
31
+ ),
26
32
  )}
27
33
  </select>
28
34
  <span className="cl-select__chevron">
29
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m6 9 6 6 6-6"></path></svg>
35
+ <svg
36
+ aria-hidden="true"
37
+ width="14"
38
+ height="14"
39
+ viewBox="0 0 24 24"
40
+ fill="none"
41
+ stroke="currentColor"
42
+ strokeWidth="2"
43
+ strokeLinecap="round"
44
+ strokeLinejoin="round"
45
+ >
46
+ <path d="m6 9 6 6 6-6"></path>
47
+ </svg>
30
48
  </span>
31
49
  </span>
32
50
  );
33
51
  if (!label && !hint) return <span style={style}>{control}</span>;
34
52
  return (
53
+ /* biome-ignore lint/a11y/noLabelWithoutControl: the select control is rendered inside this label. */
35
54
  <label className="cl-field" style={style}>
36
55
  {label ? <span className="cl-field__label">{label}</span> : null}
37
56
  {control}
@@ -1,4 +1,6 @@
1
- import React from "react";
1
+ "use client";
2
+
3
+ import type React from "react";
2
4
 
3
5
  export interface SwitchProps {
4
6
  label?: React.ReactNode;
@@ -10,10 +12,25 @@ export interface SwitchProps {
10
12
  }
11
13
 
12
14
  /** Toggle switch with trailing label. */
13
- export function Switch({ label, checked, defaultChecked, disabled, onChange, style }: SwitchProps) {
15
+ export function Switch({
16
+ label,
17
+ checked,
18
+ defaultChecked,
19
+ disabled,
20
+ onChange,
21
+ style,
22
+ }: SwitchProps) {
14
23
  return (
15
24
  <label className="cl-switch" style={{ opacity: disabled ? 0.5 : 1, ...style }}>
16
- <input type="checkbox" role="switch" checked={checked} defaultChecked={defaultChecked} disabled={disabled} onChange={onChange} />
25
+ <input
26
+ type="checkbox"
27
+ role="switch"
28
+ aria-checked={checked ?? defaultChecked ?? false}
29
+ checked={checked}
30
+ defaultChecked={defaultChecked}
31
+ disabled={disabled}
32
+ onChange={onChange}
33
+ />
17
34
  <span className="cl-switch__track">
18
35
  <span className="cl-switch__thumb"></span>
19
36
  </span>