@maratus-registry/field 0.0.0 → 0.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/css-files/Field.tsx +10 -17
- package/css-files/Field.types.ts +11 -9
- package/css-files/index.ts +5 -7
- package/css-files/useControl.ts +161 -0
- package/css-files/useDescription.ts +20 -0
- package/css-files/useErrorMessage.ts +40 -0
- package/css-files/useFieldContext.ts +15 -0
- package/css-files/useFieldRoot.ts +21 -0
- package/css-files/useLabel.ts +22 -0
- package/css-modules/Field.tsx +10 -17
- package/css-modules/Field.types.ts +11 -9
- package/css-modules/index.ts +5 -7
- package/css-modules/useControl.ts +161 -0
- package/css-modules/useDescription.ts +20 -0
- package/css-modules/useErrorMessage.ts +40 -0
- package/css-modules/useFieldContext.ts +15 -0
- package/css-modules/useFieldRoot.ts +21 -0
- package/css-modules/useLabel.ts +22 -0
- package/package.json +1 -1
- package/tailwind-css/Field.tsx +10 -17
- package/tailwind-css/Field.types.ts +11 -9
- package/tailwind-css/index.ts +5 -7
- package/tailwind-css/useControl.ts +161 -0
- package/tailwind-css/useDescription.ts +20 -0
- package/tailwind-css/useErrorMessage.ts +40 -0
- package/tailwind-css/useFieldContext.ts +15 -0
- package/tailwind-css/useFieldRoot.ts +21 -0
- package/tailwind-css/useLabel.ts +22 -0
- package/css-files/useField.ts +0 -6
- package/css-modules/useField.ts +0 -6
- package/tailwind-css/useField.ts +0 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { UseFieldRootOptions, UseFieldRootResult } from './Field.types'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import './Field.css'
|
|
4
|
+
|
|
5
|
+
export function useFieldRoot(options: UseFieldRootOptions): UseFieldRootResult {
|
|
6
|
+
const {
|
|
7
|
+
'aria-busy': ariaBusy,
|
|
8
|
+
className,
|
|
9
|
+
isLoading = false,
|
|
10
|
+
...rootProps
|
|
11
|
+
} = options
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
fieldRootProps: {
|
|
15
|
+
...rootProps,
|
|
16
|
+
'aria-busy': ariaBusy ?? (isLoading ? true : undefined),
|
|
17
|
+
className: clsx('maratus__Field__field', className),
|
|
18
|
+
'data-loading': isLoading ? '' : undefined,
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { UseLabelOptions, UseLabelResult } from './Field.types'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import { useFieldContext } from './useFieldContext'
|
|
4
|
+
import './Field.css'
|
|
5
|
+
|
|
6
|
+
export function useLabel(options: UseLabelOptions): UseLabelResult {
|
|
7
|
+
const { children, className, htmlFor, id, ...labelRootProps } = options
|
|
8
|
+
const field = useFieldContext('Label')
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
labelProps: {
|
|
12
|
+
...labelRootProps,
|
|
13
|
+
children: children ?? field.label,
|
|
14
|
+
className: clsx('maratus__Field__label', className),
|
|
15
|
+
'data-loading': field.isLoading ? '' : undefined,
|
|
16
|
+
'data-readonly': field.isReadOnly ? '' : undefined,
|
|
17
|
+
'data-required': field.isRequired ? '' : undefined,
|
|
18
|
+
htmlFor: htmlFor ?? field.controlId,
|
|
19
|
+
id: id ?? field.labelId,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
}
|
package/css-files/useField.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { useControl } from './useControl'
|
|
2
|
-
export { useDescription } from './useDescription'
|
|
3
|
-
export { useErrorMessage } from './useErrorMessage'
|
|
4
|
-
export { useFieldContext } from './useFieldContext'
|
|
5
|
-
export { useFieldRoot } from './useFieldRoot'
|
|
6
|
-
export { useLabel } from './useLabel'
|
package/css-modules/useField.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { useControl } from './useControl'
|
|
2
|
-
export { useDescription } from './useDescription'
|
|
3
|
-
export { useErrorMessage } from './useErrorMessage'
|
|
4
|
-
export { useFieldContext } from './useFieldContext'
|
|
5
|
-
export { useFieldRoot } from './useFieldRoot'
|
|
6
|
-
export { useLabel } from './useLabel'
|
package/tailwind-css/useField.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { useControl } from './useControl'
|
|
2
|
-
export { useDescription } from './useDescription'
|
|
3
|
-
export { useErrorMessage } from './useErrorMessage'
|
|
4
|
-
export { useFieldContext } from './useFieldContext'
|
|
5
|
-
export { useFieldRoot } from './useFieldRoot'
|
|
6
|
-
export { useLabel } from './useLabel'
|