@economic/taco 0.0.4-alpha.0 → 0.0.8-alpha.0
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/components/Button/Button.d.ts +5 -0
- package/dist/components/Combobox/Combobox.d.ts +4 -0
- package/dist/components/Combobox/useCombobox.d.ts +1 -1
- package/dist/components/Dialog/Context.d.ts +2 -0
- package/dist/components/Dialog/Dialog.d.ts +13 -9
- package/dist/components/Dialog/components/Content.d.ts +9 -8
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Button/util.js +7 -1
- package/dist/esm/components/Button/util.js.map +1 -1
- package/dist/esm/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/components/Combobox/useCombobox.js +15 -3
- package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/components/Dialog/Context.js +2 -0
- package/dist/esm/components/Dialog/Context.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +8 -2
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/components/Content.js +20 -10
- package/dist/esm/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/components/Dialog/components/Drawer.js +3 -1
- package/dist/esm/components/Dialog/components/Drawer.js.map +1 -1
- package/dist/esm/components/Dialog/components/Extra.js +3 -1
- package/dist/esm/components/Dialog/components/Extra.js.map +1 -1
- package/dist/esm/components/Hanger/Hanger.js +11 -1
- package/dist/esm/components/Hanger/Hanger.js.map +1 -1
- package/dist/esm/components/Input/Input.js +1 -1
- package/dist/esm/components/Input/Input.js.map +1 -1
- package/dist/esm/components/Menu/Menu.js +1 -1
- package/dist/esm/components/Menu/components/Content.js +2 -2
- package/dist/esm/components/Menu/components/Header.js +1 -1
- package/dist/esm/components/Menu/components/Item.js +1 -1
- package/dist/esm/components/Menu/components/Separator.js +1 -1
- package/dist/esm/components/Menu/components/Trigger.js +2 -2
- package/dist/esm/components/Pagination/Pagination.js +1 -1
- package/dist/esm/components/Popover/Popover.js +11 -1
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js +3 -3
- package/dist/esm/components/Table/components/Table.js +1 -2
- package/dist/esm/components/Table/components/Table.js.map +1 -1
- package/dist/esm/components/Table/components/WindowedTable.js +0 -1
- package/dist/esm/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/components/Table/hooks/plugins/useRowActions.js +1 -1
- package/dist/esm/components/Table/hooks/useTable.js +4 -1
- package/dist/esm/components/Table/hooks/useTable.js.map +1 -1
- package/dist/esm/components/Tour/Tour.js +1 -1
- package/dist/esm/index.css +8 -8
- package/dist/esm/index.js +3 -3
- package/dist/index.css +8 -8
- package/dist/taco.cjs.development.js +1593 -1535
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
- package/types.json +811 -469
@@ -12,6 +12,8 @@ var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
12
12
|
var PopoverPrimitive = require('@radix-ui/react-popover');
|
13
13
|
var uuid = require('uuid');
|
14
14
|
var framerMotion = require('framer-motion');
|
15
|
+
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
16
|
+
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
15
17
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
16
18
|
var interactions = require('@react-aria/interactions');
|
17
19
|
var ReactDayPicker = _interopDefault(require('react-day-picker'));
|
@@ -19,8 +21,6 @@ var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
19
21
|
var keycode = _interopDefault(require('keycode'));
|
20
22
|
var debounce = _interopDefault(require('lodash/debounce'));
|
21
23
|
var dateFns = require('date-fns');
|
22
|
-
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
23
|
-
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
24
24
|
var reactTable = require('react-table');
|
25
25
|
var reactIntersectionObserver = require('react-intersection-observer');
|
26
26
|
var focus = require('@react-aria/focus');
|
@@ -3895,8 +3895,18 @@ var HangerContext = /*#__PURE__*/React.createContext({
|
|
3895
3895
|
ref: null
|
3896
3896
|
});
|
3897
3897
|
var Anchor = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
3898
|
+
var _props$children;
|
3899
|
+
|
3898
3900
|
var context = React.useContext(HangerContext);
|
3901
|
+
var children = props.children;
|
3902
|
+
|
3903
|
+
if (React.isValidElement(props.children) && typeof ((_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.type) === 'function') {
|
3904
|
+
console.warn("Hanger.Anchor requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '" + props.children.type.name + "' in React.forwardRef()? Taco has wrapped '" + props.children.type.name + "' in a 'span' to maintain functionality, but this may cause unintended behaviour");
|
3905
|
+
children = React.createElement("span", null, props.children);
|
3906
|
+
}
|
3907
|
+
|
3899
3908
|
return React.createElement(PopoverPrimitive.Anchor, Object.assign({}, context.props, props, {
|
3909
|
+
children: children,
|
3900
3910
|
ref: mergeRefs([context.ref, ref]),
|
3901
3911
|
asChild: true
|
3902
3912
|
}));
|
@@ -3949,32 +3959,11 @@ var Hanger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
3949
3959
|
Hanger.Anchor = Anchor;
|
3950
3960
|
Hanger.Content = Content$1;
|
3951
3961
|
|
3952
|
-
|
3953
|
-
var
|
3954
|
-
|
3955
|
-
draggable: false,
|
3956
|
-
drawer: undefined,
|
3957
|
-
elements: {
|
3958
|
-
drawer: undefined,
|
3959
|
-
extra: undefined
|
3960
|
-
},
|
3961
|
-
onClose: function onClose() {},
|
3962
|
-
props: {},
|
3963
|
-
ref: null,
|
3964
|
-
size: 'sm'
|
3965
|
-
});
|
3966
|
-
var useCurrentDialog = function useCurrentDialog() {
|
3967
|
-
return React.useContext(DialogContext);
|
3962
|
+
var MenuContext = /*#__PURE__*/React.createContext(undefined);
|
3963
|
+
var useCurrentMenu = function useCurrentMenu() {
|
3964
|
+
return React.useContext(MenuContext);
|
3968
3965
|
};
|
3969
3966
|
|
3970
|
-
var Trigger$1 = /*#__PURE__*/React.forwardRef(function DialogTrigger(props, ref) {
|
3971
|
-
var dialog = useCurrentDialog();
|
3972
|
-
return React.createElement(DialogPrimitive.Trigger, Object.assign({}, dialog.props, props, {
|
3973
|
-
ref: mergeRefs([dialog.ref, ref]),
|
3974
|
-
asChild: true
|
3975
|
-
}));
|
3976
|
-
});
|
3977
|
-
|
3978
3967
|
var useProxiedRef = function useProxiedRef(ref) {
|
3979
3968
|
var internalRef = React.useRef(null);
|
3980
3969
|
React.useEffect(function () {
|
@@ -3989,891 +3978,1429 @@ var useProxiedRef = function useProxiedRef(ref) {
|
|
3989
3978
|
return internalRef;
|
3990
3979
|
};
|
3991
3980
|
|
3992
|
-
var
|
3993
|
-
var _React$useState = React__default.useState({
|
3994
|
-
x: 0,
|
3995
|
-
y: 0
|
3996
|
-
}),
|
3997
|
-
position = _React$useState[0],
|
3998
|
-
setPosition = _React$useState[1];
|
3981
|
+
var _excluded$a = ["children", "placement"];
|
3999
3982
|
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
3983
|
+
var getAppearanceClasses = function getAppearanceClasses(appearance) {
|
3984
|
+
switch (appearance) {
|
3985
|
+
case 'primary':
|
3986
|
+
return 'wcag-blue border-blue';
|
4003
3987
|
|
4004
|
-
|
3988
|
+
case 'danger':
|
3989
|
+
return 'wcag-red border-red';
|
4005
3990
|
|
4006
|
-
|
4007
|
-
|
4008
|
-
return;
|
4009
|
-
}
|
3991
|
+
case 'ghost':
|
3992
|
+
return 'bg-white text-blue border-blue yt-shadow-blue';
|
4010
3993
|
|
4011
|
-
|
4012
|
-
|
4013
|
-
y = _ref.y;
|
4014
|
-
x += event.deltaX;
|
4015
|
-
y += event.deltaY;
|
4016
|
-
return {
|
4017
|
-
x: x,
|
4018
|
-
y: y
|
4019
|
-
};
|
4020
|
-
});
|
4021
|
-
}
|
4022
|
-
}),
|
4023
|
-
moveProps = _useMove.moveProps;
|
3994
|
+
case 'discrete':
|
3995
|
+
return 'wcag-white border-grey yt-shadow';
|
4024
3996
|
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
}
|
3997
|
+
case 'default':
|
3998
|
+
default:
|
3999
|
+
return 'wcag-grey-light border-grey';
|
4000
|
+
}
|
4029
4001
|
};
|
4030
4002
|
|
4031
|
-
var
|
4032
|
-
var
|
4033
|
-
|
4034
|
-
};
|
4003
|
+
var Content$2 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4004
|
+
var internalRef = useProxiedRef(ref);
|
4005
|
+
var menu = useCurrentMenu();
|
4035
4006
|
|
4036
|
-
var
|
4037
|
-
|
4038
|
-
var _props$as = props.as,
|
4039
|
-
Tag = _props$as === void 0 ? 'span' : _props$as,
|
4007
|
+
var children = props.children,
|
4008
|
+
side = props.placement,
|
4040
4009
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$a);
|
4041
4010
|
|
4042
|
-
var className = cn('
|
4043
|
-
return React.createElement(
|
4011
|
+
var className = cn('border rounded block outline-none p-1', getAppearanceClasses(menu === null || menu === void 0 ? void 0 : menu.appearance), props.className);
|
4012
|
+
return React.createElement(DropdownMenuPrimitive.Content, Object.assign({}, otherProps, {
|
4013
|
+
align: "start",
|
4044
4014
|
className: className,
|
4045
|
-
"data-taco": "
|
4046
|
-
|
4047
|
-
|
4015
|
+
"data-taco": "menu",
|
4016
|
+
side: side,
|
4017
|
+
sideOffset: 2,
|
4018
|
+
style: {
|
4019
|
+
minWidth: menu === null || menu === void 0 ? void 0 : menu.minWidth
|
4020
|
+
},
|
4021
|
+
ref: internalRef
|
4022
|
+
}), children);
|
4048
4023
|
});
|
4049
4024
|
|
4050
|
-
var
|
4051
|
-
|
4052
|
-
|
4053
|
-
|
4054
|
-
|
4055
|
-
}
|
4056
|
-
|
4057
|
-
|
4058
|
-
className: "mt-8 flex justify-end",
|
4059
|
-
ref: ref
|
4060
|
-
}), React.createElement(Group, null, props.children));
|
4061
|
-
});
|
4062
|
-
var Close$1 = /*#__PURE__*/React.forwardRef(function DialogClose(props, ref) {
|
4063
|
-
var dialog = useCurrentDialog();
|
4064
|
-
return React.createElement(DialogPrimitive.Close, Object.assign({
|
4065
|
-
onClick: dialog.onClose
|
4066
|
-
}, props, {
|
4067
|
-
ref: ref,
|
4068
|
-
asChild: true
|
4025
|
+
var _excluded$b = ["icon", "shortcut"];
|
4026
|
+
var Icon$1 = function Icon$1(_ref) {
|
4027
|
+
var name = _ref.name;
|
4028
|
+
return React.createElement("span", {
|
4029
|
+
className: "absolute left-0 ml-1"
|
4030
|
+
}, React.createElement(Icon, {
|
4031
|
+
className: "!h-5 !w-5 -ml-px -mt-px",
|
4032
|
+
name: name
|
4069
4033
|
}));
|
4070
|
-
}
|
4071
|
-
var Content$2 = /*#__PURE__*/React.forwardRef(function DialogContent(props, ref) {
|
4072
|
-
var dialog = useCurrentDialog();
|
4073
|
-
var internalRef = useProxiedRef(ref);
|
4034
|
+
};
|
4074
4035
|
|
4075
|
-
|
4076
|
-
|
4077
|
-
|
4036
|
+
var getAppearanceClasses$1 = function getAppearanceClasses(appearance) {
|
4037
|
+
switch (appearance) {
|
4038
|
+
case 'primary':
|
4039
|
+
return 'wcag-blue aria-disabled:text-blue-dark focus:wcag-blue-light';
|
4078
4040
|
|
4079
|
-
|
4080
|
-
|
4081
|
-
|
4041
|
+
case 'danger':
|
4042
|
+
return 'wcag-red aria-disabled:text-red-dark focus:wcag-red-light';
|
4043
|
+
|
4044
|
+
case 'ghost':
|
4045
|
+
return 'text-blue aria-disabled:text-grey focus:wcag-blue';
|
4046
|
+
|
4047
|
+
case 'discrete':
|
4048
|
+
return 'text-black aria-disabled:text-grey focus:wcag-blue-lightest';
|
4082
4049
|
|
4050
|
+
case 'default':
|
4051
|
+
default:
|
4052
|
+
return 'wcag-grey-light aria-disabled:text-grey-darker focus:wcag-grey-dark';
|
4053
|
+
}
|
4054
|
+
};
|
4083
4055
|
|
4056
|
+
var useItemStyling = function useItemStyling(_ref2) {
|
4057
|
+
var disabled = _ref2.disabled,
|
4058
|
+
indented = _ref2.indented,
|
4059
|
+
className = _ref2.className;
|
4084
4060
|
var menu = useCurrentMenu();
|
4085
|
-
|
4061
|
+
React.useEffect(function () {
|
4062
|
+
if (indented && !(menu !== null && menu !== void 0 && menu.indented)) {
|
4063
|
+
menu === null || menu === void 0 ? void 0 : menu.registerIndentation();
|
4064
|
+
}
|
4065
|
+
}, [indented]);
|
4066
|
+
return cn('flex items-center justify-start h-7 pr-1.5 relative rounded w-full focus:outline-none group', getAppearanceClasses$1(menu === null || menu === void 0 ? void 0 : menu.appearance), {
|
4067
|
+
'pl-7': menu === null || menu === void 0 ? void 0 : menu.indented,
|
4068
|
+
'pl-1.5': !(menu !== null && menu !== void 0 && menu.indented),
|
4069
|
+
'cursor-pointer': !disabled,
|
4070
|
+
'cursor-not-allowed': disabled
|
4071
|
+
}, className);
|
4072
|
+
};
|
4073
|
+
var Shortcut = function Shortcut(props) {
|
4074
|
+
var menu = useCurrentMenu();
|
4075
|
+
var appearance;
|
4086
4076
|
|
4087
|
-
|
4088
|
-
|
4089
|
-
|
4090
|
-
|
4077
|
+
switch (menu === null || menu === void 0 ? void 0 : menu.appearance) {
|
4078
|
+
case 'primary':
|
4079
|
+
appearance = 'text-blue-lightest group-focus:text-black';
|
4080
|
+
break;
|
4081
|
+
|
4082
|
+
case 'danger':
|
4083
|
+
appearance = 'text-red-lightest group-focus:text-white';
|
4084
|
+
break;
|
4085
|
+
|
4086
|
+
case 'ghost':
|
4087
|
+
appearance = 'text-blue-light group-focus:text-blue-lightest';
|
4088
|
+
break;
|
4089
|
+
|
4090
|
+
case 'discrete':
|
4091
|
+
appearance = 'text-grey-darker group-focus:text-blue-light';
|
4092
|
+
break;
|
4093
|
+
|
4094
|
+
case 'default':
|
4095
|
+
default:
|
4096
|
+
appearance = 'text-grey-darkest';
|
4097
|
+
break;
|
4091
4098
|
}
|
4092
4099
|
|
4093
|
-
var className = cn('
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
}, props.className); // the chosen behaviour in taco is that outside clicks do not close the dialog
|
4100
|
+
var className = cn('ml-auto pl-3', appearance);
|
4101
|
+
return React.createElement("span", Object.assign({}, props, {
|
4102
|
+
className: className
|
4103
|
+
}));
|
4104
|
+
};
|
4105
|
+
var Item$1 = /*#__PURE__*/React.forwardRef(function MenuItem(props, ref) {
|
4106
|
+
var icon = props.icon,
|
4107
|
+
shortcut = props.shortcut,
|
4108
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$b);
|
4103
4109
|
|
4104
|
-
var
|
4105
|
-
|
4106
|
-
|
4110
|
+
var className = useItemStyling({
|
4111
|
+
disabled: props.disabled,
|
4112
|
+
indented: !!icon,
|
4113
|
+
className: props.className
|
4114
|
+
});
|
4115
|
+
var handleClick; // radix has a bug that does not disable clicks when disabled is set on items
|
4107
4116
|
|
4108
|
-
|
4117
|
+
if (!otherProps.disabled) {
|
4118
|
+
handleClick = props.onClick;
|
4109
4119
|
|
4110
|
-
|
4111
|
-
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
|
4120
|
+
if (props['aria-haspopup']) {
|
4121
|
+
handleClick = function handleClick(event) {
|
4122
|
+
if (props.onClick) {
|
4123
|
+
event.persist();
|
4124
|
+
props.onClick(event);
|
4125
|
+
event.preventDefault();
|
4126
|
+
}
|
4127
|
+
};
|
4128
|
+
}
|
4117
4129
|
}
|
4118
4130
|
|
4119
|
-
return React.createElement(
|
4120
|
-
asChild: true
|
4121
|
-
}, React.createElement(Backdrop, null, React.createElement(DialogPrimitive.Content, Object.assign({}, props, {
|
4131
|
+
return React.createElement(DropdownMenuPrimitive.Item, Object.assign({}, otherProps, {
|
4122
4132
|
className: className,
|
4123
|
-
|
4124
|
-
onInteractOutside: handleInteractOutside,
|
4125
|
-
onCloseAutoFocus: handleCloseAutoFocus,
|
4126
|
-
ref: ref,
|
4127
|
-
style: _extends({}, props.style, {
|
4128
|
-
left: dialog.draggable ? "calc(50% + " + position.x + "px)" : undefined,
|
4129
|
-
top: dialog.draggable ? "calc(50% + " + position.y + "px)" : undefined
|
4130
|
-
})
|
4131
|
-
}), React.createElement("div", {
|
4132
|
-
className: containerClassName,
|
4133
|
-
"data-taco": "dialog"
|
4134
|
-
}, output, dialog.draggable && React.createElement("div", Object.assign({}, dragHandleProps, {
|
4135
|
-
"aria-label": texts.dialog.drag,
|
4136
|
-
className: "yt-dialog__drag absolute-center-x bg-grey-light top-1.5 h-3 w-24 cursor-move rounded text-center"
|
4137
|
-
})), React.createElement(DialogPrimitive.Close, {
|
4138
|
-
asChild: true,
|
4139
|
-
onClick: dialog.onClose
|
4140
|
-
}, React.createElement(IconButton, {
|
4141
|
-
appearance: "discrete",
|
4142
|
-
"aria-label": texts.dialog.close,
|
4143
|
-
className: "absolute top-0 right-0 mt-2 mr-2",
|
4144
|
-
icon: "close"
|
4145
|
-
}))), dialog.elements.drawer, dialog.elements.extra))));
|
4146
|
-
});
|
4147
|
-
|
4148
|
-
var Drawer = /*#__PURE__*/React.forwardRef(function DialogDrawer(props, ref) {
|
4149
|
-
var _dialog$drawer, _dialog$drawer2;
|
4150
|
-
|
4151
|
-
var dialog = useCurrentDialog();
|
4152
|
-
return React.createElement(framerMotion.motion.div, Object.assign({}, props, {
|
4153
|
-
className: "absolute top-0 z-[998] -ml-[4px] hidden h-full w-full overflow-y-auto rounded-r bg-white p-6 text-left",
|
4154
|
-
"data-taco": "dialog-drawer",
|
4155
|
-
"aria-hidden": !((_dialog$drawer = dialog.drawer) !== null && _dialog$drawer !== void 0 && _dialog$drawer.open),
|
4156
|
-
variants: {
|
4157
|
-
visible: {
|
4158
|
-
left: '100%',
|
4159
|
-
display: 'block',
|
4160
|
-
transition: {
|
4161
|
-
ease: 'easeOut',
|
4162
|
-
duration: 0.2
|
4163
|
-
}
|
4164
|
-
},
|
4165
|
-
hidden: {
|
4166
|
-
left: '0%',
|
4167
|
-
transition: {
|
4168
|
-
ease: 'easeOut',
|
4169
|
-
duration: 0.2
|
4170
|
-
},
|
4171
|
-
transitionEnd: {
|
4172
|
-
display: 'none'
|
4173
|
-
}
|
4174
|
-
}
|
4175
|
-
},
|
4176
|
-
animate: (_dialog$drawer2 = dialog.drawer) !== null && _dialog$drawer2 !== void 0 && _dialog$drawer2.open ? 'visible' : 'hidden',
|
4133
|
+
onClick: handleClick,
|
4177
4134
|
ref: ref
|
4178
|
-
})
|
4135
|
+
}), icon && React.createElement(Icon$1, {
|
4136
|
+
name: icon
|
4137
|
+
}), props.children, shortcut && React.createElement(Shortcut, null, shortcut));
|
4179
4138
|
});
|
4180
4139
|
|
4181
|
-
var
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4140
|
+
var _excluded$c = ["href", "icon"];
|
4141
|
+
var Link = /*#__PURE__*/React.forwardRef(function MenuLink(props, ref) {
|
4142
|
+
var href = props.href,
|
4143
|
+
icon = props.icon,
|
4144
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$c);
|
4145
|
+
|
4146
|
+
var className = useItemStyling({
|
4147
|
+
disabled: props.disabled,
|
4148
|
+
indented: !!icon,
|
4149
|
+
className: props.className
|
4150
|
+
});
|
4151
|
+
return React.createElement(DropdownMenuPrimitive.Item, Object.assign({}, otherProps, {
|
4152
|
+
asChild: true,
|
4153
|
+
className: className,
|
4185
4154
|
ref: ref
|
4186
|
-
})
|
4155
|
+
}), React.createElement("a", {
|
4156
|
+
href: href,
|
4157
|
+
target: "_blank"
|
4158
|
+
}, icon && React.createElement(Icon$1, {
|
4159
|
+
name: icon
|
4160
|
+
}), props.children));
|
4187
4161
|
});
|
4188
4162
|
|
4189
|
-
var
|
4190
|
-
|
4191
|
-
var useSeparatedChildren = function useSeparatedChildren(initialChildren) {
|
4192
|
-
return React.useMemo(function () {
|
4193
|
-
var children = [];
|
4194
|
-
var drawer;
|
4195
|
-
var extra;
|
4196
|
-
React.Children.forEach(initialChildren, function (child) {
|
4197
|
-
if (child.type.displayName === 'Drawer') {
|
4198
|
-
drawer = child;
|
4199
|
-
} else if (child.type.displayName === 'Extra') {
|
4200
|
-
extra = child;
|
4201
|
-
} else {
|
4202
|
-
children.push(child);
|
4203
|
-
}
|
4204
|
-
});
|
4205
|
-
return [children, drawer, extra];
|
4206
|
-
}, [initialChildren]);
|
4207
|
-
};
|
4208
|
-
|
4209
|
-
var Dialog = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4210
|
-
var initialChildren = props.children,
|
4211
|
-
_props$draggable = props.draggable,
|
4212
|
-
draggable = _props$draggable === void 0 ? false : _props$draggable,
|
4213
|
-
onClose = props.onClose,
|
4214
|
-
defaultOpen = props.open,
|
4215
|
-
_props$size = props.size,
|
4216
|
-
size = _props$size === void 0 ? 'sm' : _props$size,
|
4217
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$b);
|
4163
|
+
var Trigger$1 = /*#__PURE__*/React.forwardRef(function MenuTrigger(props, ref) {
|
4164
|
+
var _props$children3, _props$children3$prop;
|
4218
4165
|
|
4219
|
-
var
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4166
|
+
var menu = useCurrentMenu();
|
4167
|
+
var internalRef = useProxiedRef(ref);
|
4168
|
+
React.useEffect(function () {
|
4169
|
+
if (internalRef.current) {
|
4170
|
+
menu === null || menu === void 0 ? void 0 : menu.setMinWidth(internalRef.current.getBoundingClientRect().width);
|
4171
|
+
}
|
4172
|
+
}, [internalRef]); // set the appearance based on the trigger button
|
4223
4173
|
|
4224
|
-
|
4225
|
-
|
4226
|
-
setOpen = _React$useState[1];
|
4174
|
+
React.useEffect(function () {
|
4175
|
+
var _props$children, _props$children$props;
|
4227
4176
|
|
4228
|
-
|
4229
|
-
|
4230
|
-
setDrawerOpen = _React$useState2[1];
|
4177
|
+
if ((_props$children = props.children) !== null && _props$children !== void 0 && (_props$children$props = _props$children.props) !== null && _props$children$props !== void 0 && _props$children$props.appearance) {
|
4178
|
+
var _props$children2, _props$children2$prop;
|
4231
4179
|
|
4232
|
-
|
4233
|
-
|
4234
|
-
|
4235
|
-
|
4236
|
-
|
4237
|
-
|
4238
|
-
drawer: {
|
4239
|
-
open: drawerOpen,
|
4240
|
-
toggle: function toggle() {
|
4241
|
-
return setDrawerOpen(function (isDrawerOpen) {
|
4242
|
-
return !isDrawerOpen;
|
4243
|
-
});
|
4244
|
-
}
|
4245
|
-
},
|
4246
|
-
elements: {
|
4247
|
-
drawer: drawer,
|
4248
|
-
extra: extra
|
4249
|
-
},
|
4250
|
-
onClose: onClose,
|
4251
|
-
props: otherProps,
|
4252
|
-
size: size,
|
4253
|
-
ref: ref
|
4254
|
-
};
|
4255
|
-
}, [open, drawerOpen, drawer, extra, otherProps]);
|
4256
|
-
return React.createElement(DialogContext.Provider, {
|
4257
|
-
value: context
|
4258
|
-
}, React.createElement(DialogPrimitive.Root, {
|
4259
|
-
children: children,
|
4260
|
-
open: open,
|
4261
|
-
onOpenChange: setOpen
|
4180
|
+
menu === null || menu === void 0 ? void 0 : menu.setAppearance((_props$children2 = props.children) === null || _props$children2 === void 0 ? void 0 : (_props$children2$prop = _props$children2.props) === null || _props$children2$prop === void 0 ? void 0 : _props$children2$prop.appearance);
|
4181
|
+
}
|
4182
|
+
}, [(_props$children3 = props.children) === null || _props$children3 === void 0 ? void 0 : (_props$children3$prop = _props$children3.props) === null || _props$children3$prop === void 0 ? void 0 : _props$children3$prop.appearance]);
|
4183
|
+
return React.createElement(DropdownMenuPrimitive.Trigger, Object.assign({}, props, {
|
4184
|
+
asChild: true,
|
4185
|
+
ref: internalRef
|
4262
4186
|
}));
|
4263
4187
|
});
|
4264
|
-
Dialog.Trigger = Trigger$1;
|
4265
|
-
Dialog.Content = Content$2;
|
4266
|
-
Dialog.Title = Title;
|
4267
|
-
Dialog.Footer = Footer;
|
4268
|
-
Dialog.Extra = Extra;
|
4269
|
-
Dialog.Drawer = Drawer;
|
4270
|
-
Dialog.Close = Close$1;
|
4271
4188
|
|
4272
|
-
var _excluded$
|
4273
|
-
var
|
4274
|
-
props
|
4275
|
-
|
4276
|
-
|
4277
|
-
|
4278
|
-
var context = React.useContext(PopoverContext);
|
4279
|
-
return React.createElement(PopoverPrimitive.Trigger, Object.assign({}, context.props, props, {
|
4280
|
-
ref: mergeRefs([context.ref, ref]),
|
4281
|
-
asChild: true
|
4282
|
-
}));
|
4283
|
-
});
|
4284
|
-
var RenderPropWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
4285
|
-
var children = _ref.children,
|
4286
|
-
onClick = _ref.onClick;
|
4189
|
+
var _excluded$d = ["checked", "children", "onChange"];
|
4190
|
+
var Checkbox = function Checkbox(props) {
|
4191
|
+
var checked = props.checked,
|
4192
|
+
children = props.children,
|
4193
|
+
onChange = props.onChange,
|
4194
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$d);
|
4287
4195
|
|
4288
|
-
var
|
4289
|
-
|
4290
|
-
|
4196
|
+
var className = useItemStyling({
|
4197
|
+
disabled: props.disabled,
|
4198
|
+
indented: true,
|
4199
|
+
className: props.className
|
4200
|
+
});
|
4201
|
+
return React.createElement(DropdownMenuPrimitive.CheckboxItem, Object.assign({}, otherProps, {
|
4202
|
+
className: className,
|
4203
|
+
checked: checked,
|
4204
|
+
onCheckedChange: onChange
|
4205
|
+
}), React.createElement(DropdownMenuPrimitive.ItemIndicator, {
|
4206
|
+
className: "absolute left-0 ml-1.5"
|
4207
|
+
}, React.createElement(Icon, {
|
4208
|
+
name: "tick",
|
4209
|
+
className: "!h-4 !w-4 -ml-px"
|
4210
|
+
})), children);
|
4211
|
+
};
|
4291
4212
|
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4213
|
+
var _excluded$e = ["children", "value"],
|
4214
|
+
_excluded2$1 = ["children", "defaultValue", "disabled", "invalid", "onChange", "orientation", "value"];
|
4215
|
+
var getRadioGroupItemValueAsString = function getRadioGroupItemValueAsString(value) {
|
4216
|
+
return value === null ? '' : String(value);
|
4217
|
+
};
|
4218
|
+
var findByValue = function findByValue(values, valueAsString) {
|
4219
|
+
return values.find(function (value) {
|
4220
|
+
return getRadioGroupItemValueAsString(value) === valueAsString;
|
4295
4221
|
});
|
4222
|
+
};
|
4223
|
+
var RadioGroupContext = /*#__PURE__*/React.createContext({
|
4224
|
+
disabled: false,
|
4225
|
+
invalid: false
|
4296
4226
|
});
|
4297
|
-
var
|
4298
|
-
var
|
4299
|
-
var output;
|
4227
|
+
var RadioGroupItem = /*#__PURE__*/React.forwardRef(function RadioGroupItem(props, ref) {
|
4228
|
+
var context = React.useContext(RadioGroupContext);
|
4300
4229
|
|
4301
|
-
|
4302
|
-
|
4303
|
-
|
4304
|
-
}, React.createElement(RenderPropWrapper, null, props.children));
|
4305
|
-
} else {
|
4306
|
-
output = props.children;
|
4307
|
-
}
|
4230
|
+
var children = props.children,
|
4231
|
+
value = props.value,
|
4232
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$e);
|
4308
4233
|
|
4309
|
-
|
4234
|
+
var disabled = context.disabled || props.disabled;
|
4235
|
+
var className = cn('flex items-center justify-center h-4 w-4 mr-2 rounded-full bg-white border-2 ', {
|
4236
|
+
'border-grey-dark focus:border-blue focus:yt-focus aria-checked:bg-blue aria-checked:border-blue': !disabled && !context.invalid,
|
4237
|
+
'border-grey cursor-not-allowed aria-checked:bg-grey-dark aria-checked:border-grey-dark': disabled,
|
4238
|
+
'border-red text-red focus:border-red focus:yt-focus-red aria-checked:bg-red aria-checked:border-red': context.invalid && !disabled
|
4239
|
+
});
|
4240
|
+
var labelClassName = cn('flex items-center cursor-pointer', {
|
4241
|
+
'cursor-not-allowed text-grey-dark': disabled
|
4242
|
+
});
|
4243
|
+
return React.createElement("label", {
|
4244
|
+
className: labelClassName
|
4245
|
+
}, React.createElement(RadioGroupPrimitive.Item, Object.assign({}, otherProps, {
|
4310
4246
|
className: className,
|
4311
|
-
|
4312
|
-
ref: ref
|
4313
|
-
}, output, React.createElement(UnstyledArrow, {
|
4314
|
-
className: "text-white"
|
4315
|
-
}));
|
4316
|
-
});
|
4317
|
-
var Close$2 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4318
|
-
return React.createElement(PopoverPrimitive.Close, Object.assign({}, props, {
|
4247
|
+
disabled: disabled,
|
4319
4248
|
ref: ref,
|
4320
|
-
|
4321
|
-
})
|
4249
|
+
value: getRadioGroupItemValueAsString(value)
|
4250
|
+
}), React.createElement(RadioGroupPrimitive.Indicator, {
|
4251
|
+
className: "h-2 w-2 rounded-full bg-white"
|
4252
|
+
})), children);
|
4322
4253
|
});
|
4323
|
-
var
|
4254
|
+
var useRadioGroup = function useRadioGroup(props) {
|
4324
4255
|
var children = props.children,
|
4325
|
-
|
4256
|
+
defaultValue = props.defaultValue,
|
4257
|
+
disabled = props.disabled,
|
4258
|
+
invalid = props.invalid,
|
4259
|
+
onChange = props.onChange,
|
4260
|
+
_props$orientation = props.orientation,
|
4261
|
+
orientation = _props$orientation === void 0 ? 'vertical' : _props$orientation,
|
4262
|
+
value = props.value,
|
4263
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded2$1);
|
4326
4264
|
|
4265
|
+
var values = React.useMemo(function () {
|
4266
|
+
var radioGroupItemValues = [];
|
4267
|
+
React.Children.forEach(children, function (child) {
|
4268
|
+
if (React.isValidElement(child)) {
|
4269
|
+
radioGroupItemValues.push(child.props.value);
|
4270
|
+
}
|
4271
|
+
});
|
4272
|
+
return radioGroupItemValues;
|
4273
|
+
}, [children]);
|
4327
4274
|
var context = React.useMemo(function () {
|
4328
4275
|
return {
|
4329
|
-
|
4330
|
-
|
4276
|
+
disabled: disabled !== null && disabled !== void 0 ? disabled : false,
|
4277
|
+
invalid: invalid !== null && invalid !== void 0 ? invalid : false
|
4331
4278
|
};
|
4332
|
-
}, [
|
4333
|
-
|
4279
|
+
}, [disabled, invalid]);
|
4280
|
+
var valueProps;
|
4281
|
+
|
4282
|
+
if (onChange !== undefined) {
|
4283
|
+
var handleChange = function handleChange(value) {
|
4284
|
+
return onChange(findByValue(values, value));
|
4285
|
+
};
|
4286
|
+
|
4287
|
+
valueProps = {
|
4288
|
+
onValueChange: handleChange,
|
4289
|
+
value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined
|
4290
|
+
};
|
4291
|
+
} else {
|
4292
|
+
valueProps = {
|
4293
|
+
defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined
|
4294
|
+
};
|
4295
|
+
}
|
4296
|
+
|
4297
|
+
return {
|
4298
|
+
context: context,
|
4299
|
+
props: _extends({}, otherProps, valueProps, {
|
4300
|
+
children: children,
|
4301
|
+
orientation: orientation
|
4302
|
+
})
|
4303
|
+
};
|
4304
|
+
};
|
4305
|
+
var RadioGroup = /*#__PURE__*/React.forwardRef(function RadioGroup(props, ref) {
|
4306
|
+
var _useRadioGroup = useRadioGroup(props),
|
4307
|
+
context = _useRadioGroup.context,
|
4308
|
+
otherProps = _useRadioGroup.props;
|
4309
|
+
|
4310
|
+
var className = cn('flex items-start', {
|
4311
|
+
'flex-wrap space-x-4': otherProps.orientation === 'horizontal',
|
4312
|
+
'flex-col space-y-2': otherProps.orientation === 'vertical'
|
4313
|
+
}, otherProps.className);
|
4314
|
+
return React.createElement(RadioGroupContext.Provider, {
|
4334
4315
|
value: context
|
4335
|
-
}, React.createElement(
|
4336
|
-
|
4337
|
-
|
4316
|
+
}, React.createElement(RadioGroupPrimitive.Root, Object.assign({}, otherProps, {
|
4317
|
+
className: className,
|
4318
|
+
"data-taco": "radio-group",
|
4319
|
+
ref: ref
|
4320
|
+
})));
|
4338
4321
|
});
|
4339
|
-
|
4340
|
-
Popover.Content = Content$3;
|
4341
|
-
Popover.Close = Close$2;
|
4322
|
+
RadioGroup.Item = RadioGroupItem;
|
4342
4323
|
|
4343
|
-
var _excluded$
|
4344
|
-
var
|
4345
|
-
|
4324
|
+
var _excluded$f = ["children", "value"];
|
4325
|
+
var RadioItem = function RadioItem(props) {
|
4326
|
+
var context = React.useContext(MenuRadioGroupContext);
|
4327
|
+
|
4328
|
+
var children = props.children,
|
4329
|
+
value = props.value,
|
4330
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$f);
|
4331
|
+
|
4332
|
+
var disabled = context.disabled || props.disabled;
|
4333
|
+
var className = useItemStyling({
|
4334
|
+
disabled: disabled,
|
4335
|
+
indented: true,
|
4336
|
+
className: props.className
|
4337
|
+
});
|
4338
|
+
return React.createElement(DropdownMenuPrimitive.RadioItem, Object.assign({}, otherProps, {
|
4339
|
+
className: className,
|
4340
|
+
disabled: disabled,
|
4341
|
+
value: getRadioGroupItemValueAsString(value)
|
4342
|
+
}), React.createElement(DropdownMenuPrimitive.ItemIndicator, {
|
4343
|
+
className: "absolute left-0 ml-1.5"
|
4344
|
+
}, React.createElement("span", {
|
4345
|
+
className: "flex h-1.5 w-1.5 ml-1 rounded-full bg-current "
|
4346
|
+
})), children);
|
4346
4347
|
};
|
4347
|
-
var
|
4348
|
-
|
4349
|
-
|
4350
|
-
|
4348
|
+
var MenuRadioGroupContext = /*#__PURE__*/React.createContext({
|
4349
|
+
disabled: false
|
4350
|
+
});
|
4351
|
+
var RadioGroup$1 = function RadioGroup(props) {
|
4352
|
+
var _useRadioGroup = useRadioGroup(props),
|
4353
|
+
context = _useRadioGroup.context,
|
4354
|
+
otherProps = _useRadioGroup.props;
|
4351
4355
|
|
4352
|
-
|
4356
|
+
var className = cn('flex flex-col', props.className);
|
4357
|
+
return React.createElement(MenuRadioGroupContext.Provider, {
|
4358
|
+
value: context
|
4359
|
+
}, React.createElement(DropdownMenuPrimitive.RadioGroup, Object.assign({}, otherProps, {
|
4360
|
+
className: className
|
4361
|
+
})));
|
4362
|
+
};
|
4363
|
+
RadioGroup$1.Item = RadioItem;
|
4364
|
+
|
4365
|
+
var getAppearanceClasses$2 = function getAppearanceClasses(appearance) {
|
4366
|
+
switch (appearance) {
|
4353
4367
|
case 'primary':
|
4354
|
-
return
|
4368
|
+
return 'bg-blue-lighe';
|
4355
4369
|
|
4356
4370
|
case 'danger':
|
4357
|
-
return
|
4371
|
+
return 'bg-red-light';
|
4358
4372
|
|
4359
4373
|
case 'ghost':
|
4360
|
-
return
|
4374
|
+
return 'bg-blue-light';
|
4361
4375
|
|
4362
4376
|
case 'discrete':
|
4363
|
-
|
4364
|
-
if (icon) {
|
4365
|
-
return "bg-transparent text-black border-transparent\n focus:text-black focus:yt-focus\n active:text-black\n hover:text-grey-darkest\n hover:focus:text-grey-darkest\n disabled:hover:yt-transparent";
|
4366
|
-
}
|
4367
|
-
|
4368
|
-
return "yt-transparent border-transparent\n focus:text-blue focus:yt-focus\n active:text-blue-dark\n hover:text-blue-light\n hover:focus:text-blue-light\n disabled:hover:yt-transparent";
|
4369
|
-
}
|
4377
|
+
return 'bg-grey-dark';
|
4370
4378
|
|
4379
|
+
case 'default':
|
4371
4380
|
default:
|
4372
|
-
return
|
4381
|
+
return 'bg-grey-dark';
|
4373
4382
|
}
|
4374
4383
|
};
|
4375
|
-
var createButton = function createButton(props, className, ref) {
|
4376
|
-
var dialog = props.dialog,
|
4377
|
-
hanger = props.hanger,
|
4378
|
-
popover = props.popover,
|
4379
|
-
tooltip = props.tooltip,
|
4380
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$d);
|
4381
4384
|
|
4382
|
-
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4385
|
+
var Separator = function Separator() {
|
4386
|
+
var menu = useCurrentMenu();
|
4387
|
+
var className = cn('h-px my-1', getAppearanceClasses$2(menu === null || menu === void 0 ? void 0 : menu.appearance));
|
4388
|
+
return React.createElement(DropdownMenuPrimitive.Separator, {
|
4389
|
+
className: className
|
4390
|
+
});
|
4391
|
+
};
|
4386
4392
|
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4393
|
+
var getAppearanceClasses$3 = function getAppearanceClasses(appearance) {
|
4394
|
+
switch (appearance) {
|
4395
|
+
case 'primary':
|
4396
|
+
return 'text-blue-lighest';
|
4390
4397
|
|
4391
|
-
|
4392
|
-
|
4393
|
-
}
|
4398
|
+
case 'danger':
|
4399
|
+
return 'text-red-lightest';
|
4394
4400
|
|
4395
|
-
|
4396
|
-
|
4397
|
-
}
|
4401
|
+
case 'ghost':
|
4402
|
+
return 'text-blue-light';
|
4398
4403
|
|
4399
|
-
|
4400
|
-
|
4401
|
-
title: tooltip
|
4402
|
-
}, button);
|
4403
|
-
}
|
4404
|
+
case 'discrete':
|
4405
|
+
return 'text-grey-darkest';
|
4404
4406
|
|
4405
|
-
|
4407
|
+
case 'default':
|
4408
|
+
default:
|
4409
|
+
return 'text-grey-darkest';
|
4410
|
+
}
|
4406
4411
|
};
|
4407
4412
|
|
4408
|
-
var
|
4409
|
-
var
|
4410
|
-
var
|
4411
|
-
|
4412
|
-
|
4413
|
-
rounded = _props$rounded === void 0 ? false : _props$rounded,
|
4414
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$e);
|
4415
|
-
|
4416
|
-
var className = cn(getButtonClasses(), getAppearanceClasses(appearance, true), {
|
4417
|
-
'rounded-full': rounded,
|
4418
|
-
rounded: !rounded,
|
4419
|
-
'cursor-not-allowed opacity-50': props.disabled,
|
4420
|
-
'focus:yt-focus active:focus:yt-focus': !props.disabled
|
4413
|
+
var Header = function Header(props) {
|
4414
|
+
var menu = useCurrentMenu();
|
4415
|
+
var className = cn('flex items-center justify-start h-6 pr-1.5 text-xs', getAppearanceClasses$3(menu === null || menu === void 0 ? void 0 : menu.appearance), {
|
4416
|
+
'pl-7': menu === null || menu === void 0 ? void 0 : menu.indented,
|
4417
|
+
'pl-1.5': !(menu !== null && menu !== void 0 && menu.indented)
|
4421
4418
|
}, props.className);
|
4419
|
+
return React.createElement(DropdownMenuPrimitive.Label, Object.assign({}, props, {
|
4420
|
+
className: className
|
4421
|
+
}));
|
4422
|
+
};
|
4422
4423
|
|
4423
|
-
|
4424
|
-
|
4425
|
-
|
4426
|
-
|
4427
|
-
return createButton(_extends({}, otherProps, {
|
4428
|
-
children: React.createElement(Icon, {
|
4429
|
-
name: icon,
|
4430
|
-
className: "m-0 p-0"
|
4431
|
-
}),
|
4432
|
-
'data-taco': 'icon-button'
|
4433
|
-
}), className, ref);
|
4434
|
-
});
|
4435
|
-
|
4436
|
-
var Banner = /*#__PURE__*/React.forwardRef(function Banner(props, ref) {
|
4437
|
-
var children = props.children,
|
4438
|
-
state = props.state,
|
4439
|
-
onClose = props.onClose;
|
4440
|
-
var className = cn('bg-white relative flex items-center px-4 h-12 shadow-lg z-10', props.className);
|
4441
|
-
return React.createElement("div", {
|
4442
|
-
className: className,
|
4443
|
-
"data-taco": "banner",
|
4444
|
-
ref: ref
|
4445
|
-
}, getBannerIcon(state), children, onClose ? React.createElement(IconButton, {
|
4446
|
-
className: "ml-auto",
|
4447
|
-
icon: "close",
|
4448
|
-
appearance: "discrete",
|
4449
|
-
onClick: onClose
|
4450
|
-
}) : null);
|
4451
|
-
});
|
4452
|
-
|
4453
|
-
var _excluded$f = ["appearance", "fluid"];
|
4454
|
-
var Button$1 = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
|
4455
|
-
var appearance = props.appearance,
|
4456
|
-
fluid = props.fluid,
|
4457
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$f);
|
4424
|
+
var Menu = function Menu(props) {
|
4425
|
+
var _React$useState = React.useState(false),
|
4426
|
+
open = _React$useState[0],
|
4427
|
+
setOpen = _React$useState[1];
|
4458
4428
|
|
4459
|
-
var
|
4460
|
-
|
4461
|
-
|
4462
|
-
'w-full': fluid
|
4463
|
-
}, props.className);
|
4464
|
-
return createButton(_extends({}, otherProps, {
|
4465
|
-
'data-taco': 'button'
|
4466
|
-
}), className, ref);
|
4467
|
-
});
|
4429
|
+
var _React$useState2 = React.useState('default'),
|
4430
|
+
appearance = _React$useState2[0],
|
4431
|
+
_setAppearance = _React$useState2[1];
|
4468
4432
|
|
4469
|
-
var
|
4433
|
+
var _React$useState3 = React.useState(false),
|
4434
|
+
indented = _React$useState3[0],
|
4435
|
+
setIndented = _React$useState3[1];
|
4470
4436
|
|
4471
|
-
var
|
4472
|
-
|
4473
|
-
|
4474
|
-
}) : day.getDate();
|
4475
|
-
};
|
4437
|
+
var _React$useState4 = React.useState(undefined),
|
4438
|
+
minWidth = _React$useState4[0],
|
4439
|
+
_setMinWidth = _React$useState4[1];
|
4476
4440
|
|
4477
|
-
var
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
}
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4487
|
-
|
4488
|
-
|
4489
|
-
|
4490
|
-
|
4491
|
-
|
4492
|
-
|
4493
|
-
|
4494
|
-
|
4495
|
-
|
4496
|
-
|
4497
|
-
|
4498
|
-
|
4499
|
-
|
4500
|
-
|
4501
|
-
};
|
4502
|
-
|
4503
|
-
return React.createElement("div", {
|
4504
|
-
className: "flex justify-between items-center mb-2"
|
4505
|
-
}, React.createElement("form", {
|
4506
|
-
className: "inline-flex space-x-1"
|
4507
|
-
}, React.createElement("select", {
|
4508
|
-
className: "h-8 px-2",
|
4509
|
-
name: "month",
|
4510
|
-
onChange: handleChange,
|
4511
|
-
value: value.getMonth()
|
4512
|
-
}, months.map(function (month, i) {
|
4513
|
-
return React.createElement("option", {
|
4514
|
-
value: i
|
4515
|
-
}, month);
|
4516
|
-
})), React.createElement("select", {
|
4517
|
-
className: "h-8 px-2",
|
4518
|
-
name: "year",
|
4519
|
-
onChange: handleChange,
|
4520
|
-
value: value.getFullYear()
|
4521
|
-
}, years.map(function (year) {
|
4522
|
-
return React.createElement("option", {
|
4523
|
-
value: year
|
4524
|
-
}, String(year));
|
4525
|
-
}))), React.createElement("div", null, React.createElement(IconButton, {
|
4526
|
-
appearance: "discrete",
|
4527
|
-
icon: "chevron-left",
|
4528
|
-
"aria-label": actions.previousMonth,
|
4529
|
-
onClick: function onClick() {
|
4530
|
-
return onPreviousClick();
|
4531
|
-
},
|
4532
|
-
rounded: true
|
4533
|
-
}), React.createElement(IconButton, {
|
4534
|
-
appearance: "discrete",
|
4535
|
-
icon: "chevron-right",
|
4536
|
-
"aria-label": actions.nextMonth,
|
4537
|
-
onClick: function onClick() {
|
4538
|
-
return onNextClick();
|
4539
|
-
},
|
4540
|
-
rounded: true
|
4441
|
+
var context = React.useMemo(function () {
|
4442
|
+
return {
|
4443
|
+
appearance: appearance,
|
4444
|
+
setAppearance: function setAppearance(appearance) {
|
4445
|
+
return _setAppearance(appearance);
|
4446
|
+
},
|
4447
|
+
indented: indented,
|
4448
|
+
registerIndentation: function registerIndentation() {
|
4449
|
+
return setIndented(true);
|
4450
|
+
},
|
4451
|
+
minWidth: minWidth,
|
4452
|
+
setMinWidth: function setMinWidth(width) {
|
4453
|
+
return _setMinWidth(width);
|
4454
|
+
},
|
4455
|
+
close: function close() {
|
4456
|
+
return setOpen(false);
|
4457
|
+
}
|
4458
|
+
};
|
4459
|
+
}, [indented, minWidth, appearance]);
|
4460
|
+
return React.createElement(MenuContext.Provider, {
|
4461
|
+
value: context
|
4462
|
+
}, React.createElement(DropdownMenuPrimitive.Root, Object.assign({}, props, {
|
4463
|
+
open: open,
|
4464
|
+
onOpenChange: setOpen
|
4541
4465
|
})));
|
4466
|
+
};
|
4467
|
+
Menu.Trigger = Trigger$1;
|
4468
|
+
Menu.Content = Content$2;
|
4469
|
+
Menu.Item = Item$1;
|
4470
|
+
Menu.Link = Link;
|
4471
|
+
Menu.Checkbox = Checkbox;
|
4472
|
+
Menu.Separator = Separator;
|
4473
|
+
Menu.Header = Header;
|
4474
|
+
Menu.RadioGroup = RadioGroup$1;
|
4475
|
+
|
4476
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
4477
|
+
var DialogContext = /*#__PURE__*/React.createContext({
|
4478
|
+
closeOnEscape: true,
|
4479
|
+
close: function close() {},
|
4480
|
+
draggable: false,
|
4481
|
+
drawer: undefined,
|
4482
|
+
elements: {
|
4483
|
+
drawer: undefined,
|
4484
|
+
extra: undefined
|
4485
|
+
},
|
4486
|
+
onClose: function onClose() {},
|
4487
|
+
props: {},
|
4488
|
+
ref: null,
|
4489
|
+
showCloseButton: true,
|
4490
|
+
size: 'sm'
|
4542
4491
|
});
|
4543
|
-
var
|
4544
|
-
|
4545
|
-
|
4546
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$g);
|
4492
|
+
var useCurrentDialog = function useCurrentDialog() {
|
4493
|
+
return React.useContext(DialogContext);
|
4494
|
+
};
|
4547
4495
|
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4496
|
+
var Trigger$2 = /*#__PURE__*/React.forwardRef(function DialogTrigger(props, ref) {
|
4497
|
+
var dialog = useCurrentDialog();
|
4498
|
+
return React.createElement(DialogPrimitive.Trigger, Object.assign({}, dialog.props, props, {
|
4499
|
+
ref: mergeRefs([dialog.ref, ref]),
|
4500
|
+
asChild: true
|
4501
|
+
}));
|
4502
|
+
});
|
4551
4503
|
|
4552
|
-
|
4553
|
-
|
4554
|
-
|
4504
|
+
var useDraggable = function useDraggable(ref) {
|
4505
|
+
var _React$useState = React__default.useState({
|
4506
|
+
x: 0,
|
4507
|
+
y: 0
|
4508
|
+
}),
|
4509
|
+
position = _React$useState[0],
|
4510
|
+
setPosition = _React$useState[1];
|
4555
4511
|
|
4556
|
-
|
4557
|
-
|
4558
|
-
|
4559
|
-
}
|
4560
|
-
}, [value]);
|
4512
|
+
var _useMove = interactions.useMove({
|
4513
|
+
onMove: function onMove(event) {
|
4514
|
+
var _ref$current;
|
4561
4515
|
|
4562
|
-
|
4563
|
-
if (modifiers.outside || modifiers.disabled) {
|
4564
|
-
return;
|
4565
|
-
}
|
4516
|
+
var rect = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect(); // Prevent dragging out of bounds
|
4566
4517
|
|
4567
|
-
|
4568
|
-
|
4518
|
+
// Prevent dragging out of bounds
|
4519
|
+
if (rect && (rect.left + event.deltaX < 0 || rect.right + event.deltaX > window.innerWidth || rect.top + event.deltaY < 0 || rect.bottom + event.deltaY > window.innerHeight)) {
|
4520
|
+
return;
|
4521
|
+
}
|
4569
4522
|
|
4570
|
-
|
4571
|
-
|
4523
|
+
setPosition(function (_ref) {
|
4524
|
+
var x = _ref.x,
|
4525
|
+
y = _ref.y;
|
4526
|
+
x += event.deltaX;
|
4527
|
+
y += event.deltaY;
|
4528
|
+
return {
|
4529
|
+
x: x,
|
4530
|
+
y: y
|
4531
|
+
};
|
4532
|
+
});
|
4533
|
+
}
|
4534
|
+
}),
|
4535
|
+
moveProps = _useMove.moveProps;
|
4572
4536
|
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
handleChange(today);
|
4537
|
+
return {
|
4538
|
+
position: position,
|
4539
|
+
handleProps: moveProps
|
4577
4540
|
};
|
4541
|
+
};
|
4578
4542
|
|
4579
|
-
|
4580
|
-
|
4581
|
-
|
4582
|
-
}, React.createElement(ReactDayPicker, Object.assign({}, otherProps, {
|
4543
|
+
var Title = /*#__PURE__*/React.forwardRef(function DialogTitle(props, ref) {
|
4544
|
+
var className = cn('text-center', props.className);
|
4545
|
+
return React.createElement(DialogPrimitive.Title, Object.assign({}, props, {
|
4583
4546
|
className: className,
|
4584
|
-
month: visibleMonth,
|
4585
|
-
selectedDays: value,
|
4586
|
-
locale: locale.substring(0, 2),
|
4587
|
-
firstDayOfWeek: 1,
|
4588
|
-
months: texts.calendar.months,
|
4589
|
-
weekdaysShort: texts.calendar.weekdaysShort,
|
4590
|
-
navbarElement: function navbarElement(navProps) {
|
4591
|
-
return React.createElement(Navbar, Object.assign({}, navProps, {
|
4592
|
-
onMonthChange: setVisibleMonth,
|
4593
|
-
value: visibleMonth
|
4594
|
-
}));
|
4595
|
-
},
|
4596
|
-
onDayClick: handleDayClick,
|
4597
|
-
onMonthChange: setVisibleMonth,
|
4598
|
-
onTodayButtonClick: handleCalendarClickToday,
|
4599
|
-
captionElement: function captionElement() {
|
4600
|
-
return null;
|
4601
|
-
},
|
4602
|
-
todayButton: texts.calendar.actions.today,
|
4603
|
-
showOutsideDays: true,
|
4604
|
-
renderDay: renderDay,
|
4605
|
-
numberOfMonths: 1,
|
4606
4547
|
ref: ref
|
4607
|
-
}))
|
4548
|
+
}));
|
4549
|
+
});
|
4550
|
+
var Footer = /*#__PURE__*/React.forwardRef(function DialogFooter(props, ref) {
|
4551
|
+
var className = cn('mt-8 flex justify-end', props.className);
|
4552
|
+
return React.createElement("div", Object.assign({}, props, {
|
4553
|
+
className: className,
|
4554
|
+
ref: ref
|
4555
|
+
}), props.children);
|
4556
|
+
});
|
4557
|
+
var Close$1 = /*#__PURE__*/React.forwardRef(function DialogClose(props, ref) {
|
4558
|
+
var dialog = useCurrentDialog();
|
4559
|
+
return React.createElement(DialogPrimitive.Close, Object.assign({
|
4560
|
+
onClick: dialog.onClose
|
4561
|
+
}, props, {
|
4562
|
+
ref: ref,
|
4563
|
+
asChild: true
|
4564
|
+
}));
|
4608
4565
|
});
|
4566
|
+
var Content$3 = /*#__PURE__*/React.forwardRef(function DialogContent(props, ref) {
|
4567
|
+
var dialog = useCurrentDialog();
|
4568
|
+
var internalRef = useProxiedRef(ref);
|
4609
4569
|
|
4610
|
-
var
|
4611
|
-
|
4612
|
-
|
4613
|
-
highlighted = props.highlighted,
|
4614
|
-
indeterminate = props.indeterminate,
|
4615
|
-
invalid = props.invalid,
|
4616
|
-
label = props.label,
|
4617
|
-
onChange = props.onChange,
|
4618
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$h);
|
4570
|
+
var _useDraggable = useDraggable(internalRef),
|
4571
|
+
position = _useDraggable.position,
|
4572
|
+
dragHandleProps = _useDraggable.handleProps;
|
4619
4573
|
|
4620
|
-
var
|
4621
|
-
|
4622
|
-
|
4623
|
-
'border-grey text-blue-light cursor-not-allowed': props.disabled,
|
4624
|
-
'bg-[rgba(255,255,0,0.2)] disabled:bg-[rgba(255,255,0,0.075)]': highlighted,
|
4625
|
-
'border-red text-red focus:border-red focus:yt-focus-red': invalid && !props.disabled
|
4626
|
-
}, props.className);
|
4627
|
-
var handleChange;
|
4574
|
+
var _useLocalization = useLocalization(),
|
4575
|
+
texts = _useLocalization.texts; // if the dialog was opened by a menu, we need to close the menu when the dialog closes
|
4576
|
+
// the menu is still open (and mounted) because it is the trigger for the dialog
|
4628
4577
|
|
4629
|
-
|
4630
|
-
|
4631
|
-
|
4578
|
+
|
4579
|
+
var menu = useCurrentMenu();
|
4580
|
+
var handleCloseAutoFocus;
|
4581
|
+
|
4582
|
+
if (menu) {
|
4583
|
+
handleCloseAutoFocus = function handleCloseAutoFocus() {
|
4584
|
+
return menu.close();
|
4632
4585
|
};
|
4633
4586
|
}
|
4634
4587
|
|
4635
|
-
var
|
4636
|
-
|
4637
|
-
|
4638
|
-
|
4639
|
-
|
4640
|
-
|
4641
|
-
})
|
4642
|
-
|
4643
|
-
|
4644
|
-
|
4645
|
-
className: "!h-full !w-full"
|
4646
|
-
})));
|
4588
|
+
var className = cn('bg-white rounded mt-16 mx-auto', {
|
4589
|
+
'w-128 text-center justify-center': dialog.size === 'dialog',
|
4590
|
+
'w-xs': dialog.size === 'xs',
|
4591
|
+
'w-sm': dialog.size === 'sm',
|
4592
|
+
'w-md': dialog.size === 'md',
|
4593
|
+
'w-lg': dialog.size === 'lg'
|
4594
|
+
});
|
4595
|
+
var containerClassName = cn('bg-white p-6 rounded relative z-[999]', 'shadow-[0_6px_9px_0_rgba(89,85,98,0.3),0_0_1px_0_rgba(89,85,98,0.2)]', {
|
4596
|
+
'rounded-b-none': !!dialog.elements.extra
|
4597
|
+
}, props.className);
|
4647
4598
|
|
4648
|
-
|
4649
|
-
|
4650
|
-
|
4599
|
+
var handleEscapeKeyDown = function handleEscapeKeyDown(event) {
|
4600
|
+
if (!dialog.closeOnEscape) {
|
4601
|
+
event.preventDefault();
|
4602
|
+
} else if (dialog.onClose) {
|
4603
|
+
dialog.onClose();
|
4604
|
+
}
|
4605
|
+
}; // the chosen behaviour in taco is that outside clicks do not close the dialog
|
4606
|
+
|
4607
|
+
|
4608
|
+
var handleInteractOutside = function handleInteractOutside(event) {
|
4609
|
+
return event.preventDefault();
|
4610
|
+
};
|
4611
|
+
|
4612
|
+
var output;
|
4613
|
+
|
4614
|
+
if (typeof props.children === 'function') {
|
4615
|
+
output = props.children({
|
4616
|
+
drawer: dialog.drawer,
|
4617
|
+
close: dialog.close
|
4651
4618
|
});
|
4652
|
-
|
4653
|
-
|
4654
|
-
}, element, label);
|
4619
|
+
} else {
|
4620
|
+
output = props.children;
|
4655
4621
|
}
|
4656
4622
|
|
4657
|
-
return
|
4623
|
+
return React.createElement(DialogPrimitive.Portal, null, React.createElement(DialogPrimitive.Overlay, {
|
4624
|
+
asChild: true
|
4625
|
+
}, React.createElement(Backdrop, null, React.createElement(DialogPrimitive.Content, Object.assign({}, props, {
|
4626
|
+
className: className,
|
4627
|
+
onEscapeKeyDown: handleEscapeKeyDown,
|
4628
|
+
onInteractOutside: handleInteractOutside,
|
4629
|
+
onCloseAutoFocus: handleCloseAutoFocus,
|
4630
|
+
ref: ref,
|
4631
|
+
style: _extends({}, props.style, {
|
4632
|
+
left: dialog.draggable ? "calc(50% + " + position.x + "px)" : undefined,
|
4633
|
+
top: dialog.draggable ? "calc(50% + " + position.y + "px)" : undefined
|
4634
|
+
})
|
4635
|
+
}), React.createElement("div", {
|
4636
|
+
className: containerClassName,
|
4637
|
+
"data-taco": "dialog"
|
4638
|
+
}, output, dialog.draggable && React.createElement("div", Object.assign({}, dragHandleProps, {
|
4639
|
+
"aria-label": texts.dialog.drag,
|
4640
|
+
className: "yt-dialog__drag absolute-center-x bg-grey-light top-1.5 h-3 w-24 cursor-move rounded text-center"
|
4641
|
+
})), dialog.showCloseButton ? React.createElement(DialogPrimitive.Close, {
|
4642
|
+
asChild: true,
|
4643
|
+
onClick: dialog.onClose
|
4644
|
+
}, React.createElement(IconButton, {
|
4645
|
+
appearance: "discrete",
|
4646
|
+
"aria-label": texts.dialog.close,
|
4647
|
+
className: "absolute top-0 right-0 mt-2 mr-2",
|
4648
|
+
icon: "close"
|
4649
|
+
})) : null), dialog.elements.drawer, dialog.elements.extra))));
|
4658
4650
|
});
|
4659
4651
|
|
4660
|
-
var
|
4661
|
-
var
|
4652
|
+
var Drawer = /*#__PURE__*/React.forwardRef(function DialogDrawer(props, ref) {
|
4653
|
+
var _dialog$drawer, _dialog$drawer2;
|
4662
4654
|
|
4663
|
-
|
4664
|
-
|
4665
|
-
|
4666
|
-
|
4655
|
+
var dialog = useCurrentDialog();
|
4656
|
+
var className = cn('absolute top-0 z-[998] -ml-[4px] hidden h-full w-full overflow-y-auto rounded-r bg-white p-6 text-left', props.className);
|
4657
|
+
return React.createElement(framerMotion.motion.div, Object.assign({}, props, {
|
4658
|
+
className: className,
|
4659
|
+
"data-taco": "dialog-drawer",
|
4660
|
+
"aria-hidden": !((_dialog$drawer = dialog.drawer) !== null && _dialog$drawer !== void 0 && _dialog$drawer.open),
|
4661
|
+
variants: {
|
4662
|
+
visible: {
|
4663
|
+
left: '100%',
|
4664
|
+
display: 'block',
|
4665
|
+
transition: {
|
4666
|
+
ease: 'easeOut',
|
4667
|
+
duration: 0.2
|
4668
|
+
}
|
4669
|
+
},
|
4670
|
+
hidden: {
|
4671
|
+
left: '0%',
|
4672
|
+
transition: {
|
4673
|
+
ease: 'easeOut',
|
4674
|
+
duration: 0.2
|
4675
|
+
},
|
4676
|
+
transitionEnd: {
|
4677
|
+
display: 'none'
|
4678
|
+
}
|
4679
|
+
}
|
4680
|
+
},
|
4681
|
+
animate: (_dialog$drawer2 = dialog.drawer) !== null && _dialog$drawer2 !== void 0 && _dialog$drawer2.open ? 'visible' : 'hidden',
|
4682
|
+
ref: ref
|
4683
|
+
}));
|
4684
|
+
});
|
4685
|
+
|
4686
|
+
var Extra = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4687
|
+
var className = cn('bg-grey-light yt-shadow-inset absolute top-full left-0 -mt-px w-full rounded-t-none rounded-b p-6 text-left', props.className);
|
4688
|
+
return React.createElement("div", Object.assign({}, props, {
|
4689
|
+
className: className,
|
4690
|
+
"data-taco": "dialog-extra",
|
4691
|
+
ref: ref
|
4692
|
+
}));
|
4693
|
+
});
|
4694
|
+
|
4695
|
+
var _excluded$g = ["children", "closeOnEscape", "draggable", "onClose", "open", "showCloseButton", "size"];
|
4696
|
+
|
4697
|
+
var useSeparatedChildren = function useSeparatedChildren(initialChildren) {
|
4698
|
+
return React.useMemo(function () {
|
4699
|
+
var children = [];
|
4700
|
+
var drawer;
|
4701
|
+
var extra;
|
4702
|
+
React.Children.forEach(initialChildren, function (child) {
|
4703
|
+
if (child.type.displayName === 'Drawer') {
|
4704
|
+
drawer = child;
|
4705
|
+
} else if (child.type.displayName === 'Extra') {
|
4706
|
+
extra = child;
|
4707
|
+
} else {
|
4708
|
+
children.push(child);
|
4709
|
+
}
|
4710
|
+
});
|
4711
|
+
return [children, drawer, extra];
|
4712
|
+
}, [initialChildren]);
|
4667
4713
|
};
|
4668
|
-
var getStateClasses$1 = function getStateClasses(value) {
|
4669
|
-
switch (value) {
|
4670
|
-
case 'success':
|
4671
|
-
return 'border-green hover:shadow-[0_0_0.15rem_theme(colors.green.DEFAULT)] focus:border-green-light focus:yt-focus-green active:border-green-dark';
|
4672
4714
|
|
4673
|
-
|
4674
|
-
|
4715
|
+
var Dialog = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4716
|
+
var initialChildren = props.children,
|
4717
|
+
_props$closeOnEscape = props.closeOnEscape,
|
4718
|
+
closeOnEscape = _props$closeOnEscape === void 0 ? true : _props$closeOnEscape,
|
4719
|
+
_props$draggable = props.draggable,
|
4720
|
+
draggable = _props$draggable === void 0 ? false : _props$draggable,
|
4721
|
+
onClose = props.onClose,
|
4722
|
+
defaultOpen = props.open,
|
4723
|
+
_props$showCloseButto = props.showCloseButton,
|
4724
|
+
showCloseButton = _props$showCloseButto === void 0 ? true : _props$showCloseButto,
|
4725
|
+
_props$size = props.size,
|
4726
|
+
size = _props$size === void 0 ? 'sm' : _props$size,
|
4727
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$g);
|
4675
4728
|
|
4676
|
-
|
4677
|
-
|
4729
|
+
var _useSeparatedChildren = useSeparatedChildren(initialChildren),
|
4730
|
+
children = _useSeparatedChildren[0],
|
4731
|
+
drawer = _useSeparatedChildren[1],
|
4732
|
+
extra = _useSeparatedChildren[2];
|
4678
4733
|
|
4679
|
-
|
4680
|
-
|
4734
|
+
var _React$useState = React.useState(defaultOpen),
|
4735
|
+
open = _React$useState[0],
|
4736
|
+
setOpen = _React$useState[1];
|
4681
4737
|
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
};
|
4686
|
-
var getButtonStateClasses = function getButtonStateClasses(value) {
|
4687
|
-
switch (value) {
|
4688
|
-
case 'success':
|
4689
|
-
return '!border-green focus:!border-green-light focus:yt-focus-green peer-focus:!border-green-light peer-focus:peer-active:!border-green-dark';
|
4738
|
+
var _React$useState2 = React.useState(false),
|
4739
|
+
drawerOpen = _React$useState2[0],
|
4740
|
+
setDrawerOpen = _React$useState2[1];
|
4690
4741
|
|
4691
|
-
|
4692
|
-
|
4742
|
+
var context = React.useMemo(function () {
|
4743
|
+
return {
|
4744
|
+
close: function close() {
|
4745
|
+
return setOpen(false);
|
4746
|
+
},
|
4747
|
+
closeOnEscape: closeOnEscape,
|
4748
|
+
draggable: draggable,
|
4749
|
+
drawer: {
|
4750
|
+
open: drawerOpen,
|
4751
|
+
toggle: function toggle() {
|
4752
|
+
return setDrawerOpen(function (isDrawerOpen) {
|
4753
|
+
return !isDrawerOpen;
|
4754
|
+
});
|
4755
|
+
}
|
4756
|
+
},
|
4757
|
+
elements: {
|
4758
|
+
drawer: drawer,
|
4759
|
+
extra: extra
|
4760
|
+
},
|
4761
|
+
onClose: onClose,
|
4762
|
+
props: otherProps,
|
4763
|
+
showCloseButton: showCloseButton,
|
4764
|
+
size: size,
|
4765
|
+
ref: ref
|
4766
|
+
};
|
4767
|
+
}, [closeOnEscape, drawerOpen, draggable, drawer, extra, open, otherProps, showCloseButton]);
|
4768
|
+
return React.createElement(DialogContext.Provider, {
|
4769
|
+
value: context
|
4770
|
+
}, React.createElement(DialogPrimitive.Root, {
|
4771
|
+
children: children,
|
4772
|
+
open: open,
|
4773
|
+
onOpenChange: setOpen
|
4774
|
+
}));
|
4775
|
+
});
|
4776
|
+
Dialog.Trigger = Trigger$2;
|
4777
|
+
Dialog.Content = Content$3;
|
4778
|
+
Dialog.Title = Title;
|
4779
|
+
Dialog.Footer = Footer;
|
4780
|
+
Dialog.Extra = Extra;
|
4781
|
+
Dialog.Drawer = Drawer;
|
4782
|
+
Dialog.Close = Close$1;
|
4693
4783
|
|
4694
|
-
|
4695
|
-
|
4784
|
+
var _excluded$h = ["children"];
|
4785
|
+
var PopoverContext = /*#__PURE__*/React.createContext({
|
4786
|
+
props: {},
|
4787
|
+
ref: null
|
4788
|
+
});
|
4789
|
+
var Trigger$3 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4790
|
+
var _props$children;
|
4696
4791
|
|
4697
|
-
|
4698
|
-
|
4792
|
+
var context = React.useContext(PopoverContext);
|
4793
|
+
var children = props.children;
|
4699
4794
|
|
4700
|
-
|
4701
|
-
|
4795
|
+
if (React.isValidElement(props.children) && typeof ((_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.type) === 'function') {
|
4796
|
+
console.warn("Popover.Trigger requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '" + props.children.type.name + "' in React.forwardRef()? Taco has wrapped '" + props.children.type.name + "' in a 'span' to maintain functionality, but this may cause unintended behaviour");
|
4797
|
+
children = React.createElement("span", null, props.children);
|
4702
4798
|
}
|
4703
|
-
};
|
4704
|
-
|
4705
|
-
var _excluded$i = ["button", "defaultValue", "icon", "highlighted", "state", "autoFocus"];
|
4706
|
-
var Input = /*#__PURE__*/React.forwardRef(function Input(props, ref) {
|
4707
|
-
var button = props.button,
|
4708
|
-
icon = props.icon,
|
4709
|
-
state = props.state,
|
4710
|
-
autoFocus = props.autoFocus,
|
4711
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$i);
|
4712
4799
|
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
}, !hasContainer && otherProps.className);
|
4718
|
-
React.useEffect(function () {
|
4719
|
-
if (autoFocus && inputRef.current) {
|
4720
|
-
inputRef.current.focus();
|
4721
|
-
}
|
4722
|
-
}, []);
|
4723
|
-
var input = React.createElement("input", Object.assign({}, otherProps, {
|
4724
|
-
className: className,
|
4725
|
-
"data-taco": "input",
|
4726
|
-
ref: inputRef
|
4800
|
+
return React.createElement(PopoverPrimitive.Trigger, Object.assign({}, context.props, props, {
|
4801
|
+
children: children,
|
4802
|
+
ref: mergeRefs([context.ref, ref]),
|
4803
|
+
asChild: true
|
4727
4804
|
}));
|
4805
|
+
});
|
4806
|
+
var RenderPropWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
4807
|
+
var children = _ref.children,
|
4808
|
+
onClick = _ref.onClick;
|
4728
4809
|
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4732
|
-
if (button) {
|
4733
|
-
var _button$props$disable, _cn;
|
4810
|
+
var close = function close() {
|
4811
|
+
onClick(new CustomEvent('hide'));
|
4812
|
+
};
|
4734
4813
|
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
'text-grey-dark': props.disabled,
|
4744
|
-
'text-grey-darkest': !props.disabled
|
4745
|
-
});
|
4746
|
-
extra = typeof icon === 'string' ? React.createElement(Icon, {
|
4747
|
-
className: iconClassName,
|
4748
|
-
name: icon
|
4749
|
-
}) : React.cloneElement(icon, {
|
4750
|
-
className: cn(iconClassName, icon.props.className)
|
4751
|
-
});
|
4752
|
-
}
|
4814
|
+
return children({
|
4815
|
+
close: close,
|
4816
|
+
ref: ref
|
4817
|
+
});
|
4818
|
+
});
|
4819
|
+
var Content$4 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4820
|
+
var className = cn('bg-white focus:border-blue-light', props.className);
|
4821
|
+
var output;
|
4753
4822
|
|
4754
|
-
|
4755
|
-
|
4756
|
-
|
4757
|
-
|
4758
|
-
|
4823
|
+
if (typeof props.children === 'function') {
|
4824
|
+
output = React.createElement(PopoverPrimitive.Close, {
|
4825
|
+
asChild: true
|
4826
|
+
}, React.createElement(RenderPropWrapper, null, props.children));
|
4827
|
+
} else {
|
4828
|
+
output = props.children;
|
4759
4829
|
}
|
4760
4830
|
|
4761
|
-
return
|
4831
|
+
return React.createElement(UnstyledContent, {
|
4832
|
+
className: className,
|
4833
|
+
placement: props.placement,
|
4834
|
+
ref: ref
|
4835
|
+
}, output, React.createElement(UnstyledArrow, {
|
4836
|
+
className: "text-white"
|
4837
|
+
}));
|
4838
|
+
});
|
4839
|
+
var Close$2 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4840
|
+
return React.createElement(PopoverPrimitive.Close, Object.assign({}, props, {
|
4841
|
+
ref: ref,
|
4842
|
+
asChild: true
|
4843
|
+
}));
|
4762
4844
|
});
|
4845
|
+
var Popover = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
4846
|
+
var children = props.children,
|
4847
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$h);
|
4763
4848
|
|
4764
|
-
var
|
4765
|
-
|
4766
|
-
|
4849
|
+
var context = React.useMemo(function () {
|
4850
|
+
return {
|
4851
|
+
props: otherProps,
|
4852
|
+
ref: ref
|
4853
|
+
};
|
4854
|
+
}, [otherProps]);
|
4855
|
+
return React.createElement(PopoverContext.Provider, {
|
4856
|
+
value: context
|
4857
|
+
}, React.createElement(PopoverPrimitive.Root, {
|
4858
|
+
children: children
|
4859
|
+
}));
|
4860
|
+
});
|
4861
|
+
Popover.Trigger = Trigger$3;
|
4862
|
+
Popover.Content = Content$4;
|
4863
|
+
Popover.Close = Close$2;
|
4864
|
+
|
4865
|
+
var _excluded$i = ["dialog", "hanger", "menu", "popover", "tooltip"];
|
4866
|
+
var getButtonClasses = function getButtonClasses() {
|
4867
|
+
return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] leading-6 inline-flex items-center justify-center transition-all delay-100 ease-in border';
|
4868
|
+
};
|
4869
|
+
var getAppearanceClasses$4 = function getAppearanceClasses(value, icon) {
|
4870
|
+
if (icon === void 0) {
|
4871
|
+
icon = false;
|
4767
4872
|
}
|
4768
4873
|
|
4769
|
-
|
4770
|
-
|
4874
|
+
switch (value) {
|
4875
|
+
case 'primary':
|
4876
|
+
return "yt-blue-solid border-blue\n focus:bg-blue focus:text-white focus:yt-focus\n active:bg-blue-dark active:text-white \n hover:bg-blue-light hover:border-blue-light hover:text-white\n hover:focus:bg-blue-light hover:focus:border-blue-light hover:focus:text-white\n disabled:hover:yt-blue-solid";
|
4771
4877
|
|
4772
|
-
|
4773
|
-
|
4774
|
-
return index !== undefined ? index - 1 < 0 ? 0 : index - 1 : index;
|
4878
|
+
case 'danger':
|
4879
|
+
return "yt-red-solid border-red\n focus:bg-red focus:text-white focus:yt-focus-red\n active:bg-red-dark active:text-white \n hover:bg-red-light hover:text-white\n hover:focus:bg-red-light hover:focus:text-white\n disabled:hover:yt-red-solid";
|
4775
4880
|
|
4776
|
-
case
|
4777
|
-
return
|
4881
|
+
case 'ghost':
|
4882
|
+
return "yt-blue-inverted\n focus:bg-transparent focus:text-blue focus:yt-focus\n active:bg-blue-lightest active:border-blue active:text-blue-dark \n hover:bg-blue-lightest hover:border-blue-light hover:text-blue-light\n hover:focus:bg-blue-lightest hover:focus:border-blue-light hover:focus:text-blue-light\n disabled:hover:yt-blue-inverted";
|
4778
4883
|
|
4779
|
-
case
|
4780
|
-
|
4884
|
+
case 'discrete':
|
4885
|
+
{
|
4886
|
+
if (icon) {
|
4887
|
+
return "bg-transparent text-black border-transparent\n focus:text-black focus:yt-focus\n active:text-black\n hover:text-grey-darkest\n hover:focus:text-grey-darkest\n disabled:hover:yt-transparent";
|
4888
|
+
}
|
4781
4889
|
|
4782
|
-
|
4783
|
-
|
4890
|
+
return "yt-transparent border-transparent\n focus:text-blue focus:yt-focus\n active:text-blue-dark\n hover:text-blue-light\n hover:focus:text-blue-light\n disabled:hover:yt-transparent";
|
4891
|
+
}
|
4784
4892
|
|
4785
4893
|
default:
|
4786
|
-
return;
|
4894
|
+
return "yt-grey-solid border-grey\n focus:bg-grey focus:yt-focus\n active:bg-grey-dark active:text-black\n hover:bg-grey-light hover:text-grey-darkest\n hover:focus:bg-grey-light hover:focus:text-grey-darkest\n disabled:hover:yt-grey-solid";
|
4787
4895
|
}
|
4788
4896
|
};
|
4789
|
-
var
|
4790
|
-
|
4791
|
-
|
4792
|
-
|
4897
|
+
var createButton = function createButton(props, className, ref) {
|
4898
|
+
var dialog = props.dialog,
|
4899
|
+
hanger = props.hanger,
|
4900
|
+
menu = props.menu,
|
4901
|
+
popover = props.popover,
|
4902
|
+
tooltip = props.tooltip,
|
4903
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$i);
|
4793
4904
|
|
4794
|
-
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4905
|
+
var button = React__default.createElement(Button, Object.assign({}, otherProps, {
|
4906
|
+
className: className,
|
4907
|
+
ref: ref
|
4908
|
+
}));
|
4909
|
+
|
4910
|
+
if (hanger) {
|
4911
|
+
button = React__default.createElement(Hanger, Object.assign({}, hanger.props), React__default.createElement(Hanger.Anchor, null, button), hanger.props.children);
|
4798
4912
|
}
|
4799
4913
|
|
4800
|
-
|
4801
|
-
|
4802
|
-
|
4914
|
+
if (menu) {
|
4915
|
+
button = React__default.createElement(Menu, Object.assign({}, menu.props), React__default.createElement(Menu.Trigger, null, button), menu.props.children);
|
4916
|
+
}
|
4803
4917
|
|
4804
|
-
|
4805
|
-
|
4918
|
+
if (dialog) {
|
4919
|
+
button = React__default.createElement(Dialog, Object.assign({}, dialog.props), React__default.createElement(Dialog.Trigger, null, button), dialog.props.children);
|
4920
|
+
}
|
4806
4921
|
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4922
|
+
if (popover) {
|
4923
|
+
button = React__default.createElement(Popover, Object.assign({}, popover.props), React__default.createElement(Popover.Trigger, null, button), popover.props.children);
|
4924
|
+
}
|
4810
4925
|
|
4811
|
-
|
4812
|
-
|
4926
|
+
if (tooltip) {
|
4927
|
+
button = React__default.createElement(Tooltip, {
|
4928
|
+
title: tooltip
|
4929
|
+
}, button);
|
4930
|
+
}
|
4813
4931
|
|
4814
|
-
return
|
4932
|
+
return button;
|
4815
4933
|
};
|
4816
4934
|
|
4817
|
-
var
|
4818
|
-
|
4935
|
+
var _excluded$j = ["appearance", "icon", "rounded"];
|
4936
|
+
var IconButton = /*#__PURE__*/React.forwardRef(function IconButton(props, ref) {
|
4937
|
+
var appearance = props.appearance,
|
4938
|
+
icon = props.icon,
|
4939
|
+
_props$rounded = props.rounded,
|
4940
|
+
rounded = _props$rounded === void 0 ? false : _props$rounded,
|
4941
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$j);
|
4819
4942
|
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4943
|
+
var className = cn(getButtonClasses(), getAppearanceClasses$4(appearance, true), {
|
4944
|
+
'rounded-full': rounded,
|
4945
|
+
rounded: !rounded,
|
4946
|
+
'cursor-not-allowed opacity-50': props.disabled,
|
4947
|
+
'focus:yt-focus active:focus:yt-focus': !props.disabled
|
4948
|
+
}, props.className);
|
4824
4949
|
|
4825
|
-
|
4826
|
-
|
4827
|
-
} else if (child.offsetTop < scrollTop) {
|
4828
|
-
parent.scrollTop = child.offsetTop;
|
4829
|
-
}
|
4950
|
+
if (!icon) {
|
4951
|
+
return null;
|
4830
4952
|
}
|
4831
|
-
};
|
4832
4953
|
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
4836
|
-
|
4837
|
-
|
4954
|
+
return createButton(_extends({}, otherProps, {
|
4955
|
+
children: React.createElement(Icon, {
|
4956
|
+
name: icon,
|
4957
|
+
className: "m-0 p-0"
|
4958
|
+
}),
|
4959
|
+
'data-taco': 'icon-button'
|
4960
|
+
}), className, ref);
|
4961
|
+
});
|
4838
4962
|
|
4839
|
-
|
4840
|
-
|
4841
|
-
|
4842
|
-
|
4843
|
-
|
4844
|
-
|
4845
|
-
|
4846
|
-
|
4963
|
+
var Banner = /*#__PURE__*/React.forwardRef(function Banner(props, ref) {
|
4964
|
+
var children = props.children,
|
4965
|
+
state = props.state,
|
4966
|
+
onClose = props.onClose;
|
4967
|
+
var className = cn('bg-white relative flex items-center px-4 h-12 shadow-lg z-10', props.className);
|
4968
|
+
return React.createElement("div", {
|
4969
|
+
className: className,
|
4970
|
+
"data-taco": "banner",
|
4971
|
+
ref: ref
|
4972
|
+
}, getBannerIcon(state), children, onClose ? React.createElement(IconButton, {
|
4973
|
+
className: "ml-auto",
|
4974
|
+
icon: "close",
|
4975
|
+
appearance: "discrete",
|
4976
|
+
onClick: onClose
|
4977
|
+
}) : null);
|
4978
|
+
});
|
4847
4979
|
|
4848
|
-
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4980
|
+
var _excluded$k = ["appearance", "fluid"];
|
4981
|
+
var Button$1 = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
|
4982
|
+
var appearance = props.appearance,
|
4983
|
+
fluid = props.fluid,
|
4984
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$k);
|
4852
4985
|
|
4853
|
-
var
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4986
|
+
var className = cn(getButtonClasses(), getAppearanceClasses$4(appearance), 'rounded px-3', {
|
4987
|
+
'cursor-not-allowed opacity-50': props.disabled,
|
4988
|
+
'focus:yt-focus active:focus:yt-focus': !props.disabled,
|
4989
|
+
'w-full': fluid
|
4990
|
+
}, props.className);
|
4991
|
+
return createButton(_extends({}, otherProps, {
|
4992
|
+
'data-taco': 'button'
|
4993
|
+
}), className, ref);
|
4994
|
+
});
|
4995
|
+
|
4996
|
+
var _excluded$l = ["onChange", "value"];
|
4997
|
+
|
4998
|
+
var renderDay = function renderDay(day, modifiers) {
|
4999
|
+
return modifiers.disabled ? React.createElement("span", {
|
5000
|
+
className: "dot"
|
5001
|
+
}) : day.getDate();
|
4857
5002
|
};
|
4858
5003
|
|
4859
|
-
var
|
4860
|
-
|
5004
|
+
var thisYear = /*#__PURE__*/new Date().getFullYear();
|
5005
|
+
var years = [];
|
4861
5006
|
|
4862
|
-
|
4863
|
-
|
4864
|
-
|
4865
|
-
} else if (data[nextIndex] && data[nextIndex].disabled) {
|
4866
|
-
return getNextEnabledItem(event, data, nextIndex);
|
4867
|
-
}
|
4868
|
-
}
|
5007
|
+
for (var i = thisYear - 10; i <= thisYear + 10; i += 1) {
|
5008
|
+
years.push(i);
|
5009
|
+
}
|
4869
5010
|
|
4870
|
-
|
4871
|
-
|
5011
|
+
var Navbar = /*#__PURE__*/React.memo(function (_ref) {
|
5012
|
+
var onMonthChange = _ref.onMonthChange,
|
5013
|
+
onNextClick = _ref.onNextClick,
|
5014
|
+
onPreviousClick = _ref.onPreviousClick,
|
5015
|
+
_ref$value = _ref.value,
|
5016
|
+
value = _ref$value === void 0 ? new Date() : _ref$value;
|
4872
5017
|
|
4873
|
-
var
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
5018
|
+
var _useLocalization = useLocalization(),
|
5019
|
+
_useLocalization$text = _useLocalization.texts.calendar,
|
5020
|
+
actions = _useLocalization$text.actions,
|
5021
|
+
months = _useLocalization$text.months;
|
5022
|
+
|
5023
|
+
var handleChange = function handleChange(event) {
|
5024
|
+
var _event$target$form = event.target.form,
|
5025
|
+
year = _event$target$form.year,
|
5026
|
+
month = _event$target$form.month;
|
5027
|
+
onMonthChange(new Date(year.value, month.value));
|
5028
|
+
};
|
5029
|
+
|
5030
|
+
return React.createElement("div", {
|
5031
|
+
className: "flex justify-between items-center mb-2"
|
5032
|
+
}, React.createElement("form", {
|
5033
|
+
className: "inline-flex space-x-1"
|
5034
|
+
}, React.createElement("select", {
|
5035
|
+
className: "h-8 px-2",
|
5036
|
+
name: "month",
|
5037
|
+
onChange: handleChange,
|
5038
|
+
value: value.getMonth()
|
5039
|
+
}, months.map(function (month, i) {
|
5040
|
+
return React.createElement("option", {
|
5041
|
+
value: i
|
5042
|
+
}, month);
|
5043
|
+
})), React.createElement("select", {
|
5044
|
+
className: "h-8 px-2",
|
5045
|
+
name: "year",
|
5046
|
+
onChange: handleChange,
|
5047
|
+
value: value.getFullYear()
|
5048
|
+
}, years.map(function (year) {
|
5049
|
+
return React.createElement("option", {
|
5050
|
+
value: year
|
5051
|
+
}, String(year));
|
5052
|
+
}))), React.createElement("div", null, React.createElement(IconButton, {
|
5053
|
+
appearance: "discrete",
|
5054
|
+
icon: "chevron-left",
|
5055
|
+
"aria-label": actions.previousMonth,
|
5056
|
+
onClick: function onClick() {
|
5057
|
+
return onPreviousClick();
|
5058
|
+
},
|
5059
|
+
rounded: true
|
5060
|
+
}), React.createElement(IconButton, {
|
5061
|
+
appearance: "discrete",
|
5062
|
+
icon: "chevron-right",
|
5063
|
+
"aria-label": actions.nextMonth,
|
5064
|
+
onClick: function onClick() {
|
5065
|
+
return onNextClick();
|
5066
|
+
},
|
5067
|
+
rounded: true
|
5068
|
+
})));
|
5069
|
+
});
|
5070
|
+
var Calendar$1 = /*#__PURE__*/React.forwardRef(function Calendar(props, ref) {
|
5071
|
+
var handleChange = props.onChange,
|
5072
|
+
value = props.value,
|
5073
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$l);
|
5074
|
+
|
5075
|
+
var _useLocalization2 = useLocalization(),
|
5076
|
+
locale = _useLocalization2.locale,
|
5077
|
+
texts = _useLocalization2.texts;
|
5078
|
+
|
5079
|
+
var _React$useState = React.useState(value !== null && value !== void 0 ? value : new Date()),
|
5080
|
+
visibleMonth = _React$useState[0],
|
5081
|
+
setVisibleMonth = _React$useState[1];
|
5082
|
+
|
5083
|
+
React.useEffect(function () {
|
5084
|
+
if (visibleMonth !== value) {
|
5085
|
+
setVisibleMonth(value !== null && value !== void 0 ? value : new Date());
|
5086
|
+
}
|
5087
|
+
}, [value]);
|
5088
|
+
|
5089
|
+
var handleDayClick = function handleDayClick(date, modifiers, event) {
|
5090
|
+
if (modifiers.outside || modifiers.disabled) {
|
5091
|
+
return;
|
5092
|
+
}
|
5093
|
+
|
5094
|
+
handleChange(date, event);
|
5095
|
+
};
|
5096
|
+
|
5097
|
+
var handleCalendarClickToday = function handleCalendarClickToday() {
|
5098
|
+
var today = new Date(); // set to midday to avoid UTC offset causing dates to be mismatched server side
|
5099
|
+
|
5100
|
+
today.setHours(12);
|
5101
|
+
today.setMinutes(0);
|
5102
|
+
today.setSeconds(0);
|
5103
|
+
handleChange(today);
|
5104
|
+
};
|
5105
|
+
|
5106
|
+
var className = cn('flex bg-white text-xs p-4', otherProps.className);
|
5107
|
+
return React.createElement("div", {
|
5108
|
+
"data-taco": "calendar"
|
5109
|
+
}, React.createElement(ReactDayPicker, Object.assign({}, otherProps, {
|
5110
|
+
className: className,
|
5111
|
+
month: visibleMonth,
|
5112
|
+
selectedDays: value,
|
5113
|
+
locale: locale.substring(0, 2),
|
5114
|
+
firstDayOfWeek: 1,
|
5115
|
+
months: texts.calendar.months,
|
5116
|
+
weekdaysShort: texts.calendar.weekdaysShort,
|
5117
|
+
navbarElement: function navbarElement(navProps) {
|
5118
|
+
return React.createElement(Navbar, Object.assign({}, navProps, {
|
5119
|
+
onMonthChange: setVisibleMonth,
|
5120
|
+
value: visibleMonth
|
5121
|
+
}));
|
5122
|
+
},
|
5123
|
+
onDayClick: handleDayClick,
|
5124
|
+
onMonthChange: setVisibleMonth,
|
5125
|
+
onTodayButtonClick: handleCalendarClickToday,
|
5126
|
+
captionElement: function captionElement() {
|
5127
|
+
return null;
|
5128
|
+
},
|
5129
|
+
todayButton: texts.calendar.actions.today,
|
5130
|
+
showOutsideDays: true,
|
5131
|
+
renderDay: renderDay,
|
5132
|
+
numberOfMonths: 1,
|
5133
|
+
ref: ref
|
5134
|
+
})));
|
5135
|
+
});
|
5136
|
+
|
5137
|
+
var _excluded$m = ["checked", "highlighted", "indeterminate", "invalid", "label", "onChange"];
|
5138
|
+
var Checkbox$1 = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
|
5139
|
+
var checked = props.checked,
|
5140
|
+
highlighted = props.highlighted,
|
5141
|
+
indeterminate = props.indeterminate,
|
5142
|
+
invalid = props.invalid,
|
5143
|
+
label = props.label,
|
5144
|
+
onChange = props.onChange,
|
5145
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$m);
|
5146
|
+
|
5147
|
+
var className = cn('h-5 w-5 border rounded text-sm', {
|
5148
|
+
'mr-2': !!label,
|
5149
|
+
'border-grey-dark text-blue focus:border-blue focus:yt-focus': !props.disabled && !invalid,
|
5150
|
+
'border-grey text-blue-light cursor-not-allowed': props.disabled,
|
5151
|
+
'bg-[rgba(255,255,0,0.2)] disabled:bg-[rgba(255,255,0,0.075)]': highlighted,
|
5152
|
+
'border-red text-red focus:border-red focus:yt-focus-red': invalid && !props.disabled
|
5153
|
+
}, props.className);
|
5154
|
+
var handleChange;
|
5155
|
+
|
5156
|
+
if (onChange) {
|
5157
|
+
handleChange = function handleChange(checked) {
|
5158
|
+
return onChange(checked === 'indeterminate' ? false : checked);
|
5159
|
+
};
|
5160
|
+
}
|
5161
|
+
|
5162
|
+
var element = React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, {
|
5163
|
+
"data-taco": "checkbox",
|
5164
|
+
checked: indeterminate ? 'indeterminate' : checked,
|
5165
|
+
className: className,
|
5166
|
+
onCheckedChange: handleChange,
|
5167
|
+
ref: ref
|
5168
|
+
}), React.createElement(CheckboxPrimitive.Indicator, {
|
5169
|
+
className: "flex h-full w-full"
|
5170
|
+
}, React.createElement(Icon, {
|
5171
|
+
name: indeterminate ? 'line' : 'tick',
|
5172
|
+
className: "!h-full !w-full"
|
5173
|
+
})));
|
5174
|
+
|
5175
|
+
if (label) {
|
5176
|
+
var labelClassName = cn('flex items-center cursor-pointer', {
|
5177
|
+
'cursor-not-allowed text-grey-dark': props.disabled
|
5178
|
+
});
|
5179
|
+
return React.createElement("label", {
|
5180
|
+
className: labelClassName
|
5181
|
+
}, element, label);
|
5182
|
+
}
|
5183
|
+
|
5184
|
+
return element;
|
5185
|
+
});
|
5186
|
+
|
5187
|
+
var getInputClasses = function getInputClasses(props) {
|
5188
|
+
var _cn;
|
5189
|
+
|
5190
|
+
return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded inline-flex leading-6 px-2 relative w-full text-ellipsis transition-all delay-100 ease-in flex items-center', (_cn = {
|
5191
|
+
'cursor-not-allowed text-black bg-grey': props.readOnly,
|
5192
|
+
'border-grey text-opacity-25 cursor-not-allowed': props.disabled
|
5193
|
+
}, _cn[getStateClasses$1(props.state)] = !props.disabled, _cn['bg-[rgba(255,255,0,0.075)]'] = props.highlighted && props.disabled, _cn['bg-[rgba(255,255,0,0.2)]'] = props.highlighted && !props.disabled, _cn));
|
5194
|
+
};
|
5195
|
+
var getStateClasses$1 = function getStateClasses(value) {
|
5196
|
+
switch (value) {
|
5197
|
+
case 'success':
|
5198
|
+
return 'border-green hover:shadow-[0_0_0.15rem_theme(colors.green.DEFAULT)] focus:border-green-light focus:yt-focus-green active:border-green-dark';
|
5199
|
+
|
5200
|
+
case 'error':
|
5201
|
+
return 'border-red hover:shadow-[0_0_0.15rem_theme(colors.red.DEFAULT)] focus:border-red-light focus:yt-focus-red active:border-red-dark';
|
5202
|
+
|
5203
|
+
case 'warning':
|
5204
|
+
return 'border-yellow-dark hover:shadow-[0_0_0.15rem_theme(colors.yellow.dark)] focus:yt-focus-yellow active:border-yellow-dark';
|
5205
|
+
|
5206
|
+
case 'information':
|
5207
|
+
return 'border-blue hover:shadow-[0_0_0.15rem_theme(colors.blue.dark)] focus:border-blue-light focus:yt-focus active:border-blue-dark';
|
5208
|
+
|
5209
|
+
default:
|
5210
|
+
return 'border-grey-dark hover:shadow-[0_0_0.1rem_theme(colors.grey.darker)] focus:border-blue-light focus:yt-focus active:border-blue-dark';
|
5211
|
+
}
|
5212
|
+
};
|
5213
|
+
var getButtonStateClasses = function getButtonStateClasses(value) {
|
5214
|
+
switch (value) {
|
5215
|
+
case 'success':
|
5216
|
+
return '!border-green focus:!border-green-light focus:yt-focus-green peer-focus:!border-green-light peer-focus:peer-active:!border-green-dark';
|
5217
|
+
|
5218
|
+
case 'error':
|
5219
|
+
return '!border-red focus:!border-red-light focus:yt-focus-red peer-focus:!border-red-light peer-focus:peer-active:!border-red-dark';
|
5220
|
+
|
5221
|
+
case 'warning':
|
5222
|
+
return '!border-yellow-dark focus:!border-yellow-dark focus:yt-focus-yellow peer-focus:peer-active:!border-yellow-dark';
|
5223
|
+
|
5224
|
+
case 'information':
|
5225
|
+
return '!border-blue focus:!border-blue-light peer-focus:!border-blue-light peer-focus:peer-active:!border-blue-dark';
|
5226
|
+
|
5227
|
+
default:
|
5228
|
+
return '!border-grey-dark focus:!border-blue-light peer-focus:!border-blue-light peer-focus:peer-active:!border-blue-dark';
|
5229
|
+
}
|
5230
|
+
};
|
5231
|
+
|
5232
|
+
var _excluded$n = ["button", "icon", "highlighted", "state", "autoFocus"];
|
5233
|
+
var Input = /*#__PURE__*/React.forwardRef(function Input(props, ref) {
|
5234
|
+
var button = props.button,
|
5235
|
+
icon = props.icon,
|
5236
|
+
state = props.state,
|
5237
|
+
autoFocus = props.autoFocus,
|
5238
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$n);
|
5239
|
+
|
5240
|
+
var inputRef = useProxiedRef(ref);
|
5241
|
+
var hasContainer = button || icon;
|
5242
|
+
var className = cn(getInputClasses(props), 'min-h-[theme(spacing.8)] pointer-events-all', {
|
5243
|
+
'pr-8': !!hasContainer
|
5244
|
+
}, !hasContainer && otherProps.className);
|
5245
|
+
React.useEffect(function () {
|
5246
|
+
if (autoFocus && inputRef.current) {
|
5247
|
+
inputRef.current.focus();
|
5248
|
+
}
|
5249
|
+
}, []);
|
5250
|
+
var input = React.createElement("input", Object.assign({}, otherProps, {
|
5251
|
+
className: className,
|
5252
|
+
"data-taco": "input",
|
5253
|
+
ref: inputRef
|
5254
|
+
}));
|
5255
|
+
|
5256
|
+
if (hasContainer) {
|
5257
|
+
var extra;
|
5258
|
+
|
5259
|
+
if (button) {
|
5260
|
+
var _button$props$disable, _cn;
|
5261
|
+
|
5262
|
+
var disabled = (_button$props$disable = button.props.disabled) !== null && _button$props$disable !== void 0 ? _button$props$disable : otherProps.disabled;
|
5263
|
+
var buttonClassName = cn('items-center flex justify-center border absolute rounded-l-none rounded-r right-0 h-full focus:rounded focus:outline-none', (_cn = {}, _cn[getButtonStateClasses(state)] = !props.disabled, _cn), button.props.className);
|
5264
|
+
extra = React.cloneElement(button, {
|
5265
|
+
className: buttonClassName,
|
5266
|
+
disabled: disabled
|
5267
|
+
});
|
5268
|
+
} else if (icon) {
|
5269
|
+
var iconClassName = cn('items-center flex justify-center absolute pointer-events-none mr-1 p-px right-0 w-5 top-1/2 -translate-y-1/2', {
|
5270
|
+
'text-grey-dark': props.disabled,
|
5271
|
+
'text-grey-darkest': !props.disabled
|
5272
|
+
});
|
5273
|
+
extra = typeof icon === 'string' ? React.createElement(Icon, {
|
5274
|
+
className: iconClassName,
|
5275
|
+
name: icon
|
5276
|
+
}) : React.cloneElement(icon, {
|
5277
|
+
className: cn(iconClassName, icon.props.className)
|
5278
|
+
});
|
5279
|
+
}
|
5280
|
+
|
5281
|
+
var containerClassName = cn('bg-white inline-flex relative rounded w-full', otherProps.className);
|
5282
|
+
return React.createElement("div", {
|
5283
|
+
className: containerClassName,
|
5284
|
+
"data-taco": "input-container"
|
5285
|
+
}, input, extra);
|
5286
|
+
}
|
5287
|
+
|
5288
|
+
return input;
|
5289
|
+
});
|
5290
|
+
|
5291
|
+
var getNextIndexFromKeycode = function getNextIndexFromKeycode(keyCode, length, index, direction) {
|
5292
|
+
if (direction === void 0) {
|
5293
|
+
direction = 'vertical';
|
5294
|
+
}
|
5295
|
+
|
5296
|
+
var previousKey = direction === 'horizontal' ? 'left' : 'up';
|
5297
|
+
var nextKey = direction === 'horizontal' ? 'right' : 'down';
|
5298
|
+
|
5299
|
+
switch (keyCode) {
|
5300
|
+
case keycode(previousKey):
|
5301
|
+
return index !== undefined ? index - 1 < 0 ? 0 : index - 1 : index;
|
5302
|
+
|
5303
|
+
case keycode(nextKey):
|
5304
|
+
return index !== undefined ? index + 1 >= length ? index : index + 1 : index;
|
5305
|
+
|
5306
|
+
case keycode('home'):
|
5307
|
+
return 0;
|
5308
|
+
|
5309
|
+
case keycode('end'):
|
5310
|
+
return length - 1;
|
5311
|
+
|
5312
|
+
default:
|
5313
|
+
return;
|
5314
|
+
}
|
5315
|
+
};
|
5316
|
+
var useListKeyboardNavigation = function useListKeyboardNavigation(length, options) {
|
5317
|
+
if (length === void 0) {
|
5318
|
+
length = 0;
|
5319
|
+
}
|
5320
|
+
|
5321
|
+
if (options === void 0) {
|
5322
|
+
options = {
|
5323
|
+
direction: 'vertical'
|
5324
|
+
};
|
5325
|
+
}
|
5326
|
+
|
5327
|
+
var _React$useState = React__default.useState(options.initialIndex),
|
5328
|
+
index = _React$useState[0],
|
5329
|
+
setIndex = _React$useState[1];
|
5330
|
+
|
5331
|
+
var getNextIndex = function getNextIndex(event) {
|
5332
|
+
var nextIndex = getNextIndexFromKeycode(event.keyCode, length, index, options.direction);
|
5333
|
+
|
5334
|
+
if (nextIndex !== undefined) {
|
5335
|
+
event.preventDefault();
|
5336
|
+
}
|
5337
|
+
|
5338
|
+
return nextIndex;
|
5339
|
+
};
|
5340
|
+
|
5341
|
+
return [index, setIndex, getNextIndex];
|
5342
|
+
};
|
5343
|
+
|
5344
|
+
var scrollToChildElement = function scrollToChildElement(parent, child) {
|
5345
|
+
var clientHeight = parent.clientHeight;
|
5346
|
+
|
5347
|
+
if (parent.scrollHeight > clientHeight) {
|
5348
|
+
var scrollTop = parent.scrollTop;
|
5349
|
+
var scrollBottom = clientHeight + scrollTop;
|
5350
|
+
var childBottom = child.offsetTop + child.offsetHeight;
|
5351
|
+
|
5352
|
+
if (childBottom > scrollBottom) {
|
5353
|
+
parent.scrollTop = childBottom - clientHeight;
|
5354
|
+
} else if (child.offsetTop < scrollTop) {
|
5355
|
+
parent.scrollTop = child.offsetTop;
|
5356
|
+
}
|
5357
|
+
}
|
5358
|
+
};
|
5359
|
+
|
5360
|
+
var useListScrollTo = function useListScrollTo(internalRef, itemRefs) {
|
5361
|
+
var scrollTo = function scrollTo(index) {
|
5362
|
+
if (internalRef && internalRef.current) {
|
5363
|
+
if (index !== undefined) {
|
5364
|
+
var activeRef = itemRefs[index];
|
5365
|
+
|
5366
|
+
if (activeRef && activeRef.current) {
|
5367
|
+
scrollToChildElement(internalRef.current, activeRef.current);
|
5368
|
+
}
|
5369
|
+
} else {
|
5370
|
+
internalRef.current.scrollTop = 0;
|
5371
|
+
}
|
5372
|
+
}
|
5373
|
+
};
|
5374
|
+
|
5375
|
+
return {
|
5376
|
+
scrollTo: scrollTo
|
5377
|
+
};
|
5378
|
+
};
|
5379
|
+
|
5380
|
+
var _excluded$o = ["data", "disabled", "highlighted", "id", "loading", "onChange", "onClick", "onFocus", "onKeyDown", "readOnly", "scrollOnFocus", "state", "value", "multiselect", "selectedIndexes", "allOptionsSelected"],
|
5381
|
+
_excluded2$2 = ["children", "icon"];
|
5382
|
+
var getId = function getId(id, value) {
|
5383
|
+
return id + "_" + value;
|
5384
|
+
};
|
5385
|
+
|
5386
|
+
var getNextEnabledItem = function getNextEnabledItem(event, data, index) {
|
5387
|
+
var nextIndex = getNextIndexFromKeycode(event.keyCode, data.length, index);
|
5388
|
+
|
5389
|
+
if (nextIndex) {
|
5390
|
+
if (nextIndex === index) {
|
5391
|
+
return index;
|
5392
|
+
} else if (data[nextIndex] && data[nextIndex].disabled) {
|
5393
|
+
return getNextEnabledItem(event, data, nextIndex);
|
5394
|
+
}
|
5395
|
+
}
|
5396
|
+
|
5397
|
+
return nextIndex;
|
5398
|
+
};
|
5399
|
+
|
5400
|
+
var ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(props, ref) {
|
5401
|
+
var data = props.data,
|
5402
|
+
disabled = props.disabled,
|
5403
|
+
id = props.id,
|
4877
5404
|
loading = props.loading,
|
4878
5405
|
setCurrentIndex = props.onChange,
|
4879
5406
|
onClick = props.onClick,
|
@@ -4888,7 +5415,7 @@ var ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(props
|
|
4888
5415
|
selectedIndexes = _props$selectedIndexe === void 0 ? [] : _props$selectedIndexe,
|
4889
5416
|
_props$allOptionsSele = props.allOptionsSelected,
|
4890
5417
|
allOptionsSelected = _props$allOptionsSele === void 0 ? false : _props$allOptionsSele,
|
4891
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$
|
5418
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$o);
|
4892
5419
|
|
4893
5420
|
var listRef = useProxiedRef(ref);
|
4894
5421
|
var itemRefs = React.useMemo(function () {
|
@@ -5003,11 +5530,11 @@ var ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(props
|
|
5003
5530
|
})), React.createElement("span", null, texts.listbox.loading)) : options.length ? options.map(function (_ref) {
|
5004
5531
|
var children = _ref.children,
|
5005
5532
|
icon = _ref.icon,
|
5006
|
-
optionProps = _objectWithoutPropertiesLoose(_ref, _excluded2$
|
5533
|
+
optionProps = _objectWithoutPropertiesLoose(_ref, _excluded2$2);
|
5007
5534
|
|
5008
5535
|
return React.createElement("li", Object.assign({}, optionProps), icon, React.createElement("span", {
|
5009
5536
|
className: "flex-grow truncate text-left"
|
5010
|
-
}, children), multiselect && React.createElement(Checkbox, {
|
5537
|
+
}, children), multiselect && React.createElement(Checkbox$1, {
|
5011
5538
|
checked: optionProps['aria-selected'],
|
5012
5539
|
onChange: function onChange() {
|
5013
5540
|
return null;
|
@@ -5070,7 +5597,7 @@ var setInputValueByRef = function setInputValueByRef(input, value, event) {
|
|
5070
5597
|
input.dispatchEvent(createCustomEvent(event));
|
5071
5598
|
};
|
5072
5599
|
|
5073
|
-
var _excluded$
|
5600
|
+
var _excluded$p = ["hasChildren", "path"];
|
5074
5601
|
var setInputValueByRef$1 = function setInputValueByRef$1(input, value, event) {
|
5075
5602
|
if (event === void 0) {
|
5076
5603
|
event = 'change';
|
@@ -5099,7 +5626,7 @@ var getSelectedIndexesFromValue = function getSelectedIndexesFromValue(data, val
|
|
5099
5626
|
return v !== -1;
|
5100
5627
|
});
|
5101
5628
|
};
|
5102
|
-
var findByValue = function findByValue(data, value) {
|
5629
|
+
var findByValue$1 = function findByValue(data, value) {
|
5103
5630
|
return data.find(function (option) {
|
5104
5631
|
return getValue(option.value) === getValue(value);
|
5105
5632
|
});
|
@@ -5188,7 +5715,7 @@ var useFlattenedData = function useFlattenedData(data) {
|
|
5188
5715
|
};
|
5189
5716
|
var sanitizeItem = function sanitizeItem(item) {
|
5190
5717
|
if (item) {
|
5191
|
-
var rest = _objectWithoutPropertiesLoose(item, _excluded$
|
5718
|
+
var rest = _objectWithoutPropertiesLoose(item, _excluded$p);
|
5192
5719
|
|
5193
5720
|
return rest;
|
5194
5721
|
}
|
@@ -5252,7 +5779,10 @@ var filterData = function filterData(data, value) {
|
|
5252
5779
|
});
|
5253
5780
|
};
|
5254
5781
|
|
5255
|
-
var _excluded$
|
5782
|
+
var _excluded$q = ["aria-label", "aria-labelledby", "data", "defaultValue", "disabled", "id", "inline", "loading", "onChange", "onClick", "onKeyDown", "onSearch", "readOnly", "value"];
|
5783
|
+
var debouncer = /*#__PURE__*/debounce(function (f) {
|
5784
|
+
return f();
|
5785
|
+
}, 200);
|
5256
5786
|
|
5257
5787
|
var convertToInputValue = function convertToInputValue(value) {
|
5258
5788
|
return String(value !== null && value !== void 0 ? value : '');
|
@@ -5268,9 +5798,10 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
5268
5798
|
onChange = _ref.onChange,
|
5269
5799
|
onClick = _ref.onClick,
|
5270
5800
|
onKeyDown = _ref.onKeyDown,
|
5801
|
+
onSearch = _ref.onSearch,
|
5271
5802
|
readOnly = _ref.readOnly,
|
5272
5803
|
value = _ref.value,
|
5273
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
5804
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$q);
|
5274
5805
|
|
5275
5806
|
var inputRef = useProxiedRef(ref);
|
5276
5807
|
var listRef = React.useRef(null);
|
@@ -5287,7 +5818,7 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
5287
5818
|
inputValue = _React$useState2[0],
|
5288
5819
|
setInputValue = _React$useState2[1];
|
5289
5820
|
|
5290
|
-
var shouldFilterData = !inline || inline && inputValue !== convertToInputValue(value);
|
5821
|
+
var shouldFilterData = !onSearch && (!inline || inline && inputValue !== convertToInputValue(value));
|
5291
5822
|
var flattenedData = useFlattenedData(unfilteredData);
|
5292
5823
|
var data = React.useMemo(function () {
|
5293
5824
|
return shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData;
|
@@ -5333,7 +5864,14 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
5333
5864
|
if (value !== undefined && value !== inputValue) {
|
5334
5865
|
setInputValue(convertToInputValue(value));
|
5335
5866
|
}
|
5336
|
-
}, [value]);
|
5867
|
+
}, [value]);
|
5868
|
+
React.useEffect(function () {
|
5869
|
+
if (onSearch) {
|
5870
|
+
debouncer(function () {
|
5871
|
+
onSearch(inputValue);
|
5872
|
+
});
|
5873
|
+
}
|
5874
|
+
}, [inputValue]); // show listbox based on input value
|
5337
5875
|
|
5338
5876
|
React.useEffect(function () {
|
5339
5877
|
// don't show the popover if the internal (input) value already is the current value
|
@@ -5367,7 +5905,7 @@ var useCombobox = function useCombobox(_ref, ref) {
|
|
5367
5905
|
}
|
5368
5906
|
|
5369
5907
|
if (onChange && event.target.value !== value) {
|
5370
|
-
var item = findByValue(flattenedData, event.target.value);
|
5908
|
+
var item = findByValue$1(flattenedData, event.target.value);
|
5371
5909
|
event.detail = sanitizeItem(item);
|
5372
5910
|
var parents = getOptionParents(flattenedData, item === null || item === void 0 ? void 0 : item.path);
|
5373
5911
|
|
@@ -5564,11 +6102,11 @@ var useBoundingClientRectListener = function useBoundingClientRectListener(ref)
|
|
5564
6102
|
return dimensions;
|
5565
6103
|
};
|
5566
6104
|
|
5567
|
-
var _excluded$
|
6105
|
+
var _excluded$r = ["className", "style"];
|
5568
6106
|
var Combobox = /*#__PURE__*/React.forwardRef(function Combobox(props, ref) {
|
5569
6107
|
var externalClassName = props.className,
|
5570
6108
|
style = props.style,
|
5571
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$
|
6109
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$r);
|
5572
6110
|
|
5573
6111
|
var _useCombobox = useCombobox(otherProps, ref),
|
5574
6112
|
combobox = _useCombobox.combobox,
|
@@ -5711,13 +6249,13 @@ var parseFromISOString = function parseFromISOString(date) {
|
|
5711
6249
|
return dateFns.isValid(tempDate) ? parseFromCustomString(format(new Date(date))) : undefined;
|
5712
6250
|
};
|
5713
6251
|
|
5714
|
-
var _excluded$
|
6252
|
+
var _excluded$s = ["defaultValue", "calendar", "onBlur", "onChange", "value"];
|
5715
6253
|
var useDatepicker = function useDatepicker(_ref, ref) {
|
5716
6254
|
var calendar = _ref.calendar,
|
5717
6255
|
onBlur = _ref.onBlur,
|
5718
6256
|
onChange = _ref.onChange,
|
5719
6257
|
value = _ref.value,
|
5720
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
6258
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$s);
|
5721
6259
|
|
5722
6260
|
var inputRef = useProxiedRef(ref);
|
5723
6261
|
|
@@ -5788,7 +6326,7 @@ var useDatepicker = function useDatepicker(_ref, ref) {
|
|
5788
6326
|
};
|
5789
6327
|
};
|
5790
6328
|
|
5791
|
-
var _excluded$
|
6329
|
+
var _excluded$t = ["className", "onReset", "style", "shortcuts", "shortcutsText"];
|
5792
6330
|
var Datepicker = /*#__PURE__*/React.forwardRef(function Datepicker(props, ref) {
|
5793
6331
|
var _input$disabled;
|
5794
6332
|
|
@@ -5797,7 +6335,7 @@ var Datepicker = /*#__PURE__*/React.forwardRef(function Datepicker(props, ref) {
|
|
5797
6335
|
style = props.style,
|
5798
6336
|
shortcuts = props.shortcuts,
|
5799
6337
|
shortcutsText = props.shortcutsText,
|
5800
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$
|
6338
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$t);
|
5801
6339
|
|
5802
6340
|
var _useDatepicker = useDatepicker(otherProps, ref),
|
5803
6341
|
calendar = _useDatepicker.calendar,
|
@@ -5853,11 +6391,11 @@ var Datepicker = /*#__PURE__*/React.forwardRef(function Datepicker(props, ref) {
|
|
5853
6391
|
})));
|
5854
6392
|
});
|
5855
6393
|
|
5856
|
-
var _excluded$
|
6394
|
+
var _excluded$u = ["horizontal"];
|
5857
6395
|
var Form = /*#__PURE__*/React.forwardRef(function Form(props, ref) {
|
5858
6396
|
var _props$horizontal = props.horizontal,
|
5859
6397
|
horizontal = _props$horizontal === void 0 ? false : _props$horizontal,
|
5860
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$
|
6398
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$u);
|
5861
6399
|
|
5862
6400
|
var className = cn('yt-form', {
|
5863
6401
|
'yt-form--horizontal flex flex-wrap': horizontal
|
@@ -5869,10 +6407,24 @@ var Form = /*#__PURE__*/React.forwardRef(function Form(props, ref) {
|
|
5869
6407
|
}));
|
5870
6408
|
});
|
5871
6409
|
|
5872
|
-
var _excluded$
|
6410
|
+
var _excluded$v = ["as"];
|
6411
|
+
var Group = /*#__PURE__*/React.forwardRef(function Group(props, ref) {
|
6412
|
+
var _props$as = props.as,
|
6413
|
+
Tag = _props$as === void 0 ? 'span' : _props$as,
|
6414
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$v);
|
6415
|
+
|
6416
|
+
var className = cn('flex ', props.className);
|
6417
|
+
return React.createElement(Tag, Object.assign({}, otherProps, {
|
6418
|
+
className: className,
|
6419
|
+
"data-taco": "group",
|
6420
|
+
ref: ref
|
6421
|
+
}));
|
6422
|
+
});
|
6423
|
+
|
6424
|
+
var _excluded$w = ["onSearch"];
|
5873
6425
|
var SearchInput = /*#__PURE__*/React.forwardRef(function SearchInput(_ref, ref) {
|
5874
6426
|
var onSearch = _ref.onSearch,
|
5875
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
6427
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$w);
|
5876
6428
|
|
5877
6429
|
var _useLocalization = useLocalization(),
|
5878
6430
|
texts = _useLocalization.texts;
|
@@ -5905,13 +6457,13 @@ var SearchInput = /*#__PURE__*/React.forwardRef(function SearchInput(_ref, ref)
|
|
5905
6457
|
}));
|
5906
6458
|
});
|
5907
6459
|
|
5908
|
-
var _excluded$
|
6460
|
+
var _excluded$x = ["disabled", "children", "message", "state"];
|
5909
6461
|
var Label = /*#__PURE__*/React.forwardRef(function Label(props, ref) {
|
5910
6462
|
var disabled = props.disabled,
|
5911
6463
|
children = props.children,
|
5912
6464
|
message = props.message,
|
5913
6465
|
state = props.state,
|
5914
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$
|
6466
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$x);
|
5915
6467
|
|
5916
6468
|
var className = cn('flex flex-col font-bold text-xs leading-loose pb-4 min-h-[theme(spacing.18)]', {
|
5917
6469
|
'text-grey-dark': disabled
|
@@ -5955,7 +6507,7 @@ var useTypeahead = function useTypeahead(_ref) {
|
|
5955
6507
|
};
|
5956
6508
|
};
|
5957
6509
|
|
5958
|
-
var _excluded$
|
6510
|
+
var _excluded$y = ["data", "defaultValue", "disabled", "emptyValue", "id", "name", "onChange", "onFocus", "onKeyDown", "value"];
|
5959
6511
|
var useListbox = function useListbox(_ref, ref) {
|
5960
6512
|
var _ref$data = _ref.data,
|
5961
6513
|
externalData = _ref$data === void 0 ? [] : _ref$data,
|
@@ -5969,7 +6521,7 @@ var useListbox = function useListbox(_ref, ref) {
|
|
5969
6521
|
onKeyDown = _ref.onKeyDown,
|
5970
6522
|
_ref$value = _ref.value,
|
5971
6523
|
value = _ref$value === void 0 ? emptyValue : _ref$value,
|
5972
|
-
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$
|
6524
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$y);
|
5973
6525
|
|
5974
6526
|
var data = useFlattenedData(emptyValue !== undefined ? [{
|
5975
6527
|
text: '',
|
@@ -6005,246 +6557,29 @@ var useListbox = function useListbox(_ref, ref) {
|
|
6005
6557
|
if (data.length && currentIndex === undefined) {
|
6006
6558
|
if (defaultValue !== undefined) {
|
6007
6559
|
var defaultValueIndex = getIndexFromValue(data, defaultValue);
|
6008
|
-
|
6009
|
-
if (defaultValueIndex !== undefined) {
|
6010
|
-
setInputValueByIndex(defaultValueIndex);
|
6011
|
-
}
|
6012
|
-
} else {
|
6013
|
-
setInputValueByIndex(0);
|
6014
|
-
}
|
6015
|
-
}
|
6016
|
-
}, [data]);
|
6017
|
-
|
6018
|
-
var handleListboxKeyDown = function handleListboxKeyDown(event) {
|
6019
|
-
var charKey = String.fromCharCode(event.keyCode);
|
6020
|
-
|
6021
|
-
if (charKey.match(/(\w)/g)) {
|
6022
|
-
var nextIndex = getNextIndex(charKey);
|
6023
|
-
|
6024
|
-
if (nextIndex > -1 && nextIndex !== currentIndex) {
|
6025
|
-
setInputValueByIndex(nextIndex);
|
6026
|
-
}
|
6027
|
-
|
6028
|
-
return;
|
6029
|
-
}
|
6030
|
-
|
6031
|
-
if (onKeyDown) {
|
6032
|
-
event.persist();
|
6033
|
-
onKeyDown(event);
|
6034
|
-
}
|
6035
|
-
};
|
6036
|
-
|
6037
|
-
var handleListboxFocus = function handleListboxFocus(event) {
|
6038
|
-
if (currentIndex === undefined && data.length) {
|
6039
|
-
setInputValueByIndex(0);
|
6040
|
-
}
|
6041
|
-
|
6042
|
-
if (onFocus) {
|
6043
|
-
event.persist();
|
6044
|
-
onFocus(event);
|
6045
|
-
}
|
6046
|
-
};
|
6047
|
-
|
6048
|
-
var handleInputChange = function handleInputChange(event) {
|
6049
|
-
event.persist();
|
6050
|
-
|
6051
|
-
if (onChange) {
|
6052
|
-
var _item$path$split, _item$path;
|
6053
|
-
|
6054
|
-
var item = findByValue(data, event.target.value);
|
6055
|
-
event.detail = sanitizeItem(item);
|
6056
|
-
var indexes = (_item$path$split = item === null || item === void 0 ? void 0 : (_item$path = item.path) === null || _item$path === void 0 ? void 0 : _item$path.split('.')) !== null && _item$path$split !== void 0 ? _item$path$split : [];
|
6057
|
-
|
6058
|
-
if (indexes.length > 1) {
|
6059
|
-
// we don't want to map the current item
|
6060
|
-
indexes.pop(); // we need to rebuild the path as we map
|
6061
|
-
|
6062
|
-
var lastPath;
|
6063
|
-
event.detail.parents = indexes.map(function (i) {
|
6064
|
-
lastPath = lastPath ? [lastPath, i].join('.') : i;
|
6065
|
-
return sanitizeItem(data.find(function (i) {
|
6066
|
-
return i.path === lastPath;
|
6067
|
-
}));
|
6068
|
-
});
|
6069
|
-
}
|
6070
|
-
|
6071
|
-
onChange(event);
|
6072
|
-
}
|
6073
|
-
};
|
6074
|
-
|
6075
|
-
var list = _extends({}, otherProps, {
|
6076
|
-
'aria-activedescendant': getActiveDescendant(data, currentIndex, id),
|
6077
|
-
data: data,
|
6078
|
-
disabled: disabled,
|
6079
|
-
id: id,
|
6080
|
-
onChange: handleListboxChange,
|
6081
|
-
onFocus: handleListboxFocus,
|
6082
|
-
onKeyDown: handleListboxKeyDown,
|
6083
|
-
scrollOnFocus: true,
|
6084
|
-
tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,
|
6085
|
-
value: currentIndex
|
6086
|
-
});
|
6087
|
-
|
6088
|
-
var input = {
|
6089
|
-
name: name,
|
6090
|
-
onChange: handleInputChange,
|
6091
|
-
ref: inputRef,
|
6092
|
-
tabIndex: -1,
|
6093
|
-
value: value === undefined || value === null ? '' : value
|
6094
|
-
};
|
6095
|
-
return {
|
6096
|
-
list: list,
|
6097
|
-
input: input
|
6098
|
-
};
|
6099
|
-
};
|
6100
|
-
|
6101
|
-
var _excluded$t = ["data", "defaultValue", "disabled", "id", "name", "onClick", "onChange", "onFocus", "onKeyDown", "value"];
|
6102
|
-
var useMultiListbox = function useMultiListbox(_ref, ref) {
|
6103
|
-
var _ref$data = _ref.data,
|
6104
|
-
externalData = _ref$data === void 0 ? [] : _ref$data,
|
6105
|
-
defaultValue = _ref.defaultValue,
|
6106
|
-
disabled = _ref.disabled,
|
6107
|
-
nativeId = _ref.id,
|
6108
|
-
name = _ref.name,
|
6109
|
-
onClick = _ref.onClick,
|
6110
|
-
onChange = _ref.onChange,
|
6111
|
-
onFocus = _ref.onFocus,
|
6112
|
-
onKeyDown = _ref.onKeyDown,
|
6113
|
-
value = _ref.value,
|
6114
|
-
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$t);
|
6115
|
-
|
6116
|
-
var _useLocalization = useLocalization(),
|
6117
|
-
texts = _useLocalization.texts;
|
6118
|
-
|
6119
|
-
var id = React.useMemo(function () {
|
6120
|
-
return nativeId || uuid.v4();
|
6121
|
-
}, [nativeId]);
|
6122
|
-
var inputRef = useProxiedRef(ref);
|
6123
|
-
var data = React.useMemo(function () {
|
6124
|
-
return [{
|
6125
|
-
text: texts.listbox.allOption,
|
6126
|
-
value: '#ALL-OPTIONS#'
|
6127
|
-
}].concat(externalData);
|
6128
|
-
}, [externalData]);
|
6129
|
-
|
6130
|
-
var _React$useState = React.useState(getIndexFromValue(data, value) || 0),
|
6131
|
-
currentIndex = _React$useState[0],
|
6132
|
-
setCurrentIndex = _React$useState[1];
|
6133
|
-
|
6134
|
-
var _React$useState2 = React.useState(false),
|
6135
|
-
allOptionsSelected = _React$useState2[0],
|
6136
|
-
setAllOptionsSelected = _React$useState2[1];
|
6137
|
-
|
6138
|
-
var _useTypeahead = useTypeahead({
|
6139
|
-
data: data,
|
6140
|
-
currentIndex: currentIndex
|
6141
|
-
}),
|
6142
|
-
getNextIndex = _useTypeahead.getNextIndex;
|
6143
|
-
|
6144
|
-
var _React$useState3 = React.useState(getSelectedIndexesFromValue(data, value)),
|
6145
|
-
selectedIndexes = _React$useState3[0],
|
6146
|
-
setSelectedIndexes = _React$useState3[1];
|
6147
|
-
|
6148
|
-
React.useEffect(function () {
|
6149
|
-
if (defaultValue && !value) {
|
6150
|
-
setInputValueByRef$1(inputRef.current, defaultValue.toString());
|
6151
|
-
}
|
6152
|
-
}, []);
|
6153
|
-
React.useEffect(function () {
|
6154
|
-
var selectableItemsCount = data.filter(function (item) {
|
6155
|
-
return !item.disabled;
|
6156
|
-
}).length - 1;
|
6157
|
-
|
6158
|
-
if (selectableItemsCount === selectedIndexes.length) {
|
6159
|
-
setAllOptionsSelected(true);
|
6160
|
-
} else {
|
6161
|
-
setAllOptionsSelected(false);
|
6162
|
-
}
|
6163
|
-
}, [selectedIndexes, data]);
|
6164
|
-
|
6165
|
-
var setInputValueByIndex = function setInputValueByIndex(index) {
|
6166
|
-
if (index !== undefined) {
|
6167
|
-
var option = data[index];
|
6168
|
-
|
6169
|
-
if (option && !option.disabled) {
|
6170
|
-
var _inputRef$current;
|
6171
|
-
|
6172
|
-
var newInputValue = '';
|
6173
|
-
var currentInputValue = (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value;
|
6174
|
-
var currentValuesArray = (currentInputValue === null || currentInputValue === void 0 ? void 0 : currentInputValue.split(',')) || [];
|
6175
|
-
var optionAlreadySelected = currentValuesArray.findIndex(function (val) {
|
6176
|
-
return val === String(option.value);
|
6177
|
-
}) !== -1; // Handling the select_all option
|
6178
|
-
|
6179
|
-
if (option.value === '#ALL-OPTIONS#') {
|
6180
|
-
if (!allOptionsSelected) {
|
6181
|
-
newInputValue = data.filter(function (option, index) {
|
6182
|
-
return index !== 0 && !option.disabled;
|
6183
|
-
}).map(function (option) {
|
6184
|
-
return option.value;
|
6185
|
-
}).join(',');
|
6186
|
-
} else {
|
6187
|
-
newInputValue = '';
|
6188
|
-
}
|
6189
|
-
} else {
|
6190
|
-
// Handling rest options
|
6191
|
-
if (optionAlreadySelected) {
|
6192
|
-
newInputValue = currentValuesArray.filter(function (val) {
|
6193
|
-
return val !== String(option.value);
|
6194
|
-
}).join(',');
|
6195
|
-
} else {
|
6196
|
-
newInputValue = currentInputValue ? currentInputValue + "," + option.value : option.value;
|
6197
|
-
}
|
6198
|
-
}
|
6199
|
-
|
6200
|
-
setInputValueByRef$1(inputRef.current, newInputValue);
|
6201
|
-
}
|
6202
|
-
}
|
6203
|
-
};
|
6204
|
-
|
6205
|
-
var handleListboxClick = function handleListboxClick(event, index) {
|
6206
|
-
event.preventDefault();
|
6207
|
-
|
6208
|
-
if (!data[index].disabled) {
|
6209
|
-
setCurrentIndex(index);
|
6210
|
-
setInputValueByIndex(index);
|
6211
|
-
}
|
6212
|
-
|
6213
|
-
if (onClick) {
|
6214
|
-
onClick(event);
|
6560
|
+
|
6561
|
+
if (defaultValueIndex !== undefined) {
|
6562
|
+
setInputValueByIndex(defaultValueIndex);
|
6563
|
+
}
|
6564
|
+
} else {
|
6565
|
+
setInputValueByIndex(0);
|
6566
|
+
}
|
6215
6567
|
}
|
6216
|
-
};
|
6568
|
+
}, [data]);
|
6217
6569
|
|
6218
|
-
var handleListboxKeyDown = function handleListboxKeyDown(event
|
6570
|
+
var handleListboxKeyDown = function handleListboxKeyDown(event) {
|
6219
6571
|
var charKey = String.fromCharCode(event.keyCode);
|
6220
6572
|
|
6221
6573
|
if (charKey.match(/(\w)/g)) {
|
6222
6574
|
var nextIndex = getNextIndex(charKey);
|
6223
6575
|
|
6224
6576
|
if (nextIndex > -1 && nextIndex !== currentIndex) {
|
6225
|
-
|
6577
|
+
setInputValueByIndex(nextIndex);
|
6226
6578
|
}
|
6227
6579
|
|
6228
6580
|
return;
|
6229
6581
|
}
|
6230
6582
|
|
6231
|
-
switch (event.keyCode) {
|
6232
|
-
case keycode('space'):
|
6233
|
-
{
|
6234
|
-
event.preventDefault();
|
6235
|
-
setInputValueByIndex(index);
|
6236
|
-
break;
|
6237
|
-
}
|
6238
|
-
|
6239
|
-
case keycode('enter'):
|
6240
|
-
{
|
6241
|
-
setInputValueByIndex(index);
|
6242
|
-
break;
|
6243
|
-
}
|
6244
|
-
}
|
6245
|
-
|
6246
|
-
setCurrentIndex(index);
|
6247
|
-
|
6248
6583
|
if (onKeyDown) {
|
6249
6584
|
event.persist();
|
6250
6585
|
onKeyDown(event);
|
@@ -6252,6 +6587,10 @@ var useMultiListbox = function useMultiListbox(_ref, ref) {
|
|
6252
6587
|
};
|
6253
6588
|
|
6254
6589
|
var handleListboxFocus = function handleListboxFocus(event) {
|
6590
|
+
if (currentIndex === undefined && data.length) {
|
6591
|
+
setInputValueByIndex(0);
|
6592
|
+
}
|
6593
|
+
|
6255
6594
|
if (onFocus) {
|
6256
6595
|
event.persist();
|
6257
6596
|
onFocus(event);
|
@@ -6260,41 +6599,42 @@ var useMultiListbox = function useMultiListbox(_ref, ref) {
|
|
6260
6599
|
|
6261
6600
|
var handleInputChange = function handleInputChange(event) {
|
6262
6601
|
event.persist();
|
6263
|
-
setSelectedIndexes(getSelectedIndexesFromValue(data, event.target.value));
|
6264
6602
|
|
6265
6603
|
if (onChange) {
|
6266
|
-
var
|
6267
|
-
|
6268
|
-
|
6269
|
-
|
6604
|
+
var _item$path$split, _item$path;
|
6605
|
+
|
6606
|
+
var item = findByValue$1(data, event.target.value);
|
6607
|
+
event.detail = sanitizeItem(item);
|
6608
|
+
var indexes = (_item$path$split = item === null || item === void 0 ? void 0 : (_item$path = item.path) === null || _item$path === void 0 ? void 0 : _item$path.split('.')) !== null && _item$path$split !== void 0 ? _item$path$split : [];
|
6609
|
+
|
6610
|
+
if (indexes.length > 1) {
|
6611
|
+
// we don't want to map the current item
|
6612
|
+
indexes.pop(); // we need to rebuild the path as we map
|
6613
|
+
|
6614
|
+
var lastPath;
|
6615
|
+
event.detail.parents = indexes.map(function (i) {
|
6616
|
+
lastPath = lastPath ? [lastPath, i].join('.') : i;
|
6617
|
+
return sanitizeItem(data.find(function (i) {
|
6618
|
+
return i.path === lastPath;
|
6619
|
+
}));
|
6620
|
+
});
|
6621
|
+
}
|
6270
6622
|
|
6271
|
-
if (item) {
|
6272
|
-
detail.push(item);
|
6273
|
-
}
|
6274
|
-
});
|
6275
|
-
event.detail = detail;
|
6276
6623
|
onChange(event);
|
6277
6624
|
}
|
6278
6625
|
};
|
6279
6626
|
|
6280
6627
|
var list = _extends({}, otherProps, {
|
6281
6628
|
'aria-activedescendant': getActiveDescendant(data, currentIndex, id),
|
6282
|
-
'aria-multiselectable': true,
|
6283
6629
|
data: data,
|
6284
6630
|
disabled: disabled,
|
6285
6631
|
id: id,
|
6286
|
-
onChange:
|
6287
|
-
return null;
|
6288
|
-
},
|
6289
|
-
onClick: handleListboxClick,
|
6632
|
+
onChange: handleListboxChange,
|
6290
6633
|
onFocus: handleListboxFocus,
|
6291
6634
|
onKeyDown: handleListboxKeyDown,
|
6292
|
-
scrollOnFocus:
|
6635
|
+
scrollOnFocus: true,
|
6293
6636
|
tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,
|
6294
|
-
value: currentIndex
|
6295
|
-
selectedIndexes: selectedIndexes,
|
6296
|
-
multiselect: true,
|
6297
|
-
allOptionsSelected: allOptionsSelected
|
6637
|
+
value: currentIndex
|
6298
6638
|
});
|
6299
6639
|
|
6300
6640
|
var input = {
|
@@ -6302,7 +6642,7 @@ var useMultiListbox = function useMultiListbox(_ref, ref) {
|
|
6302
6642
|
onChange: handleInputChange,
|
6303
6643
|
ref: inputRef,
|
6304
6644
|
tabIndex: -1,
|
6305
|
-
value: value
|
6645
|
+
value: value === undefined || value === null ? '' : value
|
6306
6646
|
};
|
6307
6647
|
return {
|
6308
6648
|
list: list,
|
@@ -6310,549 +6650,266 @@ var useMultiListbox = function useMultiListbox(_ref, ref) {
|
|
6310
6650
|
};
|
6311
6651
|
};
|
6312
6652
|
|
6313
|
-
var _excluded$
|
6314
|
-
|
6315
|
-
var
|
6316
|
-
|
6317
|
-
|
6318
|
-
|
6319
|
-
|
6320
|
-
|
6321
|
-
|
6322
|
-
|
6323
|
-
|
6324
|
-
|
6325
|
-
|
6326
|
-
|
6327
|
-
}, React.createElement(ScrollableList, Object.assign({}, list, {
|
6328
|
-
style: _extends({}, list.style, {
|
6329
|
-
maxHeight: 'calc(12rem + 2px)'
|
6330
|
-
/* (6 * option height) + listbox border */
|
6331
|
-
|
6332
|
-
})
|
6333
|
-
})), React.createElement("input", Object.assign({}, input, {
|
6334
|
-
className: "hidden",
|
6335
|
-
type: "text"
|
6336
|
-
})));
|
6337
|
-
});
|
6338
|
-
var MultiListbox = /*#__PURE__*/React.forwardRef(function Listbox(props, ref) {
|
6339
|
-
var externalClassName = props.className,
|
6340
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded2$2);
|
6341
|
-
|
6342
|
-
var _useMultiListbox = useMultiListbox(otherProps, ref),
|
6343
|
-
list = _useMultiListbox.list,
|
6344
|
-
input = _useMultiListbox.input;
|
6345
|
-
|
6346
|
-
var className = cn('bg-white inline-flex relative w-full', externalClassName);
|
6347
|
-
return React.createElement("span", {
|
6348
|
-
"data-taco": "listbox",
|
6349
|
-
className: className
|
6350
|
-
}, React.createElement(ScrollableList, Object.assign({}, list, {
|
6351
|
-
style: _extends({}, list.style, {
|
6352
|
-
maxHeight: 'calc(12rem + 2px + 2px)'
|
6353
|
-
/* (6 * option height) + listbox border + ALL_OPTIONS bottom border */
|
6354
|
-
|
6355
|
-
})
|
6356
|
-
})), React.createElement("input", Object.assign({}, input, {
|
6357
|
-
className: "hidden",
|
6358
|
-
type: "text"
|
6359
|
-
})));
|
6360
|
-
});
|
6361
|
-
|
6362
|
-
var _excluded$v = ["children", "placement"];
|
6363
|
-
|
6364
|
-
var getAppearanceClasses$1 = function getAppearanceClasses(appearance) {
|
6365
|
-
switch (appearance) {
|
6366
|
-
case 'primary':
|
6367
|
-
return 'wcag-blue border-blue';
|
6368
|
-
|
6369
|
-
case 'danger':
|
6370
|
-
return 'wcag-red border-red';
|
6371
|
-
|
6372
|
-
case 'ghost':
|
6373
|
-
return 'bg-white text-blue border-blue yt-shadow-blue';
|
6374
|
-
|
6375
|
-
case 'discrete':
|
6376
|
-
return 'wcag-white border-grey yt-shadow';
|
6377
|
-
|
6378
|
-
case 'default':
|
6379
|
-
default:
|
6380
|
-
return 'wcag-grey-light border-grey';
|
6381
|
-
}
|
6382
|
-
};
|
6383
|
-
|
6384
|
-
var Content$4 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
6385
|
-
var internalRef = useProxiedRef(ref);
|
6386
|
-
var menu = useCurrentMenu();
|
6387
|
-
|
6388
|
-
var children = props.children,
|
6389
|
-
side = props.placement,
|
6390
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$v);
|
6391
|
-
|
6392
|
-
var className = cn('border rounded block outline-none p-1', getAppearanceClasses$1(menu === null || menu === void 0 ? void 0 : menu.appearance), props.className);
|
6393
|
-
return React.createElement(DropdownMenuPrimitive.Content, Object.assign({}, otherProps, {
|
6394
|
-
align: "start",
|
6395
|
-
className: className,
|
6396
|
-
"data-taco": "menu",
|
6397
|
-
side: side,
|
6398
|
-
sideOffset: 2,
|
6399
|
-
style: {
|
6400
|
-
minWidth: menu === null || menu === void 0 ? void 0 : menu.minWidth
|
6401
|
-
},
|
6402
|
-
ref: internalRef
|
6403
|
-
}), children);
|
6404
|
-
});
|
6405
|
-
|
6406
|
-
var _excluded$w = ["icon", "shortcut"];
|
6407
|
-
var Icon$1 = function Icon$1(_ref) {
|
6408
|
-
var name = _ref.name;
|
6409
|
-
return React.createElement("span", {
|
6410
|
-
className: "absolute left-0 ml-1"
|
6411
|
-
}, React.createElement(Icon, {
|
6412
|
-
className: "!h-5 !w-5 -ml-px -mt-px",
|
6413
|
-
name: name
|
6414
|
-
}));
|
6415
|
-
};
|
6416
|
-
|
6417
|
-
var getAppearanceClasses$2 = function getAppearanceClasses(appearance) {
|
6418
|
-
switch (appearance) {
|
6419
|
-
case 'primary':
|
6420
|
-
return 'wcag-blue aria-disabled:text-blue-dark focus:wcag-blue-light';
|
6421
|
-
|
6422
|
-
case 'danger':
|
6423
|
-
return 'wcag-red aria-disabled:text-red-dark focus:wcag-red-light';
|
6424
|
-
|
6425
|
-
case 'ghost':
|
6426
|
-
return 'text-blue aria-disabled:text-grey focus:wcag-blue';
|
6427
|
-
|
6428
|
-
case 'discrete':
|
6429
|
-
return 'text-black aria-disabled:text-grey focus:wcag-blue-lightest';
|
6430
|
-
|
6431
|
-
case 'default':
|
6432
|
-
default:
|
6433
|
-
return 'wcag-grey-light aria-disabled:text-grey-darker focus:wcag-grey-dark';
|
6434
|
-
}
|
6435
|
-
};
|
6436
|
-
|
6437
|
-
var useItemStyling = function useItemStyling(_ref2) {
|
6438
|
-
var disabled = _ref2.disabled,
|
6439
|
-
indented = _ref2.indented,
|
6440
|
-
className = _ref2.className;
|
6441
|
-
var menu = useCurrentMenu();
|
6442
|
-
React.useEffect(function () {
|
6443
|
-
if (indented && !(menu !== null && menu !== void 0 && menu.indented)) {
|
6444
|
-
menu === null || menu === void 0 ? void 0 : menu.registerIndentation();
|
6445
|
-
}
|
6446
|
-
}, [indented]);
|
6447
|
-
return cn('flex items-center justify-start h-7 pr-1.5 relative rounded w-full focus:outline-none group', getAppearanceClasses$2(menu === null || menu === void 0 ? void 0 : menu.appearance), {
|
6448
|
-
'pl-7': menu === null || menu === void 0 ? void 0 : menu.indented,
|
6449
|
-
'pl-1.5': !(menu !== null && menu !== void 0 && menu.indented),
|
6450
|
-
'cursor-pointer': !disabled,
|
6451
|
-
'cursor-not-allowed': disabled
|
6452
|
-
}, className);
|
6453
|
-
};
|
6454
|
-
var Shortcut = function Shortcut(props) {
|
6455
|
-
var menu = useCurrentMenu();
|
6456
|
-
var appearance;
|
6457
|
-
|
6458
|
-
switch (menu === null || menu === void 0 ? void 0 : menu.appearance) {
|
6459
|
-
case 'primary':
|
6460
|
-
appearance = 'text-blue-lightest group-focus:text-black';
|
6461
|
-
break;
|
6462
|
-
|
6463
|
-
case 'danger':
|
6464
|
-
appearance = 'text-red-lightest group-focus:text-white';
|
6465
|
-
break;
|
6466
|
-
|
6467
|
-
case 'ghost':
|
6468
|
-
appearance = 'text-blue-light group-focus:text-blue-lightest';
|
6469
|
-
break;
|
6470
|
-
|
6471
|
-
case 'discrete':
|
6472
|
-
appearance = 'text-grey-darker group-focus:text-blue-light';
|
6473
|
-
break;
|
6474
|
-
|
6475
|
-
case 'default':
|
6476
|
-
default:
|
6477
|
-
appearance = 'text-grey-darkest';
|
6478
|
-
break;
|
6479
|
-
}
|
6480
|
-
|
6481
|
-
var className = cn('ml-auto pl-3', appearance);
|
6482
|
-
return React.createElement("span", Object.assign({}, props, {
|
6483
|
-
className: className
|
6484
|
-
}));
|
6485
|
-
};
|
6486
|
-
var Item$1 = /*#__PURE__*/React.forwardRef(function MenuItem(props, ref) {
|
6487
|
-
var icon = props.icon,
|
6488
|
-
shortcut = props.shortcut,
|
6489
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$w);
|
6490
|
-
|
6491
|
-
var className = useItemStyling({
|
6492
|
-
disabled: props.disabled,
|
6493
|
-
indented: !!icon,
|
6494
|
-
className: props.className
|
6495
|
-
});
|
6496
|
-
var handleClick; // radix has a bug that does not disable clicks when disabled is set on items
|
6653
|
+
var _excluded$z = ["data", "defaultValue", "disabled", "id", "name", "onClick", "onChange", "onFocus", "onKeyDown", "value"];
|
6654
|
+
var useMultiListbox = function useMultiListbox(_ref, ref) {
|
6655
|
+
var _ref$data = _ref.data,
|
6656
|
+
externalData = _ref$data === void 0 ? [] : _ref$data,
|
6657
|
+
defaultValue = _ref.defaultValue,
|
6658
|
+
disabled = _ref.disabled,
|
6659
|
+
nativeId = _ref.id,
|
6660
|
+
name = _ref.name,
|
6661
|
+
onClick = _ref.onClick,
|
6662
|
+
onChange = _ref.onChange,
|
6663
|
+
onFocus = _ref.onFocus,
|
6664
|
+
onKeyDown = _ref.onKeyDown,
|
6665
|
+
value = _ref.value,
|
6666
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$z);
|
6497
6667
|
|
6498
|
-
|
6499
|
-
|
6668
|
+
var _useLocalization = useLocalization(),
|
6669
|
+
texts = _useLocalization.texts;
|
6500
6670
|
|
6501
|
-
|
6502
|
-
|
6503
|
-
|
6504
|
-
|
6505
|
-
|
6506
|
-
|
6507
|
-
|
6508
|
-
|
6509
|
-
}
|
6510
|
-
}
|
6671
|
+
var id = React.useMemo(function () {
|
6672
|
+
return nativeId || uuid.v4();
|
6673
|
+
}, [nativeId]);
|
6674
|
+
var inputRef = useProxiedRef(ref);
|
6675
|
+
var data = React.useMemo(function () {
|
6676
|
+
return [{
|
6677
|
+
text: texts.listbox.allOption,
|
6678
|
+
value: '#ALL-OPTIONS#'
|
6679
|
+
}].concat(externalData);
|
6680
|
+
}, [externalData]);
|
6511
6681
|
|
6512
|
-
|
6513
|
-
|
6514
|
-
|
6515
|
-
ref: ref
|
6516
|
-
}), icon && React.createElement(Icon$1, {
|
6517
|
-
name: icon
|
6518
|
-
}), props.children, shortcut && React.createElement(Shortcut, null, shortcut));
|
6519
|
-
});
|
6682
|
+
var _React$useState = React.useState(getIndexFromValue(data, value) || 0),
|
6683
|
+
currentIndex = _React$useState[0],
|
6684
|
+
setCurrentIndex = _React$useState[1];
|
6520
6685
|
|
6521
|
-
var
|
6522
|
-
|
6523
|
-
|
6524
|
-
icon = props.icon,
|
6525
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$x);
|
6686
|
+
var _React$useState2 = React.useState(false),
|
6687
|
+
allOptionsSelected = _React$useState2[0],
|
6688
|
+
setAllOptionsSelected = _React$useState2[1];
|
6526
6689
|
|
6527
|
-
var
|
6528
|
-
|
6529
|
-
|
6530
|
-
|
6531
|
-
|
6532
|
-
return React.createElement(DropdownMenuPrimitive.Item, Object.assign({}, otherProps, {
|
6533
|
-
asChild: true,
|
6534
|
-
className: className,
|
6535
|
-
ref: ref
|
6536
|
-
}), React.createElement("a", {
|
6537
|
-
href: href,
|
6538
|
-
target: "_blank"
|
6539
|
-
}, icon && React.createElement(Icon$1, {
|
6540
|
-
name: icon
|
6541
|
-
}), props.children));
|
6542
|
-
});
|
6690
|
+
var _useTypeahead = useTypeahead({
|
6691
|
+
data: data,
|
6692
|
+
currentIndex: currentIndex
|
6693
|
+
}),
|
6694
|
+
getNextIndex = _useTypeahead.getNextIndex;
|
6543
6695
|
|
6544
|
-
var
|
6545
|
-
|
6696
|
+
var _React$useState3 = React.useState(getSelectedIndexesFromValue(data, value)),
|
6697
|
+
selectedIndexes = _React$useState3[0],
|
6698
|
+
setSelectedIndexes = _React$useState3[1];
|
6546
6699
|
|
6547
|
-
var menu = useCurrentMenu();
|
6548
|
-
var internalRef = useProxiedRef(ref);
|
6549
6700
|
React.useEffect(function () {
|
6550
|
-
if (
|
6551
|
-
|
6701
|
+
if (defaultValue && !value) {
|
6702
|
+
setInputValueByRef$1(inputRef.current, defaultValue.toString());
|
6552
6703
|
}
|
6553
|
-
}, [
|
6554
|
-
|
6704
|
+
}, []);
|
6555
6705
|
React.useEffect(function () {
|
6556
|
-
var
|
6557
|
-
|
6558
|
-
|
6559
|
-
var _props$children2, _props$children2$prop;
|
6706
|
+
var selectableItemsCount = data.filter(function (item) {
|
6707
|
+
return !item.disabled;
|
6708
|
+
}).length - 1;
|
6560
6709
|
|
6561
|
-
|
6710
|
+
if (selectableItemsCount === selectedIndexes.length) {
|
6711
|
+
setAllOptionsSelected(true);
|
6712
|
+
} else {
|
6713
|
+
setAllOptionsSelected(false);
|
6562
6714
|
}
|
6563
|
-
}, [
|
6564
|
-
return React.createElement(DropdownMenuPrimitive.Trigger, Object.assign({}, props, {
|
6565
|
-
asChild: true,
|
6566
|
-
ref: internalRef
|
6567
|
-
}));
|
6568
|
-
});
|
6569
|
-
|
6570
|
-
var _excluded$y = ["checked", "children", "onChange"];
|
6571
|
-
var Checkbox$1 = function Checkbox(props) {
|
6572
|
-
var checked = props.checked,
|
6573
|
-
children = props.children,
|
6574
|
-
onChange = props.onChange,
|
6575
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded$y);
|
6715
|
+
}, [selectedIndexes, data]);
|
6576
6716
|
|
6577
|
-
var
|
6578
|
-
|
6579
|
-
|
6580
|
-
className: props.className
|
6581
|
-
});
|
6582
|
-
return React.createElement(DropdownMenuPrimitive.CheckboxItem, Object.assign({}, otherProps, {
|
6583
|
-
className: className,
|
6584
|
-
checked: checked,
|
6585
|
-
onCheckedChange: onChange
|
6586
|
-
}), React.createElement(DropdownMenuPrimitive.ItemIndicator, {
|
6587
|
-
className: "absolute left-0 ml-1.5"
|
6588
|
-
}, React.createElement(Icon, {
|
6589
|
-
name: "tick",
|
6590
|
-
className: "!h-4 !w-4 -ml-px"
|
6591
|
-
})), children);
|
6592
|
-
};
|
6717
|
+
var setInputValueByIndex = function setInputValueByIndex(index) {
|
6718
|
+
if (index !== undefined) {
|
6719
|
+
var option = data[index];
|
6593
6720
|
|
6594
|
-
|
6595
|
-
|
6596
|
-
var getRadioGroupItemValueAsString = function getRadioGroupItemValueAsString(value) {
|
6597
|
-
return value === null ? '' : String(value);
|
6598
|
-
};
|
6599
|
-
var findByValue$1 = function findByValue(values, valueAsString) {
|
6600
|
-
return values.find(function (value) {
|
6601
|
-
return getRadioGroupItemValueAsString(value) === valueAsString;
|
6602
|
-
});
|
6603
|
-
};
|
6604
|
-
var RadioGroupContext = /*#__PURE__*/React.createContext({
|
6605
|
-
disabled: false,
|
6606
|
-
invalid: false
|
6607
|
-
});
|
6608
|
-
var RadioGroupItem = /*#__PURE__*/React.forwardRef(function RadioGroupItem(props, ref) {
|
6609
|
-
var context = React.useContext(RadioGroupContext);
|
6721
|
+
if (option && !option.disabled) {
|
6722
|
+
var _inputRef$current;
|
6610
6723
|
|
6611
|
-
|
6612
|
-
|
6613
|
-
|
6724
|
+
var newInputValue = '';
|
6725
|
+
var currentInputValue = (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value;
|
6726
|
+
var currentValuesArray = (currentInputValue === null || currentInputValue === void 0 ? void 0 : currentInputValue.split(',')) || [];
|
6727
|
+
var optionAlreadySelected = currentValuesArray.findIndex(function (val) {
|
6728
|
+
return val === String(option.value);
|
6729
|
+
}) !== -1; // Handling the select_all option
|
6614
6730
|
|
6615
|
-
|
6616
|
-
|
6617
|
-
|
6618
|
-
|
6619
|
-
|
6620
|
-
|
6621
|
-
|
6622
|
-
|
6623
|
-
|
6624
|
-
|
6625
|
-
|
6626
|
-
|
6627
|
-
|
6628
|
-
|
6629
|
-
|
6630
|
-
|
6631
|
-
|
6632
|
-
|
6633
|
-
|
6634
|
-
}
|
6635
|
-
var useRadioGroup = function useRadioGroup(props) {
|
6636
|
-
var children = props.children,
|
6637
|
-
defaultValue = props.defaultValue,
|
6638
|
-
disabled = props.disabled,
|
6639
|
-
invalid = props.invalid,
|
6640
|
-
onChange = props.onChange,
|
6641
|
-
_props$orientation = props.orientation,
|
6642
|
-
orientation = _props$orientation === void 0 ? 'vertical' : _props$orientation,
|
6643
|
-
value = props.value,
|
6644
|
-
otherProps = _objectWithoutPropertiesLoose(props, _excluded2$3);
|
6731
|
+
if (option.value === '#ALL-OPTIONS#') {
|
6732
|
+
if (!allOptionsSelected) {
|
6733
|
+
newInputValue = data.filter(function (option, index) {
|
6734
|
+
return index !== 0 && !option.disabled;
|
6735
|
+
}).map(function (option) {
|
6736
|
+
return option.value;
|
6737
|
+
}).join(',');
|
6738
|
+
} else {
|
6739
|
+
newInputValue = '';
|
6740
|
+
}
|
6741
|
+
} else {
|
6742
|
+
// Handling rest options
|
6743
|
+
if (optionAlreadySelected) {
|
6744
|
+
newInputValue = currentValuesArray.filter(function (val) {
|
6745
|
+
return val !== String(option.value);
|
6746
|
+
}).join(',');
|
6747
|
+
} else {
|
6748
|
+
newInputValue = currentInputValue ? currentInputValue + "," + option.value : option.value;
|
6749
|
+
}
|
6750
|
+
}
|
6645
6751
|
|
6646
|
-
|
6647
|
-
var radioGroupItemValues = [];
|
6648
|
-
React.Children.forEach(children, function (child) {
|
6649
|
-
if (React.isValidElement(child)) {
|
6650
|
-
radioGroupItemValues.push(child.props.value);
|
6752
|
+
setInputValueByRef$1(inputRef.current, newInputValue);
|
6651
6753
|
}
|
6652
|
-
}
|
6653
|
-
|
6654
|
-
}, [children]);
|
6655
|
-
var context = React.useMemo(function () {
|
6656
|
-
return {
|
6657
|
-
disabled: disabled !== null && disabled !== void 0 ? disabled : false,
|
6658
|
-
invalid: invalid !== null && invalid !== void 0 ? invalid : false
|
6659
|
-
};
|
6660
|
-
}, [disabled, invalid]);
|
6661
|
-
var valueProps;
|
6662
|
-
|
6663
|
-
if (onChange !== undefined) {
|
6664
|
-
var handleChange = function handleChange(value) {
|
6665
|
-
return onChange(findByValue$1(values, value));
|
6666
|
-
};
|
6667
|
-
|
6668
|
-
valueProps = {
|
6669
|
-
onValueChange: handleChange,
|
6670
|
-
value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined
|
6671
|
-
};
|
6672
|
-
} else {
|
6673
|
-
valueProps = {
|
6674
|
-
defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined
|
6675
|
-
};
|
6676
|
-
}
|
6677
|
-
|
6678
|
-
return {
|
6679
|
-
context: context,
|
6680
|
-
props: _extends({}, otherProps, valueProps, {
|
6681
|
-
children: children,
|
6682
|
-
orientation: orientation
|
6683
|
-
})
|
6684
|
-
};
|
6685
|
-
};
|
6686
|
-
var RadioGroup = /*#__PURE__*/React.forwardRef(function RadioGroup(props, ref) {
|
6687
|
-
var _useRadioGroup = useRadioGroup(props),
|
6688
|
-
context = _useRadioGroup.context,
|
6689
|
-
otherProps = _useRadioGroup.props;
|
6690
|
-
|
6691
|
-
var className = cn('flex items-start', {
|
6692
|
-
'flex-wrap space-x-4': otherProps.orientation === 'horizontal',
|
6693
|
-
'flex-col space-y-2': otherProps.orientation === 'vertical'
|
6694
|
-
}, otherProps.className);
|
6695
|
-
return React.createElement(RadioGroupContext.Provider, {
|
6696
|
-
value: context
|
6697
|
-
}, React.createElement(RadioGroupPrimitive.Root, Object.assign({}, otherProps, {
|
6698
|
-
className: className,
|
6699
|
-
"data-taco": "radio-group",
|
6700
|
-
ref: ref
|
6701
|
-
})));
|
6702
|
-
});
|
6703
|
-
RadioGroup.Item = RadioGroupItem;
|
6754
|
+
}
|
6755
|
+
};
|
6704
6756
|
|
6705
|
-
var
|
6706
|
-
|
6707
|
-
var context = React.useContext(MenuRadioGroupContext);
|
6757
|
+
var handleListboxClick = function handleListboxClick(event, index) {
|
6758
|
+
event.preventDefault();
|
6708
6759
|
|
6709
|
-
|
6710
|
-
|
6711
|
-
|
6760
|
+
if (!data[index].disabled) {
|
6761
|
+
setCurrentIndex(index);
|
6762
|
+
setInputValueByIndex(index);
|
6763
|
+
}
|
6712
6764
|
|
6713
|
-
|
6714
|
-
|
6715
|
-
|
6716
|
-
|
6717
|
-
className: props.className
|
6718
|
-
});
|
6719
|
-
return React.createElement(DropdownMenuPrimitive.RadioItem, Object.assign({}, otherProps, {
|
6720
|
-
className: className,
|
6721
|
-
disabled: disabled,
|
6722
|
-
value: getRadioGroupItemValueAsString(value)
|
6723
|
-
}), React.createElement(DropdownMenuPrimitive.ItemIndicator, {
|
6724
|
-
className: "absolute left-0 ml-1.5"
|
6725
|
-
}, React.createElement("span", {
|
6726
|
-
className: "flex h-1.5 w-1.5 ml-1 rounded-full bg-current "
|
6727
|
-
})), children);
|
6728
|
-
};
|
6729
|
-
var MenuRadioGroupContext = /*#__PURE__*/React.createContext({
|
6730
|
-
disabled: false
|
6731
|
-
});
|
6732
|
-
var RadioGroup$1 = function RadioGroup(props) {
|
6733
|
-
var _useRadioGroup = useRadioGroup(props),
|
6734
|
-
context = _useRadioGroup.context,
|
6735
|
-
otherProps = _useRadioGroup.props;
|
6765
|
+
if (onClick) {
|
6766
|
+
onClick(event);
|
6767
|
+
}
|
6768
|
+
};
|
6736
6769
|
|
6737
|
-
var
|
6738
|
-
|
6739
|
-
value: context
|
6740
|
-
}, React.createElement(DropdownMenuPrimitive.RadioGroup, Object.assign({}, otherProps, {
|
6741
|
-
className: className
|
6742
|
-
})));
|
6743
|
-
};
|
6744
|
-
RadioGroup$1.Item = RadioItem;
|
6770
|
+
var handleListboxKeyDown = function handleListboxKeyDown(event, index) {
|
6771
|
+
var charKey = String.fromCharCode(event.keyCode);
|
6745
6772
|
|
6746
|
-
|
6747
|
-
|
6748
|
-
case 'primary':
|
6749
|
-
return 'bg-blue-lighe';
|
6773
|
+
if (charKey.match(/(\w)/g)) {
|
6774
|
+
var nextIndex = getNextIndex(charKey);
|
6750
6775
|
|
6751
|
-
|
6752
|
-
|
6776
|
+
if (nextIndex > -1 && nextIndex !== currentIndex) {
|
6777
|
+
setCurrentIndex(nextIndex);
|
6778
|
+
}
|
6753
6779
|
|
6754
|
-
|
6755
|
-
|
6780
|
+
return;
|
6781
|
+
}
|
6756
6782
|
|
6757
|
-
|
6758
|
-
|
6783
|
+
switch (event.keyCode) {
|
6784
|
+
case keycode('space'):
|
6785
|
+
{
|
6786
|
+
event.preventDefault();
|
6787
|
+
setInputValueByIndex(index);
|
6788
|
+
break;
|
6789
|
+
}
|
6759
6790
|
|
6760
|
-
|
6761
|
-
|
6762
|
-
|
6763
|
-
|
6764
|
-
}
|
6791
|
+
case keycode('enter'):
|
6792
|
+
{
|
6793
|
+
setInputValueByIndex(index);
|
6794
|
+
break;
|
6795
|
+
}
|
6796
|
+
}
|
6765
6797
|
|
6766
|
-
|
6767
|
-
var menu = useCurrentMenu();
|
6768
|
-
var className = cn('h-px my-1', getAppearanceClasses$3(menu === null || menu === void 0 ? void 0 : menu.appearance));
|
6769
|
-
return React.createElement(DropdownMenuPrimitive.Separator, {
|
6770
|
-
className: className
|
6771
|
-
});
|
6772
|
-
};
|
6798
|
+
setCurrentIndex(index);
|
6773
6799
|
|
6774
|
-
|
6775
|
-
|
6776
|
-
|
6777
|
-
|
6800
|
+
if (onKeyDown) {
|
6801
|
+
event.persist();
|
6802
|
+
onKeyDown(event);
|
6803
|
+
}
|
6804
|
+
};
|
6778
6805
|
|
6779
|
-
|
6780
|
-
|
6806
|
+
var handleListboxFocus = function handleListboxFocus(event) {
|
6807
|
+
if (onFocus) {
|
6808
|
+
event.persist();
|
6809
|
+
onFocus(event);
|
6810
|
+
}
|
6811
|
+
};
|
6781
6812
|
|
6782
|
-
|
6783
|
-
|
6813
|
+
var handleInputChange = function handleInputChange(event) {
|
6814
|
+
event.persist();
|
6815
|
+
setSelectedIndexes(getSelectedIndexesFromValue(data, event.target.value));
|
6784
6816
|
|
6785
|
-
|
6786
|
-
|
6817
|
+
if (onChange) {
|
6818
|
+
var detail = [];
|
6819
|
+
var valuesArray = event.target.value.split(',');
|
6820
|
+
valuesArray.forEach(function (val) {
|
6821
|
+
var item = findByValue$1(data, val);
|
6787
6822
|
|
6788
|
-
|
6789
|
-
|
6790
|
-
|
6791
|
-
|
6792
|
-
|
6823
|
+
if (item) {
|
6824
|
+
detail.push(item);
|
6825
|
+
}
|
6826
|
+
});
|
6827
|
+
event.detail = detail;
|
6828
|
+
onChange(event);
|
6829
|
+
}
|
6830
|
+
};
|
6793
6831
|
|
6794
|
-
var
|
6795
|
-
|
6796
|
-
|
6797
|
-
|
6798
|
-
|
6799
|
-
|
6800
|
-
|
6801
|
-
|
6802
|
-
|
6832
|
+
var list = _extends({}, otherProps, {
|
6833
|
+
'aria-activedescendant': getActiveDescendant(data, currentIndex, id),
|
6834
|
+
'aria-multiselectable': true,
|
6835
|
+
data: data,
|
6836
|
+
disabled: disabled,
|
6837
|
+
id: id,
|
6838
|
+
onChange: function onChange() {
|
6839
|
+
return null;
|
6840
|
+
},
|
6841
|
+
onClick: handleListboxClick,
|
6842
|
+
onFocus: handleListboxFocus,
|
6843
|
+
onKeyDown: handleListboxKeyDown,
|
6844
|
+
scrollOnFocus: false,
|
6845
|
+
tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,
|
6846
|
+
value: currentIndex,
|
6847
|
+
selectedIndexes: selectedIndexes,
|
6848
|
+
multiselect: true,
|
6849
|
+
allOptionsSelected: allOptionsSelected
|
6850
|
+
});
|
6851
|
+
|
6852
|
+
var input = {
|
6853
|
+
name: name,
|
6854
|
+
onChange: handleInputChange,
|
6855
|
+
ref: inputRef,
|
6856
|
+
tabIndex: -1,
|
6857
|
+
value: value !== null && value !== void 0 ? value : ''
|
6858
|
+
};
|
6859
|
+
return {
|
6860
|
+
list: list,
|
6861
|
+
input: input
|
6862
|
+
};
|
6803
6863
|
};
|
6804
6864
|
|
6805
|
-
var
|
6806
|
-
|
6807
|
-
|
6808
|
-
|
6865
|
+
var _excluded$A = ["className"],
|
6866
|
+
_excluded2$3 = ["className"];
|
6867
|
+
var Listbox = /*#__PURE__*/React.forwardRef(function Listbox(props, ref) {
|
6868
|
+
var externalClassName = props.className,
|
6869
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$A);
|
6809
6870
|
|
6810
|
-
var
|
6811
|
-
|
6812
|
-
|
6871
|
+
var _useListbox = useListbox(otherProps, ref),
|
6872
|
+
list = _useListbox.list,
|
6873
|
+
input = _useListbox.input;
|
6813
6874
|
|
6814
|
-
var
|
6815
|
-
|
6816
|
-
|
6875
|
+
var className = cn('bg-white inline-flex relative w-full', externalClassName);
|
6876
|
+
return React.createElement("span", {
|
6877
|
+
"data-taco": "listbox",
|
6878
|
+
className: className
|
6879
|
+
}, React.createElement(ScrollableList, Object.assign({}, list, {
|
6880
|
+
style: _extends({}, list.style, {
|
6881
|
+
maxHeight: 'calc(12rem + 2px)'
|
6882
|
+
/* (6 * option height) + listbox border */
|
6817
6883
|
|
6818
|
-
|
6819
|
-
|
6820
|
-
|
6884
|
+
})
|
6885
|
+
})), React.createElement("input", Object.assign({}, input, {
|
6886
|
+
className: "hidden",
|
6887
|
+
type: "text"
|
6888
|
+
})));
|
6889
|
+
});
|
6890
|
+
var MultiListbox = /*#__PURE__*/React.forwardRef(function Listbox(props, ref) {
|
6891
|
+
var externalClassName = props.className,
|
6892
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded2$3);
|
6821
6893
|
|
6822
|
-
var
|
6823
|
-
|
6824
|
-
|
6825
|
-
|
6826
|
-
|
6827
|
-
|
6828
|
-
|
6829
|
-
|
6830
|
-
|
6831
|
-
|
6832
|
-
|
6833
|
-
|
6834
|
-
|
6835
|
-
|
6836
|
-
|
6837
|
-
|
6838
|
-
|
6839
|
-
};
|
6840
|
-
}, [indented, minWidth, appearance]);
|
6841
|
-
return React.createElement(MenuContext.Provider, {
|
6842
|
-
value: context
|
6843
|
-
}, React.createElement(DropdownMenuPrimitive.Root, Object.assign({}, props, {
|
6844
|
-
open: open,
|
6845
|
-
onOpenChange: setOpen
|
6894
|
+
var _useMultiListbox = useMultiListbox(otherProps, ref),
|
6895
|
+
list = _useMultiListbox.list,
|
6896
|
+
input = _useMultiListbox.input;
|
6897
|
+
|
6898
|
+
var className = cn('bg-white inline-flex relative w-full', externalClassName);
|
6899
|
+
return React.createElement("span", {
|
6900
|
+
"data-taco": "listbox",
|
6901
|
+
className: className
|
6902
|
+
}, React.createElement(ScrollableList, Object.assign({}, list, {
|
6903
|
+
style: _extends({}, list.style, {
|
6904
|
+
maxHeight: 'calc(12rem + 2px + 2px)'
|
6905
|
+
/* (6 * option height) + listbox border + ALL_OPTIONS bottom border */
|
6906
|
+
|
6907
|
+
})
|
6908
|
+
})), React.createElement("input", Object.assign({}, input, {
|
6909
|
+
className: "hidden",
|
6910
|
+
type: "text"
|
6846
6911
|
})));
|
6847
|
-
};
|
6848
|
-
Menu.Trigger = Trigger$3;
|
6849
|
-
Menu.Content = Content$4;
|
6850
|
-
Menu.Item = Item$1;
|
6851
|
-
Menu.Link = Link;
|
6852
|
-
Menu.Checkbox = Checkbox$1;
|
6853
|
-
Menu.Separator = Separator;
|
6854
|
-
Menu.Header = Header;
|
6855
|
-
Menu.RadioGroup = RadioGroup$1;
|
6912
|
+
});
|
6856
6913
|
|
6857
6914
|
var _excluded$B = ["children", "className", "expanded", "title", "fixed", "onClick"];
|
6858
6915
|
var TreeviewItem = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
@@ -7252,11 +7309,11 @@ var useSelect = function useSelect(_ref, ref) {
|
|
7252
7309
|
} else {
|
7253
7310
|
var _findByValue$text, _findByValue;
|
7254
7311
|
|
7255
|
-
text = (_findByValue$text = (_findByValue = findByValue(searchData, selectedValues[0])) === null || _findByValue === void 0 ? void 0 : _findByValue.text) !== null && _findByValue$text !== void 0 ? _findByValue$text : '';
|
7312
|
+
text = (_findByValue$text = (_findByValue = findByValue$1(searchData, selectedValues[0])) === null || _findByValue === void 0 ? void 0 : _findByValue.text) !== null && _findByValue$text !== void 0 ? _findByValue$text : '';
|
7256
7313
|
more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;
|
7257
7314
|
}
|
7258
7315
|
} else {
|
7259
|
-
var item = findByValue(searchData, value);
|
7316
|
+
var item = findByValue$1(searchData, value);
|
7260
7317
|
|
7261
7318
|
if (item) {
|
7262
7319
|
text = item.icon ? React.createElement(React.Fragment, null, React.cloneElement(item.icon, {
|
@@ -7272,7 +7329,7 @@ var useSelect = function useSelect(_ref, ref) {
|
|
7272
7329
|
if (onChange) {
|
7273
7330
|
var _item$path$split, _item$path;
|
7274
7331
|
|
7275
|
-
var _item = findByValue(searchData, event.target.value);
|
7332
|
+
var _item = findByValue$1(searchData, event.target.value);
|
7276
7333
|
|
7277
7334
|
event.detail = sanitizeItem(_item);
|
7278
7335
|
var indexes = (_item$path$split = _item === null || _item === void 0 ? void 0 : (_item$path = _item.path) === null || _item$path === void 0 ? void 0 : _item$path.split('.')) !== null && _item$path$split !== void 0 ? _item$path$split : [];
|
@@ -8226,7 +8283,7 @@ var useRowSelect = function useRowSelect(onSelectedRows) {
|
|
8226
8283
|
}
|
8227
8284
|
};
|
8228
8285
|
|
8229
|
-
return React__default.createElement(Checkbox, Object.assign({}, props, {
|
8286
|
+
return React__default.createElement(Checkbox$1, Object.assign({}, props, {
|
8230
8287
|
onChange: onChange,
|
8231
8288
|
className: "mt-px"
|
8232
8289
|
}));
|
@@ -8259,7 +8316,7 @@ var useRowSelect = function useRowSelect(onSelectedRows) {
|
|
8259
8316
|
lastSelectedSortedIndex.current = sortedIndex;
|
8260
8317
|
};
|
8261
8318
|
|
8262
|
-
return React__default.createElement(Checkbox, Object.assign({}, props, {
|
8319
|
+
return React__default.createElement(Checkbox$1, Object.assign({}, props, {
|
8263
8320
|
className: "mt-px",
|
8264
8321
|
onClick: onClick,
|
8265
8322
|
// this is necessary to remove console spam from eslint
|
@@ -8604,6 +8661,8 @@ var useTableSortingListener = function useTableSortingListener(data, sortedRows,
|
|
8604
8661
|
|
8605
8662
|
var DEFAULT_PAGE_SIZE = 10;
|
8606
8663
|
var useTable = function useTable(props, ref) {
|
8664
|
+
var _otherProps$tabIndex;
|
8665
|
+
|
8607
8666
|
var children = props.children,
|
8608
8667
|
data = props.data,
|
8609
8668
|
onRowClick = props.onRowClick,
|
@@ -8736,7 +8795,8 @@ var useTable = function useTable(props, ref) {
|
|
8736
8795
|
tableProps: _extends({}, otherProps, {
|
8737
8796
|
headerGroups: headerGroups,
|
8738
8797
|
onFocus: handleFocus,
|
8739
|
-
onKeyDown: handleKeyDown
|
8798
|
+
onKeyDown: handleKeyDown,
|
8799
|
+
tabIndex: (_otherProps$tabIndex = otherProps.tabIndex) !== null && _otherProps$tabIndex !== void 0 ? _otherProps$tabIndex : 0
|
8740
8800
|
}),
|
8741
8801
|
state: state,
|
8742
8802
|
pagination: !disablePagination ? {
|
@@ -8965,8 +9025,7 @@ var Table = /*#__PURE__*/React__default.forwardRef(function Table(props, ref) {
|
|
8965
9025
|
}
|
8966
9026
|
|
8967
9027
|
return React__default.createElement(React__default.Fragment, null, paginationElement, React__default.createElement(BaseTable, Object.assign({}, tableProps, {
|
8968
|
-
ref: tableRef
|
8969
|
-
tabIndex: 0
|
9028
|
+
ref: tableRef
|
8970
9029
|
}), rows.length ? rows.map(function (row, index) {
|
8971
9030
|
prepareRow(row, index);
|
8972
9031
|
return React__default.createElement(Row, Object.assign({}, rowProps, {
|
@@ -9178,7 +9237,6 @@ var WindowedTable = /*#__PURE__*/React__default.forwardRef(function WindowedTabl
|
|
9178
9237
|
return React__default.createElement(BaseTable, Object.assign({}, tableProps, {
|
9179
9238
|
className: className,
|
9180
9239
|
headerRef: headerRef,
|
9181
|
-
tabIndex: 0,
|
9182
9240
|
ref: tableRef
|
9183
9241
|
}), list ? list : emptyStateRenderer());
|
9184
9242
|
});
|
@@ -9647,7 +9705,7 @@ exports.Badge = Badge;
|
|
9647
9705
|
exports.Banner = Banner;
|
9648
9706
|
exports.Button = Button$1;
|
9649
9707
|
exports.Calendar = Calendar$1;
|
9650
|
-
exports.Checkbox = Checkbox;
|
9708
|
+
exports.Checkbox = Checkbox$1;
|
9651
9709
|
exports.Combobox = Combobox;
|
9652
9710
|
exports.Datepicker = Datepicker;
|
9653
9711
|
exports.Dialog = Dialog;
|
@@ -9684,7 +9742,7 @@ exports.VisuallyHidden = VisuallyHidden;
|
|
9684
9742
|
exports.WindowedTable = WindowedTable;
|
9685
9743
|
exports.convertRowIndexPathToNumberArray = convertRowIndexPathToNumberArray;
|
9686
9744
|
exports.defaultLocalisationTexts = defaultLocalisationTexts;
|
9687
|
-
exports.findByValue = findByValue
|
9745
|
+
exports.findByValue = findByValue;
|
9688
9746
|
exports.format = format;
|
9689
9747
|
exports.getByRowIndexPath = getByRowIndexPath;
|
9690
9748
|
exports.getNextIndexFromKeycode = getNextIndexFromKeycode;
|