@scaleflex/ui-tw 0.0.145 → 0.0.147
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/form/form.types.d.ts +1 -0
- package/highlight-text/highlight-text.component.d.ts +4 -0
- package/highlight-text/highlight-text.component.js +36 -0
- package/highlight-text/highlight-text.constants.d.ts +3 -0
- package/highlight-text/highlight-text.constants.js +15 -0
- package/highlight-text/highlight-text.types.d.ts +8 -0
- package/highlight-text/highlight-text.types.js +1 -0
- package/highlight-text/highlight-text.utils.d.ts +1 -0
- package/highlight-text/highlight-text.utils.js +3 -0
- package/highlight-text/index.d.ts +3 -0
- package/highlight-text/index.js +2 -0
- package/package.json +2 -2
package/form/form.types.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ export type FormSelectProps = SelectProps & {
|
|
|
93
93
|
options: SelectOption[];
|
|
94
94
|
placeholder?: string;
|
|
95
95
|
icon?: ReactElement;
|
|
96
|
+
popoverClassName?: string;
|
|
96
97
|
};
|
|
97
98
|
export type FormSelectFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
|
|
98
99
|
icon?: ReactElement;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["text", "highlight", "variant", "highlightClassName", "className"];
|
|
4
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { highlightVariants } from './highlight-text.constants';
|
|
7
|
+
import { escapeRegExp } from './highlight-text.utils';
|
|
8
|
+
function HighlightText(_ref) {
|
|
9
|
+
var text = _ref.text,
|
|
10
|
+
highlight = _ref.highlight,
|
|
11
|
+
variant = _ref.variant,
|
|
12
|
+
highlightClassName = _ref.highlightClassName,
|
|
13
|
+
className = _ref.className,
|
|
14
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
15
|
+
if (!(highlight !== null && highlight !== void 0 && highlight.trim())) {
|
|
16
|
+
return /*#__PURE__*/React.createElement("span", _extends({
|
|
17
|
+
"data-slot": "highlight-text",
|
|
18
|
+
className: className
|
|
19
|
+
}, props), text);
|
|
20
|
+
}
|
|
21
|
+
var regex = new RegExp("(".concat(escapeRegExp(highlight), ")"), 'gi');
|
|
22
|
+
var parts = text.split(regex);
|
|
23
|
+
var normalizedHighlight = highlight.toLowerCase();
|
|
24
|
+
return /*#__PURE__*/React.createElement("span", _extends({
|
|
25
|
+
"data-slot": "highlight-text",
|
|
26
|
+
className: className
|
|
27
|
+
}, props), parts.map(function (part, i) {
|
|
28
|
+
return part.toLowerCase() === normalizedHighlight ? /*#__PURE__*/React.createElement("mark", {
|
|
29
|
+
key: i,
|
|
30
|
+
className: cn(highlightVariants({
|
|
31
|
+
variant: variant
|
|
32
|
+
}), highlightClassName)
|
|
33
|
+
}, part) : part;
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
export { HighlightText };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
export var highlightVariants = cva('text-inherit', {
|
|
3
|
+
variants: {
|
|
4
|
+
variant: {
|
|
5
|
+
primary: 'bg-primary/30',
|
|
6
|
+
warning: 'bg-warning/30',
|
|
7
|
+
success: 'bg-success/30',
|
|
8
|
+
info: 'bg-info/30',
|
|
9
|
+
destructive: 'bg-destructive/30'
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
defaultVariants: {
|
|
13
|
+
variant: 'primary'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
import { highlightVariants } from './highlight-text.constants';
|
|
4
|
+
export interface HighlightTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'>, VariantProps<typeof highlightVariants> {
|
|
5
|
+
text: string;
|
|
6
|
+
highlight: string;
|
|
7
|
+
highlightClassName?: string;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeRegExp(string: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.147",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@radix-ui/react-switch": "^1.0.1",
|
|
30
30
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
31
31
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
32
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
32
|
+
"@scaleflex/icons-tw": "^0.0.147",
|
|
33
33
|
"@tanstack/react-table": "^8.21.3",
|
|
34
34
|
"@types/lodash.merge": "^4.6.9",
|
|
35
35
|
"class-variance-authority": "^0.7.1",
|