@seeqdev/qomponents 0.0.82 → 0.0.84
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/dist/TextField/TextField.types.d.ts +6 -1
- package/dist/ToolbarButton/ToolbarButton.types.d.ts +10 -0
- package/dist/index.esm.js +28 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3 -3
- package/dist/utils/svg.d.ts +15 -0
- package/dist/utils/svg.js +20 -0
- package/dist/utils/svg.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,6 +3,9 @@ export interface TextFieldProps {
|
|
|
3
3
|
readonly?: boolean;
|
|
4
4
|
onChange?: React.ChangeEventHandler<FormControlElement>;
|
|
5
5
|
onKeyUp?: React.KeyboardEventHandler<FormControlElement>;
|
|
6
|
+
onKeyDown?: React.KeyboardEventHandler<FormControlElement>;
|
|
7
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
8
|
+
onBlur?: React.FocusEventHandler<FormControlElement>;
|
|
6
9
|
id?: string;
|
|
7
10
|
name?: string;
|
|
8
11
|
size?: 'sm' | 'lg';
|
|
@@ -14,7 +17,9 @@ export interface TextFieldProps {
|
|
|
14
17
|
ref?: any;
|
|
15
18
|
inputGroup?: InputGroupPlacement;
|
|
16
19
|
step?: number | string;
|
|
17
|
-
/** if true error formatting will be displayed */
|
|
18
20
|
showError?: boolean;
|
|
21
|
+
errorText?: string;
|
|
19
22
|
required?: boolean;
|
|
23
|
+
autoComplete?: string;
|
|
24
|
+
autoFocus?: boolean;
|
|
20
25
|
}
|
|
@@ -39,4 +39,14 @@ export interface ToolbarButtonProps {
|
|
|
39
39
|
onHide?: () => void;
|
|
40
40
|
/** set to display arrow or not */
|
|
41
41
|
hasArrow?: boolean;
|
|
42
|
+
/** true if the `icon` string is an svg */
|
|
43
|
+
isPrimaryAnSvg?: boolean;
|
|
44
|
+
/** extra class names to be placed on the primary icon */
|
|
45
|
+
primaryIconExtraClassNames?: string;
|
|
46
|
+
/** height for the icon */
|
|
47
|
+
iconHeight?: number;
|
|
48
|
+
/** width for the icon */
|
|
49
|
+
iconWidth?: number;
|
|
50
|
+
/** viewbox for the icon */
|
|
51
|
+
primaryIconViewbox?: string;
|
|
42
52
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -4561,6 +4561,26 @@ const $cb5cc270b50c6fcd$export$602eac185826482c = $cb5cc270b50c6fcd$export$dd679
|
|
|
4561
4561
|
const $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2 = $cb5cc270b50c6fcd$export$d7e1f420b25549ff;
|
|
4562
4562
|
const $cb5cc270b50c6fcd$export$21b07c8f274aebd5 = $cb5cc270b50c6fcd$export$3152841115e061b2;
|
|
4563
4563
|
|
|
4564
|
+
const SVG_PATH = 'svgpath:';
|
|
4565
|
+
/**
|
|
4566
|
+
* Determines if an icon is SVG
|
|
4567
|
+
*
|
|
4568
|
+
* @param icon - an icon string that will either be an icon class or an SVG path definition (e.g. "fa fa-wrench" or
|
|
4569
|
+
* "svgpath:M 17.0181 0 ...")
|
|
4570
|
+
*/
|
|
4571
|
+
function isSvgIcon(icon) {
|
|
4572
|
+
return icon.startsWith(SVG_PATH);
|
|
4573
|
+
}
|
|
4574
|
+
/**
|
|
4575
|
+
* Retrieves the SVG path from an SVG icon
|
|
4576
|
+
*
|
|
4577
|
+
* @param icon - an SVG icon string including path definition (e.g. "svgpath:M 17.0181 0 ...")
|
|
4578
|
+
* @returns the SVG icon path or an empty string if the supplied icon is not SVG
|
|
4579
|
+
*/
|
|
4580
|
+
function getSvgIconPath(icon) {
|
|
4581
|
+
return isSvgIcon(icon) ? icon.substring(SVG_PATH.length) : '';
|
|
4582
|
+
}
|
|
4583
|
+
|
|
4564
4584
|
const borderStyles$4 = [
|
|
4565
4585
|
'tw-border-solid',
|
|
4566
4586
|
'tw-border',
|
|
@@ -4594,7 +4614,7 @@ const activeBorderStyles = [
|
|
|
4594
4614
|
const bgStyles$3 = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
|
|
4595
4615
|
const disabledClasses$4 = ['tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
|
|
4596
4616
|
const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (React.createElement($cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, { ref: ref, align: align, sideOffset: sideOffset, ...props, asChild: true })));
|
|
4597
|
-
const ToolbarButton = ({ isSmall = false, label, icon, secondIcon, forceSmallIcon = false, tooltipText, id, popoverContent, extraClassNames, testId, tooltipTestId, tooltipOptions, isActive = false, isHtmlTooltip = false, hasArrow = false, disabled = false, onClick, onHide, }) => {
|
|
4617
|
+
const ToolbarButton = ({ isSmall = false, label, icon, secondIcon, forceSmallIcon = false, tooltipText, id, popoverContent, extraClassNames, testId, tooltipTestId, tooltipOptions, isActive = false, isHtmlTooltip = false, hasArrow = false, disabled = false, isPrimaryAnSvg = false, primaryIconExtraClassNames = false, iconHeight = 24, iconWidth = 24, primaryIconViewbox = '0 0 24 24', onClick, onHide, }) => {
|
|
4598
4618
|
let tooltipData = undefined;
|
|
4599
4619
|
if (tooltipText) {
|
|
4600
4620
|
tooltipData = {
|
|
@@ -4614,9 +4634,10 @@ const ToolbarButton = ({ isSmall = false, label, icon, secondIcon, forceSmallIco
|
|
|
4614
4634
|
React.createElement($cb5cc270b50c6fcd$export$41fb9f06171c75f4, { id: id, className: `tw-border-none ${isActive ? 'active' : ''}`, disabled: disabled, "data-testid": testId, onClick: (e) => {
|
|
4615
4635
|
onClick && onClick(e);
|
|
4616
4636
|
} },
|
|
4617
|
-
React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-items-center ${isSmall ? 'tw-py-[1px] tw-px-[5px]' : 'tw-px-2 tw-py-[
|
|
4637
|
+
React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-items-center ${isSmall ? 'tw-py-[1px] tw-px-[5px]' : 'tw-px-2 tw-py-[5px]'} ${disabled ? disabledClasses$4 : isActive ? activeBorderStyles : triggerBorderStyles} ${extraClassNames || ''}` },
|
|
4618
4638
|
React.createElement("span", { className: "tw-nowrap" },
|
|
4619
|
-
React.createElement(
|
|
4639
|
+
isPrimaryAnSvg ? (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", className: `tw-text-sq-text-color dark:tw-text-sq-dark-text ${primaryIconExtraClassNames || ''}`, viewBox: primaryIconViewbox, height: `${iconHeight}px`, width: `${iconWidth}px`, fill: "currentColor", "data-testid": testId },
|
|
4640
|
+
React.createElement("path", { d: getSvgIconPath(icon) }))) : (React.createElement(Icon, { icon: icon, testId: "firstIcon", type: "text", large: !isSmall && !label && !secondIcon && !forceSmallIcon, extraClassNames: `tw-text-sq-text-color dark:tw-text-sq-dark-text` })),
|
|
4620
4641
|
secondIcon && React.createElement(Icon, { icon: secondIcon, type: "text", testId: "secondIcon" }),
|
|
4621
4642
|
popoverContent ? (React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-ml-[3px] tw-text-[8px]", type: "text" })) : undefined),
|
|
4622
4643
|
!isSmall && (React.createElement("small", { className: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-text-[10px]" }, label)))),
|
|
@@ -4653,7 +4674,7 @@ const sizeClasses = {
|
|
|
4653
4674
|
* Textfield.
|
|
4654
4675
|
*/
|
|
4655
4676
|
const TextField = React__default.forwardRef((props, ref) => {
|
|
4656
|
-
const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, required = false, } = props;
|
|
4677
|
+
const { readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, errorText, required = false, autoComplete = 'off' } = props;
|
|
4657
4678
|
const internalRef = useRef(null);
|
|
4658
4679
|
const [cursor, setCursor] = useState(null);
|
|
4659
4680
|
const setAllRefs = (receivedRef) => {
|
|
@@ -4689,7 +4710,9 @@ const TextField = React__default.forwardRef((props, ref) => {
|
|
|
4689
4710
|
borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
|
|
4690
4711
|
}
|
|
4691
4712
|
const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${showError ? errorClasses$2 : borderColorClasses$2} `;
|
|
4692
|
-
return (React__default.createElement("
|
|
4713
|
+
return (React__default.createElement("div", { className: "tw-w-full" },
|
|
4714
|
+
React__default.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: autoComplete, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, step: step, required: required }),
|
|
4715
|
+
errorText && showError && React__default.createElement("div", { className: "tw-text-sq-danger-color tw-text-xs tw-mt-1" }, errorText)));
|
|
4693
4716
|
});
|
|
4694
4717
|
|
|
4695
4718
|
const alignment = 'tw-flex';
|