uibee 2.12.0 → 2.12.1

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,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Check } from 'lucide-react';
3
- import { SelectionWrapper, FieldWrapper } from './shared';
3
+ import { FieldWrapper, InputLabel } from './shared';
4
4
  export default function Checkbox(props) {
5
5
  const { options, onChange, value, label, description, error, info, name, className, ...rest } = props;
6
6
  const selectedValues = Array.isArray(value) ? value : [];
@@ -19,18 +19,19 @@ export default function Checkbox(props) {
19
19
  }, className: 'mb-0' }, option.value))) }) }));
20
20
  }
21
21
  function CheckboxItem(props) {
22
- const { name, label, error, info, description, className, ...inputProps } = props;
22
+ const { name, label, error, ...inputProps } = props;
23
23
  const id = inputProps.value ? `${name}-${inputProps.value}` : name;
24
- return (_jsx(SelectionWrapper, { label: label, name: id, required: inputProps.required, info: info, description: description, error: error, className: className, disabled: inputProps.disabled, children: _jsxs("div", { className: 'relative flex items-center', children: [_jsx("input", { ...inputProps, id: id, name: name, type: 'checkbox', className: `
25
- peer appearance-none h-5 w-5 rounded border border-login-500 bg-login-500/50
24
+ return (_jsxs("div", { className: 'flex items-center gap-2', children: [_jsxs("div", { className: 'relative w-5 h-5 shrink-0', children: [_jsx("input", { ...inputProps, id: id, name: name, type: 'checkbox', className: `
25
+ peer appearance-none rounded border border-login-500 bg-login-500/50
26
26
  checked:bg-login checked:border-login
27
27
  focus:outline-none focus:ring-2 focus:ring-login/50
28
28
  disabled:opacity-50 disabled:cursor-not-allowed
29
29
  cursor-pointer transition-all duration-200
30
+ w-5 h-5 absolute inset-0
30
31
  ${error ? 'border-red-500' : ''}
31
32
  ` }), _jsx(Check, { className: `
32
33
  absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2
33
34
  w-3.5 h-3.5 pointer-events-none text-white opacity-0
34
35
  peer-checked:opacity-100 transition-opacity duration-200
35
- ` })] }) }));
36
+ ` })] }), label && (_jsx(InputLabel, { label: label, name: name, className: 'select-none cursor-pointer' }))] }));
36
37
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { SelectionWrapper, FieldWrapper } from './shared';
2
+ import { FieldWrapper, InputLabel } from './shared';
3
3
  export default function Radio(props) {
4
4
  const { options, onChange, value, label, description, error, info, name, className, ...rest } = props;
5
5
  return (_jsx(FieldWrapper, { label: label, name: name, required: rest.required, info: info, description: description, error: error, className: className, children: _jsx("div", { className: 'flex flex-col gap-2', children: options.map((option) => (_jsx(RadioItem, { name: name, value: option.value, label: option.label, checked: value === option.value, disabled: rest.disabled, onChange: () => {
@@ -8,19 +8,20 @@ export default function Radio(props) {
8
8
  }, className: 'mb-0' }, option.value))) }) }));
9
9
  }
10
10
  function RadioItem(props) {
11
- const { name, label, error, info, description, className, ...inputProps } = props;
11
+ const { name, label, error, ...inputProps } = props;
12
12
  const { value } = inputProps;
13
13
  const id = `${name}-${value}`;
14
- return (_jsx(SelectionWrapper, { label: label, name: id, required: inputProps.required, info: info, description: description, error: error, className: className, disabled: inputProps.disabled, children: _jsxs("div", { className: 'relative flex items-center', children: [_jsx("input", { ...inputProps, id: id, name: name, type: 'radio', className: `
15
- peer appearance-none h-5 w-5 rounded-full border border-login-500 bg-login-500/50
14
+ return (_jsxs("div", { className: 'flex items-center gap-2', children: [_jsxs("div", { className: 'relative w-5 h-5 shrink-0', children: [_jsx("input", { ...inputProps, id: id, name: name, type: 'radio', className: `
15
+ peer appearance-none rounded-full border border-login-500 bg-login-500/50
16
16
  checked:bg-login checked:border-login
17
17
  focus:outline-none focus:ring-2 focus:ring-login/50
18
18
  disabled:opacity-50 disabled:cursor-not-allowed
19
19
  cursor-pointer transition-all duration-200
20
+ w-5 h-5 absolute inset-0
20
21
  ${error ? 'border-red-500' : ''}
21
22
  ` }), _jsx("div", { className: `
22
23
  absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2
23
24
  w-2 h-2 rounded-full bg-white pointer-events-none opacity-0
24
25
  peer-checked:opacity-100 transition-opacity duration-200
25
- ` })] }) }));
26
+ ` })] }), label && (_jsx(InputLabel, { label: label, name: name, className: 'select-none cursor-pointer' }))] }));
26
27
  }
@@ -1,5 +1,4 @@
1
1
  export { default as FieldWrapper } from './fieldWrapper';
2
- export { default as SelectionWrapper } from './selectionWrapper';
3
2
  export { default as InputLabel } from './inputLabel';
4
3
  export { default as InputInfo } from './inputInfo';
5
4
  export { default as InputError } from './inputError';
@@ -1,5 +1,4 @@
1
1
  export { default as FieldWrapper } from './fieldWrapper';
2
- export { default as SelectionWrapper } from './selectionWrapper';
3
2
  export { default as InputLabel } from './inputLabel';
4
3
  export { default as InputInfo } from './inputInfo';
5
4
  export { default as InputError } from './inputError';
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { SelectionWrapper } from './shared';
2
+ import { FieldWrapper } from './shared';
3
3
  export default function Switch(props) {
4
4
  const { name, label, error, info, description, className, switchOnly, ...inputProps } = props;
5
- return (_jsx(SelectionWrapper, { label: label, name: name, required: inputProps.required, info: info, description: description, error: error, hideError: switchOnly, className: className, disabled: inputProps.disabled, children: _jsxs("label", { className: `relative inline-flex items-center cursor-pointer ${switchOnly ? 'h-fit' : 'h-10.5'}`, children: [_jsx("input", { ...inputProps, type: 'checkbox', id: name, name: name, className: 'sr-only peer' }), _jsx("div", { className: `
5
+ return (_jsx(FieldWrapper, { label: label, name: name, required: inputProps.required, info: info, error: error, description: description, className: className, children: _jsxs("label", { className: `relative inline-flex items-center cursor-pointer ${switchOnly ? 'h-fit' : 'h-10.5'}`, children: [_jsx("input", { ...inputProps, type: 'checkbox', id: name, name: name, className: 'sr-only peer' }), _jsx("div", { className: `
6
6
  w-11 h-6 bg-login-500/50 rounded-full peer
7
7
  peer-checked:after:translate-x-full peer-checked:after:border-white
8
8
  after:content-[''] after:absolute ${switchOnly ? 'after:top-0.5' : 'after:top-2.75'} after:left-0.5
@@ -1028,9 +1028,6 @@
1028
1028
  .-mt-0\.5 {
1029
1029
  margin-top: calc(var(--spacing) * -0.5);
1030
1030
  }
1031
- .-mt-1 {
1032
- margin-top: calc(var(--spacing) * -1);
1033
- }
1034
1031
  .mt-1 {
1035
1032
  margin-top: calc(var(--spacing) * 1);
1036
1033
  }
@@ -1064,9 +1061,6 @@
1064
1061
  .ml-1 {
1065
1062
  margin-left: calc(var(--spacing) * 1);
1066
1063
  }
1067
- .ml-7 {
1068
- margin-left: calc(var(--spacing) * 7);
1069
- }
1070
1064
  .page-container {
1071
1065
  display: grid;
1072
1066
  grid-template-columns: 1fr 1rem minmax(0, 72rem) 1rem 1fr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uibee",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Shared components, functions and hooks for reuse across Login projects",
5
5
  "homepage": "https://github.com/Login-Linjeforening-for-IT/uibee#readme",
6
6
  "bugs": {
@@ -1,5 +1,5 @@
1
1
  import { Check } from 'lucide-react'
2
- import { SelectionWrapper, FieldWrapper } from './shared'
2
+ import { FieldWrapper, InputLabel } from './shared'
3
3
 
4
4
  export type CheckboxOption = {
5
5
  label: string
@@ -70,32 +70,24 @@ export default function Checkbox(props: CheckboxProps) {
70
70
  }
71
71
 
72
72
  function CheckboxItem(props: CheckboxItemProps) {
73
- const { name, label, error, info, description, className, ...inputProps } = props
73
+ const { name, label, error, ...inputProps } = props
74
74
  const id = inputProps.value ? `${name}-${inputProps.value}` : name
75
75
 
76
76
  return (
77
- <SelectionWrapper
78
- label={label}
79
- name={id}
80
- required={inputProps.required}
81
- info={info}
82
- description={description}
83
- error={error}
84
- className={className}
85
- disabled={inputProps.disabled}
86
- >
87
- <div className='relative flex items-center'>
77
+ <div className='flex items-center gap-2'>
78
+ <div className='relative w-5 h-5 shrink-0'>
88
79
  <input
89
80
  {...inputProps}
90
81
  id={id}
91
82
  name={name}
92
83
  type='checkbox'
93
84
  className={`
94
- peer appearance-none h-5 w-5 rounded border border-login-500 bg-login-500/50
85
+ peer appearance-none rounded border border-login-500 bg-login-500/50
95
86
  checked:bg-login checked:border-login
96
87
  focus:outline-none focus:ring-2 focus:ring-login/50
97
88
  disabled:opacity-50 disabled:cursor-not-allowed
98
89
  cursor-pointer transition-all duration-200
90
+ w-5 h-5 absolute inset-0
99
91
  ${error ? 'border-red-500' : ''}
100
92
  `}
101
93
  />
@@ -107,6 +99,13 @@ function CheckboxItem(props: CheckboxItemProps) {
107
99
  `}
108
100
  />
109
101
  </div>
110
- </SelectionWrapper>
102
+ {label && (
103
+ <InputLabel
104
+ label={label}
105
+ name={name}
106
+ className='select-none cursor-pointer'
107
+ />
108
+ )}
109
+ </div>
111
110
  )
112
111
  }
@@ -1,4 +1,4 @@
1
- import { SelectionWrapper, FieldWrapper } from './shared'
1
+ import { FieldWrapper, InputLabel } from './shared'
2
2
 
3
3
  export type RadioOption = {
4
4
  label: string
@@ -60,33 +60,25 @@ export default function Radio(props: RadioProps) {
60
60
  }
61
61
 
62
62
  function RadioItem(props: RadioItemProps) {
63
- const { name, label, error, info, description, className, ...inputProps } = props
63
+ const { name, label, error, ...inputProps } = props
64
64
  const { value } = inputProps
65
65
  const id = `${name}-${value}`
66
66
 
67
67
  return (
68
- <SelectionWrapper
69
- label={label}
70
- name={id}
71
- required={inputProps.required}
72
- info={info}
73
- description={description}
74
- error={error}
75
- className={className}
76
- disabled={inputProps.disabled}
77
- >
78
- <div className='relative flex items-center'>
68
+ <div className='flex items-center gap-2'>
69
+ <div className='relative w-5 h-5 shrink-0'>
79
70
  <input
80
71
  {...inputProps}
81
72
  id={id}
82
73
  name={name}
83
74
  type='radio'
84
75
  className={`
85
- peer appearance-none h-5 w-5 rounded-full border border-login-500 bg-login-500/50
76
+ peer appearance-none rounded-full border border-login-500 bg-login-500/50
86
77
  checked:bg-login checked:border-login
87
78
  focus:outline-none focus:ring-2 focus:ring-login/50
88
79
  disabled:opacity-50 disabled:cursor-not-allowed
89
80
  cursor-pointer transition-all duration-200
81
+ w-5 h-5 absolute inset-0
90
82
  ${error ? 'border-red-500' : ''}
91
83
  `}
92
84
  />
@@ -94,8 +86,15 @@ function RadioItem(props: RadioItemProps) {
94
86
  absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2
95
87
  w-2 h-2 rounded-full bg-white pointer-events-none opacity-0
96
88
  peer-checked:opacity-100 transition-opacity duration-200
97
- `}></div>
89
+ `}/>
98
90
  </div>
99
- </SelectionWrapper>
91
+ {label && (
92
+ <InputLabel
93
+ label={label}
94
+ name={name}
95
+ className='select-none cursor-pointer'
96
+ />
97
+ )}
98
+ </div>
100
99
  )
101
100
  }
@@ -1,5 +1,4 @@
1
1
  export { default as FieldWrapper } from './fieldWrapper'
2
- export { default as SelectionWrapper } from './selectionWrapper'
3
2
  export { default as InputLabel } from './inputLabel'
4
3
  export { default as InputInfo } from './inputInfo'
5
4
  export { default as InputError } from './inputError'
@@ -1,4 +1,4 @@
1
- import { SelectionWrapper } from './shared'
1
+ import { FieldWrapper } from './shared'
2
2
 
3
3
  export type SwitchProps = Omit<React.ComponentProps<'input'>, 'name'> & {
4
4
  name: string
@@ -14,16 +14,14 @@ export default function Switch(props: SwitchProps) {
14
14
  const { name, label, error, info, description, className, switchOnly, ...inputProps } = props
15
15
 
16
16
  return (
17
- <SelectionWrapper
17
+ <FieldWrapper
18
18
  label={label}
19
19
  name={name}
20
20
  required={inputProps.required}
21
21
  info={info}
22
- description={description}
23
22
  error={error}
24
- hideError={switchOnly}
23
+ description={description}
25
24
  className={className}
26
- disabled={inputProps.disabled}
27
25
  >
28
26
  <label className={`relative inline-flex items-center cursor-pointer ${switchOnly ? 'h-fit' : 'h-10.5'}`}>
29
27
  <input
@@ -41,8 +39,8 @@ export default function Switch(props: SwitchProps) {
41
39
  after:h-5 after:w-5 after:transition-all peer-checked:bg-login
42
40
  ${inputProps.disabled ? 'opacity-50 cursor-not-allowed' : ''}
43
41
  ${error ? 'ring-1 ring-red-500' : ''}
44
- `}></div>
42
+ `} />
45
43
  </label>
46
- </SelectionWrapper>
44
+ </FieldWrapper>
47
45
  )
48
46
  }
@@ -1,15 +0,0 @@
1
- import { ReactNode } from 'react';
2
- interface SelectionWrapperProps {
3
- label?: string;
4
- name: string;
5
- required?: boolean;
6
- info?: string;
7
- error?: string;
8
- description?: string;
9
- children: ReactNode;
10
- className?: string;
11
- disabled?: boolean;
12
- hideError?: boolean;
13
- }
14
- export default function SelectionWrapper({ label, name, required, info, error, description, children, className, disabled, hideError, }: SelectionWrapperProps): import("react/jsx-runtime").JSX.Element;
15
- export {};
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import InputLabel from './inputLabel';
3
- import InputInfo from './inputInfo';
4
- import InputError from './inputError';
5
- export default function SelectionWrapper({ label, name, required, info, error, description, children, className, disabled, hideError, }) {
6
- return (_jsxs("div", { className: `flex flex-col gap-1 ${className || ''}`, children: [_jsxs("div", { className: 'flex items-start justify-between mb-1', children: [_jsxs("div", { className: 'flex items-center gap-2', children: [children, label && (_jsx(InputLabel, { label: label, name: name, required: required, disabled: disabled, className: 'select-none cursor-pointer' }))] }), info && _jsx(InputInfo, { info: info })] }), description && (_jsx("p", { className: 'text-xs text-login-200 ml-7 -mt-1 mb-1', children: description })), !hideError && _jsx(InputError, { error: error })] }));
7
- }
@@ -1,56 +0,0 @@
1
- import { ReactNode } from 'react'
2
- import InputLabel from './inputLabel'
3
- import InputInfo from './inputInfo'
4
- import InputError from './inputError'
5
-
6
- interface SelectionWrapperProps {
7
- label?: string
8
- name: string
9
- required?: boolean
10
- info?: string
11
- error?: string
12
- description?: string
13
- children: ReactNode
14
- className?: string
15
- disabled?: boolean
16
- hideError?: boolean
17
- }
18
-
19
- export default function SelectionWrapper({
20
- label,
21
- name,
22
- required,
23
- info,
24
- error,
25
- description,
26
- children,
27
- className,
28
- disabled,
29
- hideError,
30
- }: SelectionWrapperProps) {
31
- return (
32
- <div className={`flex flex-col gap-1 ${className || ''}`}>
33
- <div className='flex items-start justify-between mb-1'>
34
- <div className='flex items-center gap-2'>
35
- {children}
36
- {label && (
37
- <InputLabel
38
- label={label}
39
- name={name}
40
- required={required}
41
- disabled={disabled}
42
- className='select-none cursor-pointer'
43
- />
44
- )}
45
- </div>
46
- {info && <InputInfo info={info} />}
47
- </div>
48
- {description && (
49
- <p className='text-xs text-login-200 ml-7 -mt-1 mb-1'>
50
- {description}
51
- </p>
52
- )}
53
- {!hideError && <InputError error={error} />}
54
- </div>
55
- )
56
- }