@dreamtree-org/twreact-ui 1.1.2 → 1.1.4
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/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +298 -62
- package/dist/index.js +297 -60
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { forwardRef, createElement, useId, useRef, useState, useEffect, useImperativeHandle, useMemo,
|
|
2
|
+
import React__default, { forwardRef, createElement, useId, useRef, useState, useEffect, useImperativeHandle, useMemo, useLayoutEffect, useCallback, createContext, useContext, cloneElement, PureComponent } from 'react';
|
|
3
3
|
import ReactDOM, { createPortal } from 'react-dom';
|
|
4
4
|
|
|
5
5
|
function _extends() {
|
|
@@ -3346,8 +3346,8 @@ function _defineProperty$4(e, r, t) {
|
|
|
3346
3346
|
}
|
|
3347
3347
|
|
|
3348
3348
|
var _excluded$l = ["options", "value", "onChange", "placeholder", "label", "error", "disabled", "required", "multiSelect", "searchable", "grouped", "onMenuItemRender", "className", "allowClear", "creatable", "onCreateOption", "onSearch", "loading", "selectAllOption", "closeOnSelect", "maxTagCount", "renderGroupLabel", "name"];
|
|
3349
|
-
function ownKeys$
|
|
3350
|
-
function _objectSpread$
|
|
3349
|
+
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3350
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3351
3351
|
|
|
3352
3352
|
/**
|
|
3353
3353
|
* Enhanced Select component (debounce removed)
|
|
@@ -3370,7 +3370,7 @@ var flattenGroups = function flattenGroups() {
|
|
|
3370
3370
|
return groups.reduce(function (acc, g) {
|
|
3371
3371
|
var groupLabel = g.label;
|
|
3372
3372
|
g.options.forEach(function (opt) {
|
|
3373
|
-
return acc.push(_objectSpread$
|
|
3373
|
+
return acc.push(_objectSpread$a(_objectSpread$a({}, opt), {}, {
|
|
3374
3374
|
_group: groupLabel
|
|
3375
3375
|
}));
|
|
3376
3376
|
});
|
|
@@ -3460,7 +3460,7 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
|
|
|
3460
3460
|
var flatOptions = useMemo(function () {
|
|
3461
3461
|
if (grouped) return flattenGroups(options);
|
|
3462
3462
|
return options.map(function (opt) {
|
|
3463
|
-
return _objectSpread$
|
|
3463
|
+
return _objectSpread$a({}, opt);
|
|
3464
3464
|
});
|
|
3465
3465
|
}, [options, grouped]);
|
|
3466
3466
|
var selectedValues = multiSelect ? Array.isArray(value) ? value : [] : value;
|
|
@@ -3487,7 +3487,7 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
|
|
|
3487
3487
|
}
|
|
3488
3488
|
if (grouped) {
|
|
3489
3489
|
return options.map(function (g) {
|
|
3490
|
-
return _objectSpread$
|
|
3490
|
+
return _objectSpread$a(_objectSpread$a({}, g), {}, {
|
|
3491
3491
|
options: g.options.filter(function (o) {
|
|
3492
3492
|
return o.label.toLowerCase().includes(searchTerm.toLowerCase());
|
|
3493
3493
|
})
|
|
@@ -3714,7 +3714,7 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
|
|
|
3714
3714
|
className: "text-xs border border-slate-200 p-0.5 rounded-md cursor-pointer hover:bg-gray-100",
|
|
3715
3715
|
onClick: function onClick() {
|
|
3716
3716
|
return setCollapsedGroups(function (prev) {
|
|
3717
|
-
return _objectSpread$
|
|
3717
|
+
return _objectSpread$a(_objectSpread$a({}, prev), {}, _defineProperty$4({}, group.label, !prev[group.label]));
|
|
3718
3718
|
});
|
|
3719
3719
|
}
|
|
3720
3720
|
}, /*#__PURE__*/React__default.createElement(ChevronDown, {
|
|
@@ -4185,78 +4185,137 @@ function MobileFilters(_ref) {
|
|
|
4185
4185
|
})));
|
|
4186
4186
|
}
|
|
4187
4187
|
|
|
4188
|
-
function
|
|
4189
|
-
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4190
|
-
|
|
4191
|
-
/**
|
|
4192
|
-
* Action menu dropdown component for table row actions
|
|
4193
|
-
* Uses fixed positioning with smart placement above/below anchor
|
|
4194
|
-
*/
|
|
4195
|
-
var ActionMenu = /*#__PURE__*/memo(function ActionMenu(_ref) {
|
|
4188
|
+
function ActionMenu(_ref) {
|
|
4196
4189
|
var _ref$actions = _ref.actions,
|
|
4197
4190
|
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
4198
4191
|
row = _ref.row,
|
|
4199
4192
|
onAction = _ref.onAction,
|
|
4193
|
+
onClose = _ref.onClose,
|
|
4200
4194
|
menuRef = _ref.menuRef,
|
|
4201
|
-
anchorEl = _ref.anchorEl
|
|
4202
|
-
onClose = _ref.onClose;
|
|
4195
|
+
anchorEl = _ref.anchorEl;
|
|
4203
4196
|
var _useState = useState({
|
|
4204
|
-
top: 0,
|
|
4205
4197
|
left: 0,
|
|
4206
|
-
|
|
4198
|
+
top: 0,
|
|
4199
|
+
transformOrigin: "top right",
|
|
4200
|
+
maxHeight: 300,
|
|
4201
|
+
width: 180,
|
|
4202
|
+
opacity: 0
|
|
4207
4203
|
}),
|
|
4208
4204
|
_useState2 = _slicedToArray(_useState, 2),
|
|
4209
|
-
|
|
4210
|
-
|
|
4205
|
+
style = _useState2[0],
|
|
4206
|
+
setStyle = _useState2[1];
|
|
4207
|
+
var menuWidth = 180;
|
|
4208
|
+
var maxMenuHeight = 320;
|
|
4209
|
+
var minMenuHeight = 80;
|
|
4210
|
+
var margin = 8;
|
|
4211
4211
|
useLayoutEffect(function () {
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
});
|
|
4212
|
+
computePosition();
|
|
4213
|
+
var handleResize = function handleResize() {
|
|
4214
|
+
window.requestAnimationFrame(function () {
|
|
4215
|
+
return computePosition();
|
|
4217
4216
|
});
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4217
|
+
};
|
|
4218
|
+
var handleScroll = function handleScroll() {
|
|
4219
|
+
onClose === null || onClose === void 0 || onClose();
|
|
4220
|
+
};
|
|
4221
|
+
window.addEventListener("resize", handleResize);
|
|
4222
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
4223
|
+
return function () {
|
|
4224
|
+
window.removeEventListener("resize", handleResize);
|
|
4225
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
4226
|
+
};
|
|
4227
|
+
}, [anchorEl, actions, menuRef, onClose]);
|
|
4228
|
+
var computePosition = function computePosition() {
|
|
4229
|
+
if (!anchorEl || typeof window === "undefined") return;
|
|
4221
4230
|
var rect = anchorEl.getBoundingClientRect();
|
|
4222
|
-
var menuWidth = menu.offsetWidth || 176;
|
|
4223
|
-
var menuHeight = menu.offsetHeight || menu.scrollHeight || 200;
|
|
4224
|
-
var viewportWidth = window.innerWidth;
|
|
4225
|
-
var viewportHeight = window.innerHeight;
|
|
4226
|
-
var scrollX = window.scrollX || window.pageXOffset || 0;
|
|
4227
4231
|
var scrollY = window.scrollY || window.pageYOffset || 0;
|
|
4228
|
-
var
|
|
4229
|
-
var
|
|
4232
|
+
var scrollX = window.scrollX || window.pageXOffset || 0;
|
|
4233
|
+
var spaceBelow = window.innerHeight - rect.bottom;
|
|
4234
|
+
var spaceAbove = rect.top;
|
|
4230
4235
|
|
|
4231
|
-
//
|
|
4232
|
-
var
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
+
// allowed max height based on available space
|
|
4237
|
+
var allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, Math.max(spaceBelow - margin, spaceAbove - margin)));
|
|
4238
|
+
|
|
4239
|
+
// decide placement
|
|
4240
|
+
var placement = "bottom";
|
|
4241
|
+
if (spaceBelow < 160 && spaceAbove > spaceBelow) {
|
|
4242
|
+
placement = "top";
|
|
4243
|
+
allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceAbove - margin));
|
|
4244
|
+
} else {
|
|
4245
|
+
allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceBelow - margin));
|
|
4246
|
+
}
|
|
4247
|
+
|
|
4248
|
+
// measure content height if available
|
|
4249
|
+
var measuredMenuHeight = allowedMaxHeight;
|
|
4250
|
+
var menuEl = menuRef === null || menuRef === void 0 ? void 0 : menuRef.current;
|
|
4251
|
+
if (menuEl) {
|
|
4252
|
+
var contentHeight = menuEl.scrollHeight || menuEl.offsetHeight || allowedMaxHeight;
|
|
4253
|
+
measuredMenuHeight = Math.min(contentHeight, allowedMaxHeight);
|
|
4236
4254
|
}
|
|
4237
4255
|
|
|
4238
|
-
//
|
|
4256
|
+
// compute top based on placement
|
|
4239
4257
|
var top;
|
|
4240
|
-
if (
|
|
4241
|
-
top =
|
|
4242
|
-
} else if (preferAboveTop >= scrollY + 8) {
|
|
4243
|
-
top = preferAboveTop;
|
|
4258
|
+
if (placement === "top") {
|
|
4259
|
+
top = rect.top + scrollY - measuredMenuHeight - margin;
|
|
4244
4260
|
} else {
|
|
4245
|
-
top =
|
|
4261
|
+
top = rect.bottom + scrollY + margin;
|
|
4246
4262
|
}
|
|
4247
|
-
|
|
4248
|
-
|
|
4263
|
+
|
|
4264
|
+
// clamp top to viewport
|
|
4265
|
+
var minTop = margin + scrollY;
|
|
4266
|
+
var maxTop = window.innerHeight + scrollY - measuredMenuHeight - margin;
|
|
4267
|
+
if (top < minTop) top = minTop;
|
|
4268
|
+
if (top > maxTop) top = maxTop;
|
|
4269
|
+
|
|
4270
|
+
// compute left and clamp horizontally (align right edge of menu to anchor right)
|
|
4271
|
+
var left = rect.right + scrollX - menuWidth;
|
|
4272
|
+
if (left < margin) left = margin;
|
|
4273
|
+
if (left + menuWidth > window.innerWidth - margin) {
|
|
4274
|
+
left = Math.max(margin, window.innerWidth - menuWidth - margin);
|
|
4275
|
+
}
|
|
4276
|
+
var transformOrigin = placement === "bottom" ? "top right" : "bottom right";
|
|
4277
|
+
|
|
4278
|
+
// Apply style (fade-in by setting opacity to 1)
|
|
4279
|
+
setStyle({
|
|
4249
4280
|
left: left,
|
|
4250
|
-
|
|
4281
|
+
top: top,
|
|
4282
|
+
transformOrigin: transformOrigin,
|
|
4283
|
+
maxHeight: allowedMaxHeight,
|
|
4284
|
+
width: menuWidth,
|
|
4285
|
+
opacity: 1
|
|
4251
4286
|
});
|
|
4252
|
-
}
|
|
4253
|
-
|
|
4287
|
+
};
|
|
4288
|
+
|
|
4289
|
+
// measure & position before paint
|
|
4290
|
+
useLayoutEffect(function () {
|
|
4291
|
+
computePosition();
|
|
4292
|
+
var onScrollOrResize = function onScrollOrResize() {
|
|
4293
|
+
window.requestAnimationFrame(function () {
|
|
4294
|
+
return computePosition();
|
|
4295
|
+
});
|
|
4296
|
+
};
|
|
4297
|
+
window.addEventListener("resize", onScrollOrResize);
|
|
4298
|
+
window.addEventListener("scroll", onScrollOrResize, true);
|
|
4299
|
+
return function () {
|
|
4300
|
+
window.removeEventListener("resize", onScrollOrResize);
|
|
4301
|
+
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
4302
|
+
};
|
|
4303
|
+
// recompute when anchor or actions change (content height may change)
|
|
4304
|
+
}, [anchorEl, actions, menuRef]);
|
|
4305
|
+
|
|
4306
|
+
// Render into body
|
|
4307
|
+
return /*#__PURE__*/createPortal(/*#__PURE__*/React__default.createElement("div", {
|
|
4254
4308
|
ref: menuRef,
|
|
4255
|
-
className: "absolute right-0 z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5",
|
|
4256
4309
|
style: {
|
|
4257
|
-
|
|
4258
|
-
|
|
4310
|
+
position: "absolute",
|
|
4311
|
+
top: style.top,
|
|
4312
|
+
left: style.left,
|
|
4313
|
+
width: style.width,
|
|
4314
|
+
maxHeight: style.maxHeight,
|
|
4315
|
+
transformOrigin: style.transformOrigin,
|
|
4316
|
+
opacity: style.opacity
|
|
4259
4317
|
},
|
|
4318
|
+
className: "absolute z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 overflow-y-auto transition-opacity duration-150 ease-out",
|
|
4260
4319
|
onClick: function onClick(e) {
|
|
4261
4320
|
return e.stopPropagation();
|
|
4262
4321
|
}
|
|
@@ -4268,18 +4327,25 @@ var ActionMenu = /*#__PURE__*/memo(function ActionMenu(_ref) {
|
|
|
4268
4327
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
4269
4328
|
key: action.name,
|
|
4270
4329
|
className: "px-1"
|
|
4271
|
-
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4330
|
+
}, action.render ? /*#__PURE__*/React__default.createElement("button", {
|
|
4331
|
+
className: "w-full text-left px-3 py-2 text-sm hover:bg-gray-100 flex items-center gap-2 rounded-md",
|
|
4332
|
+
onClick: function onClick(e) {
|
|
4333
|
+
e.stopPropagation();
|
|
4334
|
+
onAction === null || onAction === void 0 || onAction(action, row);
|
|
4335
|
+
onClose === null || onClose === void 0 || onClose();
|
|
4336
|
+
}
|
|
4337
|
+
}, action.render(row)) : /*#__PURE__*/React__default.createElement("button", {
|
|
4272
4338
|
className: "w-full text-left px-3 py-2 text-sm hover:bg-gray-100 flex items-center gap-2 rounded-md",
|
|
4273
4339
|
onClick: function onClick(e) {
|
|
4274
4340
|
e.stopPropagation();
|
|
4275
4341
|
onAction === null || onAction === void 0 || onAction(action, row);
|
|
4276
4342
|
onClose === null || onClose === void 0 || onClose();
|
|
4277
4343
|
}
|
|
4278
|
-
}, action.
|
|
4344
|
+
}, action.icon && /*#__PURE__*/React__default.createElement("span", {
|
|
4279
4345
|
className: "inline-flex"
|
|
4280
|
-
}, action.icon), /*#__PURE__*/React__default.createElement("span", null, action.label)))
|
|
4281
|
-
})));
|
|
4282
|
-
}
|
|
4346
|
+
}, action.icon), /*#__PURE__*/React__default.createElement("span", null, action.label)));
|
|
4347
|
+
}))), document.body);
|
|
4348
|
+
}
|
|
4283
4349
|
|
|
4284
4350
|
/**
|
|
4285
4351
|
* Desktop table row component
|
|
@@ -15847,6 +15913,176 @@ function LocationPicker(_ref) {
|
|
|
15847
15913
|
}, iconButton)));
|
|
15848
15914
|
}
|
|
15849
15915
|
|
|
15916
|
+
var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
15917
|
+
var _ref$lang = _ref.lang,
|
|
15918
|
+
lang = _ref$lang === void 0 ? "en-US" : _ref$lang,
|
|
15919
|
+
_ref$continuous = _ref.continuous,
|
|
15920
|
+
continuous = _ref$continuous === void 0 ? true : _ref$continuous,
|
|
15921
|
+
_ref$interimResults = _ref.interimResults,
|
|
15922
|
+
interimResults = _ref$interimResults === void 0 ? true : _ref$interimResults,
|
|
15923
|
+
_ref$onSpeechComplete = _ref.onSpeechComplete,
|
|
15924
|
+
onSpeechComplete = _ref$onSpeechComplete === void 0 ? function () {} : _ref$onSpeechComplete,
|
|
15925
|
+
_ref$onSpeaking = _ref.onSpeaking,
|
|
15926
|
+
onSpeaking = _ref$onSpeaking === void 0 ? function () {} : _ref$onSpeaking,
|
|
15927
|
+
_ref$onError = _ref.onError,
|
|
15928
|
+
onError = _ref$onError === void 0 ? function () {} : _ref$onError,
|
|
15929
|
+
_ref$onStart = _ref.onStart,
|
|
15930
|
+
onStart = _ref$onStart === void 0 ? function () {} : _ref$onStart,
|
|
15931
|
+
_ref$onStop = _ref.onStop,
|
|
15932
|
+
onStop = _ref$onStop === void 0 ? function () {} : _ref$onStop,
|
|
15933
|
+
_ref$renderButton = _ref.renderButton,
|
|
15934
|
+
renderButton = _ref$renderButton === void 0 ? null : _ref$renderButton,
|
|
15935
|
+
_ref$autoStart = _ref.autoStart,
|
|
15936
|
+
autoStart = _ref$autoStart === void 0 ? false : _ref$autoStart,
|
|
15937
|
+
_ref$disabled = _ref.disabled,
|
|
15938
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
15939
|
+
var recognitionRef = useRef(null);
|
|
15940
|
+
var finalTranscriptRef = useRef("");
|
|
15941
|
+
var _useState = useState(false),
|
|
15942
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15943
|
+
_isListening = _useState2[0],
|
|
15944
|
+
setIsListening = _useState2[1];
|
|
15945
|
+
var _useState3 = useState(true),
|
|
15946
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
15947
|
+
_isSupported = _useState4[0],
|
|
15948
|
+
setIsSupported = _useState4[1];
|
|
15949
|
+
useEffect(function () {
|
|
15950
|
+
if (!("webkitSpeechRecognition" in window) && !("SpeechRecognition" in window)) {
|
|
15951
|
+
setIsSupported(false);
|
|
15952
|
+
} else {
|
|
15953
|
+
setIsSupported(true);
|
|
15954
|
+
}
|
|
15955
|
+
}, []);
|
|
15956
|
+
useEffect(function () {
|
|
15957
|
+
if (autoStart && _isSupported) {
|
|
15958
|
+
startListening();
|
|
15959
|
+
}
|
|
15960
|
+
return function () {
|
|
15961
|
+
if (recognitionRef.current) {
|
|
15962
|
+
try {
|
|
15963
|
+
recognitionRef.current.onresult = null;
|
|
15964
|
+
recognitionRef.current.onerror = null;
|
|
15965
|
+
recognitionRef.current.onend = null;
|
|
15966
|
+
recognitionRef.current.onstart = null;
|
|
15967
|
+
recognitionRef.current.stop();
|
|
15968
|
+
} catch (e) {}
|
|
15969
|
+
}
|
|
15970
|
+
};
|
|
15971
|
+
}, [autoStart, _isSupported]);
|
|
15972
|
+
function initializeRecognition() {
|
|
15973
|
+
if (recognitionRef.current) return recognitionRef.current;
|
|
15974
|
+
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
15975
|
+
if (!SpeechRecognition) {
|
|
15976
|
+
var err = new Error("SpeechRecognition API not available");
|
|
15977
|
+
onError(err);
|
|
15978
|
+
return null;
|
|
15979
|
+
}
|
|
15980
|
+
var recognition = new SpeechRecognition();
|
|
15981
|
+
recognition.continuous = !!continuous;
|
|
15982
|
+
recognition.interimResults = !!interimResults;
|
|
15983
|
+
recognition.lang = lang;
|
|
15984
|
+
recognition.onstart = function () {
|
|
15985
|
+
finalTranscriptRef.current = finalTranscriptRef.current || "";
|
|
15986
|
+
setIsListening(true);
|
|
15987
|
+
onStart();
|
|
15988
|
+
};
|
|
15989
|
+
recognition.onresult = function (event) {
|
|
15990
|
+
var interim = "";
|
|
15991
|
+
var finalPart = "";
|
|
15992
|
+
for (var i = event.resultIndex; i < event.results.length; i++) {
|
|
15993
|
+
var piece = event.results[i][0].transcript;
|
|
15994
|
+
if (event.results[i].isFinal) {
|
|
15995
|
+
finalPart += piece + " ";
|
|
15996
|
+
} else {
|
|
15997
|
+
interim += piece;
|
|
15998
|
+
}
|
|
15999
|
+
}
|
|
16000
|
+
if (interim) {
|
|
16001
|
+
onSpeaking(interim);
|
|
16002
|
+
}
|
|
16003
|
+
if (finalPart) {
|
|
16004
|
+
finalTranscriptRef.current = (finalTranscriptRef.current || "") + finalPart;
|
|
16005
|
+
onSpeechComplete(finalTranscriptRef.current.trim());
|
|
16006
|
+
}
|
|
16007
|
+
};
|
|
16008
|
+
recognition.onerror = function (event) {
|
|
16009
|
+
var err = event && event.error ? new Error(event.error) : new Error("Speech recognition error");
|
|
16010
|
+
onError(err);
|
|
16011
|
+
setIsListening(false);
|
|
16012
|
+
};
|
|
16013
|
+
recognition.onend = function () {
|
|
16014
|
+
setIsListening(false);
|
|
16015
|
+
onStop();
|
|
16016
|
+
onSpeechComplete((finalTranscriptRef.current || "").trim());
|
|
16017
|
+
};
|
|
16018
|
+
recognitionRef.current = recognition;
|
|
16019
|
+
return recognition;
|
|
16020
|
+
}
|
|
16021
|
+
function startListening() {
|
|
16022
|
+
if (!_isSupported) {
|
|
16023
|
+
onError(new Error("Speech recognition not supported in this browser"));
|
|
16024
|
+
return;
|
|
16025
|
+
}
|
|
16026
|
+
try {
|
|
16027
|
+
var rec = initializeRecognition();
|
|
16028
|
+
if (!rec) return;
|
|
16029
|
+
rec.start();
|
|
16030
|
+
} catch (err) {
|
|
16031
|
+
onError(err);
|
|
16032
|
+
}
|
|
16033
|
+
}
|
|
16034
|
+
function stopListening() {
|
|
16035
|
+
if (recognitionRef.current) {
|
|
16036
|
+
try {
|
|
16037
|
+
recognitionRef.current.stop();
|
|
16038
|
+
} catch (e) {}
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
16041
|
+
function toggleListening() {
|
|
16042
|
+
if (disabled) return;
|
|
16043
|
+
if (_isListening) {
|
|
16044
|
+
stopListening();
|
|
16045
|
+
} else {
|
|
16046
|
+
startListening();
|
|
16047
|
+
}
|
|
16048
|
+
}
|
|
16049
|
+
useImperativeHandle(ref, function () {
|
|
16050
|
+
return {
|
|
16051
|
+
start: startListening,
|
|
16052
|
+
stop: stopListening,
|
|
16053
|
+
toggle: toggleListening,
|
|
16054
|
+
isListening: function isListening() {
|
|
16055
|
+
return _isListening;
|
|
16056
|
+
},
|
|
16057
|
+
isSupported: function isSupported() {
|
|
16058
|
+
return _isSupported;
|
|
16059
|
+
},
|
|
16060
|
+
getTranscript: function getTranscript() {
|
|
16061
|
+
return (finalTranscriptRef.current || "").trim();
|
|
16062
|
+
},
|
|
16063
|
+
clearTranscript: function clearTranscript() {
|
|
16064
|
+
finalTranscriptRef.current = "";
|
|
16065
|
+
}
|
|
16066
|
+
};
|
|
16067
|
+
}, [_isListening, _isSupported]);
|
|
16068
|
+
if (renderButton && typeof renderButton === "function") {
|
|
16069
|
+
return renderButton({
|
|
16070
|
+
isListening: _isListening,
|
|
16071
|
+
isSupported: _isSupported,
|
|
16072
|
+
start: startListening,
|
|
16073
|
+
stop: stopListening,
|
|
16074
|
+
toggle: toggleListening,
|
|
16075
|
+
disabled: disabled
|
|
16076
|
+
});
|
|
16077
|
+
}
|
|
16078
|
+
return /*#__PURE__*/React__default.createElement("button", {
|
|
16079
|
+
type: "button",
|
|
16080
|
+
"aria-pressed": _isListening,
|
|
16081
|
+
onClick: toggleListening,
|
|
16082
|
+
disabled: disabled || !_isSupported
|
|
16083
|
+
}, _isListening ? "Stop" : "Start");
|
|
16084
|
+
});
|
|
16085
|
+
|
|
15850
16086
|
var _excluded$d = ["items", "collapsed", "onToggle", "className", "logo", "user", "onUserClick", "drawerPosition", "isMobileOpen", "setIsMobileOpen", "showCollapsedTooltips", "tooltipOptions"];
|
|
15851
16087
|
|
|
15852
16088
|
/**
|
|
@@ -16479,7 +16715,7 @@ var Navbar = function Navbar(_ref3) {
|
|
|
16479
16715
|
"text-gray-700 hover:bg-gray-50": !item.active
|
|
16480
16716
|
})
|
|
16481
16717
|
}, item.label);
|
|
16482
|
-
}))));
|
|
16718
|
+
}))), /*#__PURE__*/React__default.createElement("h1", null, "asddddddddddddd"));
|
|
16483
16719
|
};
|
|
16484
16720
|
Navbar.displayName = "Navbar";
|
|
16485
16721
|
Navbar.propTypes = {
|
|
@@ -26519,4 +26755,4 @@ var StoreProvider = function StoreProvider(_ref) {
|
|
|
26519
26755
|
}, children));
|
|
26520
26756
|
};
|
|
26521
26757
|
|
|
26522
|
-
export { Accordion, Alert, Avatar, Badge, Breadcrumbs, Button, Card, Carousel, Checkbox, ColorPicker, Condition, DatePicker, DateRangePicker, Dialog, EmitterClass as Emitter, FileUpload, FootNav, Form, Helpers, Input, Loader, LocationPicker, Navbar, Pagination, PriceRangePicker, ProgressBar, Radio, Rate, RoundedTag, Select, Sidebar, Skeleton, Stepper, StoreProvider, Switch, Table, Tabs, ThemeProvider, ThreeDotPopoverSimple as ThreeDotPopover, Toast, ToastContainer, Tooltip, cn$1 as cn, useApi, useMixins, useTheme, useToast };
|
|
26758
|
+
export { Accordion, Alert, Avatar, Badge, Breadcrumbs, Button, Card, Carousel, Checkbox, ColorPicker, Condition, DatePicker, DateRangePicker, Dialog, EmitterClass as Emitter, FileUpload, FootNav, Form, Helpers, Input, Loader, LocationPicker, Navbar, Pagination, PriceRangePicker, ProgressBar, Radio, Rate, RoundedTag, Select, Sidebar, Skeleton, SpeechToText, Stepper, StoreProvider, Switch, Table, Tabs, ThemeProvider, ThreeDotPopoverSimple as ThreeDotPopover, Toast, ToastContainer, Tooltip, cn$1 as cn, useApi, useMixins, useTheme, useToast };
|