uibee 2.7.4 → 2.7.6

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.
@@ -9,16 +9,16 @@ export default function Button({ text, className, icon, path, color, type, onCli
9
9
  ${bg} cursor-pointer px-4 rounded-md min-h-8 h-8 flex
10
10
  justify-evenly items-center gap-2 select-none
11
11
  focus:outline-none border-0 outline w-fit ${className}
12
- `, children: [_jsx("h1", { className: 'font-bold', children: icon || '' }), _jsx("h1", { className: 'w-fit', children: text })] }));
12
+ `, children: [_jsx("h1", { className: 'font-bold', children: icon || '' }), _jsx("h1", { className: 'min-w-fit w-fit', children: text })] }));
13
13
  }
14
14
  if (disabled) {
15
15
  return (_jsxs("div", { className: `
16
- ${bg} cursor-not-allowed px-4 rounded-md h-8 flex
17
- justify-evenly items-center gap-2 select-none w-fit
18
- `, children: [_jsx("h1", { className: 'font-bold', children: icon || '' }), _jsx("h1", { className: 'w-fit', children: text })] }));
16
+ ${bg} cursor-not-allowed px-4 rounded-md h-8 flex w-fit
17
+ justify-evenly items-center gap-2 select-none ${className}
18
+ `, children: [_jsx("h1", { className: 'font-bold', children: icon || '' }), _jsx("h1", { className: 'min-w-fit w-fit', children: text })] }));
19
19
  }
20
20
  return (_jsxs(Link, { href: path, className: `
21
- ${bg} cursor-pointer px-4 rounded-md h-8 flex
22
- justify-evenly items-center gap-2 select-none w-fit
23
- `, children: [_jsx("h1", { className: 'font-bold', children: icon || '' }), _jsx("h1", { className: 'w-fit', children: text })] }));
21
+ ${bg} cursor-pointer px-4 rounded-md h-8 flex w-fit
22
+ justify-evenly items-center gap-2 select-none ${className}
23
+ `, children: [_jsx("h1", { className: 'font-bold', children: icon || '' }), _jsx("h1", { className: 'min-w-fit w-fit', children: text })] }));
24
24
  }
@@ -1,6 +1,7 @@
1
1
  export type Option = {
2
2
  value: string | number;
3
3
  label: string;
4
+ image?: string;
4
5
  };
5
6
  export type SelectProps = {
6
7
  label?: string;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useEffect } from 'react';
4
+ import Image from 'next/image';
4
5
  import { useClickOutside } from '../../hooks';
5
6
  import { ChevronDown, X } from 'lucide-react';
6
7
  import { FieldWrapper } from './shared';
@@ -39,7 +40,7 @@ export default function Select({ label, name, value, onChange, options, error, c
39
40
  flex items-center justify-between
40
41
  ${error ? 'border-red-500 focus:border-red-500 focus:ring-red-500' : ''}
41
42
  ${!selectedOption ? 'text-login-200' : ''}
42
- `, title: label, children: [_jsx("span", { className: 'truncate', children: selectedOption ? selectedOption.label : placeholder }), _jsxs("div", { className: 'absolute inset-y-0 right-0 flex items-center px-2 gap-1', children: [clearable && selectedOption && !disabled && (_jsx("div", { role: 'button', onClick: handleClear, className: `
43
+ `, title: label, children: [_jsxs("div", { className: 'flex items-center gap-2 truncate', children: [selectedOption?.image && (_jsx(Image, { src: selectedOption.image, alt: '', width: 30, height: 20, className: 'rounded-xs object-cover shrink-0' })), _jsx("span", { className: 'truncate', children: selectedOption ? selectedOption.label : placeholder })] }), _jsxs("div", { className: 'absolute inset-y-0 right-0 flex items-center px-2 gap-1', children: [clearable && selectedOption && !disabled && (_jsx("div", { role: 'button', onClick: handleClear, className: `
43
44
  p-1 hover:bg-login-500 rounded-full text-login-200
44
45
  hover:text-red-400 transition-colors cursor-pointer
45
46
  `, title: 'Clear selection', children: _jsx(X, { className: 'w-3 h-3' }) })), _jsx("div", { className: `
@@ -49,9 +50,10 @@ export default function Select({ label, name, value, onChange, options, error, c
49
50
  `, children: _jsx(ChevronDown, { className: 'w-4 h-4' }) })] })] }), isOpen && (_jsx("div", { className: `
50
51
  absolute z-50 w-full mt-1 bg-login-600 border border-login-500
51
52
  rounded-md shadow-lg max-h-60 overflow-auto noscroll
52
- `, children: options.length > 0 ? (_jsx("ul", { className: 'py-1', role: 'listbox', children: options.map((option) => (_jsx("li", { role: 'option', "aria-selected": selectedOption?.value === option.value, children: _jsx("button", { type: 'button', onClick: () => handleSelect(option), className: `
53
+ `, children: options.length > 0 ? (_jsx("ul", { className: 'py-1', role: 'listbox', children: options.map((option) => (_jsx("li", { role: 'option', "aria-selected": selectedOption?.value === option.value, children: _jsxs("button", { type: 'button', onClick: () => handleSelect(option), className: `
53
54
  w-full text-left px-3 py-2 text-sm
54
55
  hover:bg-login-500 transition-colors duration-150
56
+ flex items-center gap-2
55
57
  ${selectedOption?.value === option.value ? 'bg-login-500 text-login' : 'text-login-text'}
56
- `, children: option.label }) }, option.value))) })) : (_jsx("div", { className: 'px-3 py-2 text-sm text-login-200', children: "No options available" })) }))] }), _jsx("input", { type: 'hidden', name: name, value: selectedOption?.value || '', required: required })] }));
58
+ `, children: [option.image && (_jsx(Image, { src: option.image, alt: '', width: 75, height: 25, className: 'rounded-md object-cover shrink-0' })), _jsx("span", { className: 'truncate', children: option.label })] }) }, option.value))) })) : (_jsx("div", { className: 'px-3 py-2 text-sm text-login-200', children: "No options available" })) }))] }), _jsx("input", { type: 'hidden', name: name, value: selectedOption?.value || '', required: required })] }));
57
59
  }
@@ -41,6 +41,7 @@
41
41
  --font-weight-bold: 700;
42
42
  --font-weight-extrabold: 800;
43
43
  --tracking-tight: -0.025em;
44
+ --radius-xs: 0.125rem;
44
45
  --radius-md: 0.375rem;
45
46
  --radius-lg: 0.5rem;
46
47
  --radius-xl: 0.75rem;
@@ -558,6 +559,9 @@
558
559
  .min-w-70 {
559
560
  min-width: calc(var(--spacing) * 70);
560
561
  }
562
+ .min-w-fit {
563
+ min-width: fit-content;
564
+ }
561
565
  .flex-1 {
562
566
  flex: 1;
563
567
  }
@@ -707,6 +711,9 @@
707
711
  .rounded-xl {
708
712
  border-radius: var(--radius-xl);
709
713
  }
714
+ .rounded-xs {
715
+ border-radius: var(--radius-xs);
716
+ }
710
717
  .border {
711
718
  border-style: var(--tw-border-style);
712
719
  border-width: 1px;
@@ -832,6 +839,9 @@
832
839
  .object-contain {
833
840
  object-fit: contain;
834
841
  }
842
+ .object-cover {
843
+ object-fit: cover;
844
+ }
835
845
  .p-1 {
836
846
  padding: calc(var(--spacing) * 1);
837
847
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uibee",
3
- "version": "2.7.4",
3
+ "version": "2.7.6",
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": {
@@ -40,7 +40,7 @@ export default function Button({
40
40
  `}
41
41
  >
42
42
  <h1 className='font-bold'>{icon || ''}</h1>
43
- <h1 className='w-fit'>{text}</h1>
43
+ <h1 className='min-w-fit w-fit'>{text}</h1>
44
44
  </button>
45
45
  )
46
46
  }
@@ -49,12 +49,12 @@ export default function Button({
49
49
  return (
50
50
  <div
51
51
  className={`
52
- ${bg} cursor-not-allowed px-4 rounded-md h-8 flex
53
- justify-evenly items-center gap-2 select-none w-fit
52
+ ${bg} cursor-not-allowed px-4 rounded-md h-8 flex w-fit
53
+ justify-evenly items-center gap-2 select-none ${className}
54
54
  `}
55
55
  >
56
56
  <h1 className='font-bold'>{icon || ''}</h1>
57
- <h1 className='w-fit'>{text}</h1>
57
+ <h1 className='min-w-fit w-fit'>{text}</h1>
58
58
  </div>
59
59
  )
60
60
  }
@@ -63,12 +63,12 @@ export default function Button({
63
63
  <Link
64
64
  href={path}
65
65
  className={`
66
- ${bg} cursor-pointer px-4 rounded-md h-8 flex
67
- justify-evenly items-center gap-2 select-none w-fit
66
+ ${bg} cursor-pointer px-4 rounded-md h-8 flex w-fit
67
+ justify-evenly items-center gap-2 select-none ${className}
68
68
  `}
69
69
  >
70
70
  <h1 className='font-bold'>{icon || ''}</h1>
71
- <h1 className='w-fit'>{text}</h1>
71
+ <h1 className='min-w-fit w-fit'>{text}</h1>
72
72
  </Link>
73
73
  )
74
74
  }
@@ -1,6 +1,7 @@
1
1
  'use client'
2
2
 
3
3
  import { useState, useEffect } from 'react'
4
+ import Image from 'next/image'
4
5
  import { useClickOutside } from '../../hooks'
5
6
  import { ChevronDown, X } from 'lucide-react'
6
7
  import { FieldWrapper } from './shared'
@@ -8,6 +9,7 @@ import { FieldWrapper } from './shared'
8
9
  export type Option = {
9
10
  value: string | number
10
11
  label: string
12
+ image?: string
11
13
  }
12
14
 
13
15
  export type SelectProps = {
@@ -98,9 +100,20 @@ export default function Select({
98
100
  `}
99
101
  title={label}
100
102
  >
101
- <span className='truncate'>
102
- {selectedOption ? selectedOption.label : placeholder}
103
- </span>
103
+ <div className='flex items-center gap-2 truncate'>
104
+ {selectedOption?.image && (
105
+ <Image
106
+ src={selectedOption.image}
107
+ alt=''
108
+ width={30}
109
+ height={20}
110
+ className='rounded-xs object-cover shrink-0'
111
+ />
112
+ )}
113
+ <span className='truncate'>
114
+ {selectedOption ? selectedOption.label : placeholder}
115
+ </span>
116
+ </div>
104
117
  <div className='absolute inset-y-0 right-0 flex items-center px-2 gap-1'>
105
118
  {clearable && selectedOption && !disabled && (
106
119
  <div
@@ -140,10 +153,20 @@ export default function Select({
140
153
  className={`
141
154
  w-full text-left px-3 py-2 text-sm
142
155
  hover:bg-login-500 transition-colors duration-150
156
+ flex items-center gap-2
143
157
  ${selectedOption?.value === option.value ? 'bg-login-500 text-login' : 'text-login-text'}
144
158
  `}
145
159
  >
146
- {option.label}
160
+ {option.image && (
161
+ <Image
162
+ src={option.image}
163
+ alt=''
164
+ width={75}
165
+ height={25}
166
+ className='rounded-md object-cover shrink-0'
167
+ />
168
+ )}
169
+ <span className='truncate'>{option.label}</span>
147
170
  </button>
148
171
  </li>
149
172
  ))}