innoboxrr-react-form-elements 3.0.0 → 3.2.0

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/index.js CHANGED
@@ -22,6 +22,7 @@ export { default as CountrySelectInputComponent } from './src/CountrySelectInput
22
22
  export { default as DynamicGroupInputComponent } from './src/DynamicGroupInputComponent.jsx'
23
23
  export { default as EditorInputComponent } from './src/EditorInputComponent.jsx'
24
24
  export { default as FileDropInputComponent } from './src/FileDropInputComponent.jsx'
25
+ export { default as IconComponent } from './src/IconComponent.jsx'
25
26
  export { default as FileInputComponent } from './src/FileInputComponent.jsx'
26
27
  export { default as FqsInputComponent } from './src/FqsInputComponent.jsx'
27
28
  export { default as InputErrorComponent } from './src/InputErrorComponent.jsx'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innoboxrr-react-form-elements",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Gemelo React de innoboxrr-form-elements: los mismos componentes, los mismos nombres y el mismo contrato.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -48,10 +48,11 @@
48
48
  "@dnd-kit/core": "^6.3.1",
49
49
  "@dnd-kit/sortable": "^10.0.0",
50
50
  "@dnd-kit/utilities": "^3.2.2",
51
+ "@iconify/react": "^6.0.0",
51
52
  "@tinymce/tinymce-react": "^6.3.0",
52
53
  "@uiw/react-codemirror": "^4.25.11",
53
54
  "@yaireo/tagify": "^4.38.0",
54
- "innoboxrr-form-core": "^2.0.0",
55
+ "innoboxrr-form-core": "^2.2.0",
55
56
  "innoboxrr-maskjs": "^2.0.0",
56
57
  "react-colorful": "^5.8.1",
57
58
  "react-phone-number-input": "^3.4.18",
@@ -0,0 +1,39 @@
1
+ import { useSyncExternalStore } from 'react'
2
+ import { Icon } from '@iconify/react'
3
+ import { iconFor, onIconChange } from 'innoboxrr-form-core'
4
+
5
+ /**
6
+ * Un icono, por nombre semantico.
7
+ *
8
+ * <IconComponent name="plus" />
9
+ * <IconComponent name="mdi:home" size={24} />
10
+ *
11
+ * El nombre se resuelve contra el mapa de innoboxrr-form-core —el mismo que
12
+ * usa la rama Vue—, asi que cambiar el juego de iconos de todo el proyecto es
13
+ * un `setIcons()` en el arranque y no tocar un solo componente.
14
+ *
15
+ * Es `aria-hidden` a proposito: un icono decorativo junto a su texto no debe
16
+ * leerse dos veces. Cuando el icono es la unica pista —un boton solo con
17
+ * icono— la etiqueta va en el `aria-label` del boton, que es donde el lector
18
+ * la espera.
19
+ *
20
+ * @param {{ name: string, size?: number|string, className?: string }} props
21
+ */
22
+ export default function IconComponent({ name, size = null, className = null }) {
23
+ // useSyncExternalStore es la forma correcta de leer estado que vive fuera
24
+ // de React: un `setIcons()` en caliente repinta lo ya montado.
25
+ const resolved = useSyncExternalStore(
26
+ onIconChange,
27
+ () => iconFor(name),
28
+ () => iconFor(name)
29
+ )
30
+
31
+ return (
32
+ <Icon
33
+ icon={resolved}
34
+ width={size}
35
+ height={size}
36
+ className={className}
37
+ aria-hidden="true" />
38
+ )
39
+ }
@@ -1,4 +1,5 @@
1
1
  import { useId, useState } from 'react'
2
+ import IconComponent from './IconComponent.jsx'
2
3
  import { applyMask, isMaskSpec } from 'innoboxrr-maskjs'
3
4
  import Field from './internal/Field.jsx'
4
5
  import useThemeClass from './internal/useThemeClass.js'
@@ -62,7 +63,7 @@ export default function TextInputComponent({
62
63
 
63
64
  return (
64
65
  <Field label={label} help={help} htmlFor={uid}>
65
- {hasIcon ? <span className="fe-field-icon" uk-icon={`icon: ${icon}`}></span> : null}
66
+ {hasIcon ? <span className="fe-field-icon"><IconComponent name={icon} /></span> : null}
66
67
 
67
68
  <div className="fe-input-wrap">
68
69
  <input
@@ -20,7 +20,11 @@ export default function FieldLabel({ label, help, htmlFor = undefined }) {
20
20
  <label htmlFor={htmlFor} className={theme.label}>
21
21
  {help ? (
22
22
  <span className={theme.help}>
23
- <i uk-tooltip={`title: ${help}`} className={theme.helpIcon}></i>
23
+ <i
24
+ className={theme.helpIcon}
25
+ data-tooltip={help}
26
+ aria-label={help}
27
+ tabIndex={0}></i>
24
28
  </span>
25
29
  ) : null}
26
30
  {label}