oihana-next-ui 0.1.45 → 0.1.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oihana-next-ui",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "private": false,
5
5
  "description": "Oihana Next.js UI component library — reusable components, hooks and utilities built with React 19, Next.js, Tailwind CSS and DaisyUI",
6
6
  "author": {
@@ -50,29 +50,29 @@
50
50
  "./themes/*": "./src/themes/*"
51
51
  },
52
52
  "peerDependencies": {
53
- "next": "^16.0.0",
53
+ "next": "16.2.3",
54
54
  "react": "^19.0.0",
55
55
  "react-dom": "^19.0.0",
56
56
  "tailwindcss": "^4.0.0",
57
57
  "daisyui": "^5.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@maskito/core": "^5.1.1",
61
- "@maskito/kit": "^5.1.1",
62
- "@maskito/react": "^5.1.1",
60
+ "@maskito/core": "^5.2.2",
61
+ "@maskito/kit": "^5.2.2",
62
+ "@maskito/react": "^5.2.2",
63
63
  "@use-gesture/react": "^10.3.1",
64
64
  "chroma-js": "^3.2.0",
65
65
  "clsx": "^2.1.1",
66
- "dayjs": "^1.11.19",
66
+ "dayjs": "^1.11.20",
67
67
  "flag-icons": "^7.5.0",
68
68
  "html-react-parser": "^5.2.17",
69
69
  "ky": "^1.14.3",
70
- "motion": "^12.35.0",
71
- "next": "16.1.6",
70
+ "motion": "^12.38.0",
71
+ "next": "16.2.3",
72
72
  "react": "19.2.3",
73
73
  "react-dom": "19.2.3",
74
74
  "react-icons": "^5.6.0",
75
- "react-is": "^19.2.4",
75
+ "react-is": "^19.2.5",
76
76
  "react-markdown": "^10.1.0",
77
77
  "react-syntax-highlighter": "^16.1.1",
78
78
  "react-use": "^17.6.0",
@@ -80,24 +80,24 @@
80
80
  "rehype-raw": "^7.0.0",
81
81
  "remark-breaks": "^4.0.0",
82
82
  "remark-gfm": "^4.0.1",
83
- "sanitize-html": "^2.17.1",
83
+ "sanitize-html": "^2.17.3",
84
84
  "tailwind-merge": "^3.5.0",
85
- "validator": "^13.15.26",
85
+ "validator": "^13.15.35",
86
86
  "vegas-js-core": "^1.0.47"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@biomejs/biome": "2.2.0",
90
- "@tailwindcss/postcss": "^4.2.1",
90
+ "@tailwindcss/postcss": "^4.2.4",
91
91
  "@tailwindcss/typography": "^0.5.19",
92
- "@types/node": "^25.3.3",
92
+ "@types/node": "^25.6.0",
93
93
  "@types/react-syntax-highlighter": "^15.5.13",
94
- "@types/sanitize-html": "^2.16.0",
94
+ "@types/sanitize-html": "^2.16.1",
95
95
  "babel-plugin-react-compiler": "1.0.0",
96
96
  "daisyui": "^5.5.19",
97
97
  "raw-loader": "^4.0.2",
98
98
  "sharp": "^0.34.5",
99
99
  "tailwind-scrollbar": "^4.0.2",
100
- "tailwindcss": "^4.2.1",
100
+ "tailwindcss": "^4.2.4",
101
101
  "tailwindcss-animated": "^2.0.0",
102
102
  "tailwindcss-opentype": "^1.2.0"
103
103
  },
@@ -17,6 +17,7 @@ import { MdColorLens as ColorIcon } from 'react-icons/md' ;
17
17
  *
18
18
  * @param {Object} props
19
19
  * @param {boolean} [props.alpha=false] - Allow alpha channel (8 chars: #RRGGBBAA)
20
+ * @param {number} [props.length] - Explicit hex length (3, 4, 6 or 8). Overrides the default derived from `alpha`. When set, validation requires exactly this length.
20
21
  * @param {boolean} [props.prefixed=true] - Display "#" prefix
21
22
  * @param {boolean} [props.showColorPreview=true] - Show color preview in icon background
22
23
  * @param {boolean} [props.showValidationError=false] - Show error message for invalid colors
@@ -71,6 +72,7 @@ const InputHexColor =
71
72
  error: externalError,
72
73
  icon,
73
74
  iconClassName = 'aspect-square',
75
+ length,
74
76
  onChange: onChangeFromProps,
75
77
  prefixed = true,
76
78
  showColorPreview = true,
@@ -85,6 +87,10 @@ const InputHexColor =
85
87
  const [ currentColor , setCurrentColor ] = useState( externalValue || defaultValue || '' ) ;
86
88
  const [ internalError, setInternalError ] = useState( '' ) ;
87
89
 
90
+ // --------- Resolve max length (explicit length wins over alpha default)
91
+
92
+ const maxLength = length ?? ( alpha ? 8 : 6 ) ;
93
+
88
94
  // --------- Transformations
89
95
 
90
96
  const transform = value =>
@@ -94,8 +100,7 @@ const InputHexColor =
94
100
  return '' ;
95
101
  }
96
102
 
97
- const cleaned = value.replace( /([^0-9A-F]+)/gi, '' ) ;
98
- const maxLength = alpha ? 8 : 6 ;
103
+ const cleaned = value.replace( /([^0-9A-F]+)/gi, '' ) ;
99
104
 
100
105
  return cleaned.substring( 0, maxLength ).toUpperCase() ;
101
106
  } ;
@@ -108,19 +113,21 @@ const InputHexColor =
108
113
  return true ;
109
114
  }
110
115
 
111
- const isValid = validateHexColor( value , alpha ) ;
116
+ // When length is explicit, require exact length; otherwise accept any valid hex form.
117
+ const isValid = length !== undefined
118
+ ? ( value.length === length && validateHexColor( value, alpha ) )
119
+ : validateHexColor( value, alpha ) ;
112
120
 
113
121
  if ( showValidationError )
114
122
  {
115
123
  if ( !isValid )
116
124
  {
117
- const expectedLength = alpha ? 8 : 6 ;
118
125
  const defaultPattern = 'Invalid hex color (expected {0} characters: 0-9, A-F)' ;
119
126
 
120
127
  setInternalError( fastFormat
121
128
  (
122
129
  validationError ?? defaultPattern,
123
- String( expectedLength )
130
+ String( maxLength )
124
131
  ) ) ;
125
132
  }
126
133
  else
@@ -134,12 +141,14 @@ const InputHexColor =
134
141
 
135
142
  const format = prefixed ? value =>
136
143
  {
137
- return value ? `#${value}` : '' ;
144
+ if ( !value ) return '' ;
145
+ return value.startsWith( '#' ) ? value : `#${value}` ;
138
146
  } : undefined ;
139
147
 
140
148
  const process = ( value ) =>
141
149
  {
142
- return value ? `#${value}` : '' ;
150
+ if ( !value ) return '' ;
151
+ return value.startsWith( '#' ) ? value : `#${value}` ;
143
152
  } ;
144
153
 
145
154
  // --------- Intercept onChange to update currentColor
@@ -60,11 +60,12 @@ const InputHexColorDemo = () =>
60
60
 
61
61
  {/* Short format (3 chars) */}
62
62
  <InputHexColor
63
- label = "Short Format (3 chars)"
63
+ length = { 3 }
64
+ label = "Short Format (3 chars)"
64
65
  defaultValue = "F53"
65
- icon = { <ColorIcon /> }
66
- placeholder = "FFF"
67
- helper = "Short format: #rgb"
66
+ icon = { <ColorIcon /> }
67
+ placeholder = "FFF"
68
+ helper = "Short format: #rgb"
68
69
  />
69
70
 
70
71
  {/* With validation error */}
package/src/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const version = "0.1.45" ;
1
+ const version = "0.1.46" ;
2
2
 
3
3
  export default version ;