@bearlab/switch
Version:
Bearlab UI Switch Component
515 lines (486 loc) • 29.8 kB
JavaScript
import require$$0 from 'react';
import classnames from 'classnames';
import { IconErrorTriangle } from '@bearlab/core';
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
var jsxRuntime = {exports: {}};
var reactJsxRuntime_production = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactJsxRuntime_production;
function requireReactJsxRuntime_production () {
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
hasRequiredReactJsxRuntime_production = 1;
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
function jsxProd(type, config, maybeKey) {
var key = null;
void 0 !== maybeKey && (key = "" + maybeKey);
void 0 !== config.key && (key = "" + config.key);
if ("key" in config) {
maybeKey = {};
for (var propName in config)
"key" !== propName && (maybeKey[propName] = config[propName]);
} else maybeKey = config;
config = maybeKey.ref;
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key,
ref: void 0 !== config ? config : null,
props: maybeKey
};
}
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
reactJsxRuntime_production.jsx = jsxProd;
reactJsxRuntime_production.jsxs = jsxProd;
return reactJsxRuntime_production;
}
var reactJsxRuntime_development = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactJsxRuntime_development;
function requireReactJsxRuntime_development () {
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
hasRequiredReactJsxRuntime_development = 1;
"production" !== process.env.NODE_ENV &&
(function () {
function getComponentNameFromType(type) {
if (null == type) return null;
if ("function" === typeof type)
return type.$$typeof === REACT_CLIENT_REFERENCE
? null
: type.displayName || type.name || null;
if ("string" === typeof type) return type;
switch (type) {
case REACT_FRAGMENT_TYPE:
return "Fragment";
case REACT_PROFILER_TYPE:
return "Profiler";
case REACT_STRICT_MODE_TYPE:
return "StrictMode";
case REACT_SUSPENSE_TYPE:
return "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
case REACT_ACTIVITY_TYPE:
return "Activity";
}
if ("object" === typeof type)
switch (
("number" === typeof type.tag &&
console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
),
type.$$typeof)
) {
case REACT_PORTAL_TYPE:
return "Portal";
case REACT_CONTEXT_TYPE:
return (type.displayName || "Context") + ".Provider";
case REACT_CONSUMER_TYPE:
return (type._context.displayName || "Context") + ".Consumer";
case REACT_FORWARD_REF_TYPE:
var innerType = type.render;
type = type.displayName;
type ||
((type = innerType.displayName || innerType.name || ""),
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
return type;
case REACT_MEMO_TYPE:
return (
(innerType = type.displayName || null),
null !== innerType
? innerType
: getComponentNameFromType(type.type) || "Memo"
);
case REACT_LAZY_TYPE:
innerType = type._payload;
type = type._init;
try {
return getComponentNameFromType(type(innerType));
} catch (x) {}
}
return null;
}
function testStringCoercion(value) {
return "" + value;
}
function checkKeyStringCoercion(value) {
try {
testStringCoercion(value);
var JSCompiler_inline_result = !1;
} catch (e) {
JSCompiler_inline_result = true;
}
if (JSCompiler_inline_result) {
JSCompiler_inline_result = console;
var JSCompiler_temp_const = JSCompiler_inline_result.error;
var JSCompiler_inline_result$jscomp$0 =
("function" === typeof Symbol &&
Symbol.toStringTag &&
value[Symbol.toStringTag]) ||
value.constructor.name ||
"Object";
JSCompiler_temp_const.call(
JSCompiler_inline_result,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
JSCompiler_inline_result$jscomp$0
);
return testStringCoercion(value);
}
}
function getTaskName(type) {
if (type === REACT_FRAGMENT_TYPE) return "<>";
if (
"object" === typeof type &&
null !== type &&
type.$$typeof === REACT_LAZY_TYPE
)
return "<...>";
try {
var name = getComponentNameFromType(type);
return name ? "<" + name + ">" : "<...>";
} catch (x) {
return "<...>";
}
}
function getOwner() {
var dispatcher = ReactSharedInternals.A;
return null === dispatcher ? null : dispatcher.getOwner();
}
function UnknownOwner() {
return Error("react-stack-top-frame");
}
function hasValidKey(config) {
if (hasOwnProperty.call(config, "key")) {
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
if (getter && getter.isReactWarning) return false;
}
return void 0 !== config.key;
}
function defineKeyPropWarningGetter(props, displayName) {
function warnAboutAccessingKey() {
specialPropKeyWarningShown ||
((specialPropKeyWarningShown = true),
console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
displayName
));
}
warnAboutAccessingKey.isReactWarning = true;
Object.defineProperty(props, "key", {
get: warnAboutAccessingKey,
configurable: true
});
}
function elementRefGetterWithDeprecationWarning() {
var componentName = getComponentNameFromType(this.type);
didWarnAboutElementRef[componentName] ||
((didWarnAboutElementRef[componentName] = true),
console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
));
componentName = this.props.ref;
return void 0 !== componentName ? componentName : null;
}
function ReactElement(
type,
key,
self,
source,
owner,
props,
debugStack,
debugTask
) {
self = props.ref;
type = {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key,
props: props,
_owner: owner
};
null !== (void 0 !== self ? self : null)
? Object.defineProperty(type, "ref", {
enumerable: false,
get: elementRefGetterWithDeprecationWarning
})
: Object.defineProperty(type, "ref", { enumerable: false, value: null });
type._store = {};
Object.defineProperty(type._store, "validated", {
configurable: false,
enumerable: false,
writable: true,
value: 0
});
Object.defineProperty(type, "_debugInfo", {
configurable: false,
enumerable: false,
writable: true,
value: null
});
Object.defineProperty(type, "_debugStack", {
configurable: false,
enumerable: false,
writable: true,
value: debugStack
});
Object.defineProperty(type, "_debugTask", {
configurable: false,
enumerable: false,
writable: true,
value: debugTask
});
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
return type;
}
function jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
debugStack,
debugTask
) {
var children = config.children;
if (void 0 !== children)
if (isStaticChildren)
if (isArrayImpl(children)) {
for (
isStaticChildren = 0;
isStaticChildren < children.length;
isStaticChildren++
)
validateChildKeys(children[isStaticChildren]);
Object.freeze && Object.freeze(children);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else validateChildKeys(children);
if (hasOwnProperty.call(config, "key")) {
children = getComponentNameFromType(type);
var keys = Object.keys(config).filter(function (k) {
return "key" !== k;
});
isStaticChildren =
0 < keys.length
? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
: "{key: someKey}";
didWarnAboutKeySpread[children + isStaticChildren] ||
((keys =
0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
console.error(
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
isStaticChildren,
children,
keys,
children
),
(didWarnAboutKeySpread[children + isStaticChildren] = true));
}
children = null;
void 0 !== maybeKey &&
(checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
hasValidKey(config) &&
(checkKeyStringCoercion(config.key), (children = "" + config.key));
if ("key" in config) {
maybeKey = {};
for (var propName in config)
"key" !== propName && (maybeKey[propName] = config[propName]);
} else maybeKey = config;
children &&
defineKeyPropWarningGetter(
maybeKey,
"function" === typeof type
? type.displayName || type.name || "Unknown"
: type
);
return ReactElement(
type,
children,
self,
source,
getOwner(),
maybeKey,
debugStack,
debugTask
);
}
function validateChildKeys(node) {
"object" === typeof node &&
null !== node &&
node.$$typeof === REACT_ELEMENT_TYPE &&
node._store &&
(node._store.validated = 1);
}
var React = require$$0,
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
REACT_MEMO_TYPE = Symbol.for("react.memo"),
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
ReactSharedInternals =
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
hasOwnProperty = Object.prototype.hasOwnProperty,
isArrayImpl = Array.isArray,
createTask = console.createTask
? console.createTask
: function () {
return null;
};
React = {
react_stack_bottom_frame: function (callStackForError) {
return callStackForError();
}
};
var specialPropKeyWarningShown;
var didWarnAboutElementRef = {};
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
React,
UnknownOwner
)();
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
var didWarnAboutKeySpread = {};
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
reactJsxRuntime_development.jsx = function (type, config, maybeKey, source, self) {
var trackActualOwner =
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
return jsxDEVImpl(
type,
config,
maybeKey,
false,
source,
self,
trackActualOwner
? Error("react-stack-top-frame")
: unknownOwnerDebugStack,
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
);
};
reactJsxRuntime_development.jsxs = function (type, config, maybeKey, source, self) {
var trackActualOwner =
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
return jsxDEVImpl(
type,
config,
maybeKey,
true,
source,
self,
trackActualOwner
? Error("react-stack-top-frame")
: unknownOwnerDebugStack,
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
);
};
})();
return reactJsxRuntime_development;
}
var hasRequiredJsxRuntime;
function requireJsxRuntime () {
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
hasRequiredJsxRuntime = 1;
if (process.env.NODE_ENV === 'production') {
jsxRuntime.exports = requireReactJsxRuntime_production();
} else {
jsxRuntime.exports = requireReactJsxRuntime_development();
}
return jsxRuntime.exports;
}
var jsxRuntimeExports = requireJsxRuntime();
function styleInject(css, ref) {
if ( ref === void 0 ) ref = {};
var insertAt = ref.insertAt;
if (typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
var css_248z = ":root[data-theme=light]{--theme-color:#1d2939;--skeleton-bg:#e4e7ec;--skeleton-shimmer:linear-gradient(90deg,transparent,rgba(70,95,255,.15),transparent);--skeleton-shadow:rgba(16,24,40,.12);--skeleton-border:#e4e7ec;--skeleton-card-bg:#fff;--skeleton-accent:color-mix(in oklab,#465fff 8%,transparent)}:root[data-theme=dark]{--theme-color:color-mix(in oklab,#fff 90%,transparent);--skeleton-bg:#1d2939;--skeleton-shimmer:linear-gradient(90deg,transparent,rgba(117,146,255,.2),transparent);--skeleton-shadow:rgba(0,0,0,.4);--skeleton-border:#1d2939;--skeleton-card-bg:#0f1828;--skeleton-accent:color-mix(in oklab,#7592ff 12%,transparent)}.switch-module_container__P5nIl{align-items:center;color:#374151;cursor:pointer;display:flex;font-size:14px;gap:12px;position:relative;user-select:none}.switch-module_container__P5nIl:hover .switch-module_popover__WDi85{display:block}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F{position:relative}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F input{clip:rect(0,0,0,0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_slider__axqSk{align-items:center;border-radius:999px;display:flex;height:20px;position:relative;transition:all .2s ease;width:40px}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_slider__axqSk .switch-module_toggle__L3590{border-radius:50%;height:16px;position:absolute;transition:all .2s ease;width:16px}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_slider__axqSk .switch-module_toggleActive__eqhkO{background-color:#fff;transform:translateX(21px)}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_slider__axqSk .switch-module_toggleInactive__VNI0Y{background-color:#fff;transform:translateX(1px)}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_checked__BZmr9{background-color:#465fff;border:1px solid #465fff}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_unchecked__x3QU-{background-color:#d1d5db;border:1px solid #d1d5db}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_sliderDisabled__TY4hA{cursor:not-allowed;opacity:.6;pointer-events:none}.switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_popover__WDi85{left:-14px}.switch-module_container__P5nIl .switch-module_label__0mo-C{color:#344054;font-size:14px;font-weight:600;width:max-content}.switch-module_container__P5nIl .switch-module_label__0mo-C span{color:#f04438}.switch-module_container__P5nIl .switch-module_popover__WDi85{background-color:#fff;border-radius:8px;box-shadow:0 1px 1px 0 rgba(162,184,191,.274),inset 0 -1px 1px 1px rgba(196,205,222,.119),inset 0 0 0 1px rgba(197,206,225,.383);color:#344054;display:none;font-size:13px;font-weight:500;padding:12px;position:absolute;top:-45px;width:max-content;z-index:9999}.switch-module_container__P5nIl .switch-module_viewError__2rBxV{align-items:center;bottom:-20px;display:flex;font-size:14px;left:0;position:absolute;width:max-content}.switch-module_container__P5nIl .switch-module_viewError__2rBxV svg{height:12px;margin-right:8px;width:12px}.switch-module_container__P5nIl .switch-module_viewError__2rBxV span{color:#f00438}.switch-module_disabled__jGYrk{cursor:not-allowed;opacity:.6;pointer-events:none}html[data-theme=dark] .switch-module_container__P5nIl{color:#9ca3af}html[data-theme=dark] .switch-module_container__P5nIl .switch-module_switchWrapper__Per-F .switch-module_unchecked__x3QU-{background-color:#374151;border-color:#374151}html[data-theme=dark] .switch-module_container__P5nIl .switch-module_label__0mo-C{color:#98a2b3}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN3aXRjaC5tb2R1bGUuc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx3QkFDRSxxQkFBc0IsQ0FDdEIscUJBQXNCLENBQ3RCLHFGQUtDLENBQ0Qsb0NBQXlDLENBQ3pDLHlCQUEwQixDQUMxQix1QkFBd0IsQ0FDeEIsNERBQ0YsQ0FFQSx1QkFDRSxzREFBeUQsQ0FDekQscUJBQXNCLENBQ3RCLHNGQUtDLENBQ0QsZ0NBQXFDLENBQ3JDLHlCQUEwQixDQUMxQiwwQkFBMkIsQ0FDM0IsNkRBQ0YsQ0FFQSxnQ0FLRSxrQkFBbUIsQ0FHbkIsYUFBYyxDQUxkLGNBQWUsQ0FEZixZQUFhLENBS2IsY0FBZSxDQURmLFFBQVMsQ0FMVCxpQkFBa0IsQ0FHbEIsZ0JBS0YsQ0FDQSxvRUFDRSxhQUNGLENBQ0Esb0VBQ0UsaUJBQ0YsQ0FDQSwwRUFPRSxrQkFBc0IsQ0FFdEIsUUFBUyxDQU5ULFVBQVcsQ0FFWCxXQUFZLENBQ1osZUFBZ0IsQ0FGaEIsU0FBVSxDQUhWLGlCQUFrQixDQU9sQixrQkFBbUIsQ0FObkIsU0FRRixDQUNBLGlHQUVFLGtCQUFtQixDQUduQixtQkFBb0IsQ0FKcEIsWUFBYSxDQUdiLFdBQVksQ0FHWixpQkFBa0IsQ0FEbEIsdUJBQXlCLENBSHpCLFVBS0YsQ0FDQSw4SEFJRSxpQkFBa0IsQ0FEbEIsV0FBWSxDQUZaLGlCQUFrQixDQUlsQix1QkFBeUIsQ0FIekIsVUFJRixDQUNBLG9JQUVFLHFC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jb250YWluZXIgLmxhYmVsIHtcbiAgY29sb3I6ICM5OGEyYjM7XG59Il19 */";
var styles = {"container":"switch-module_container__P5nIl","popover":"switch-module_popover__WDi85","switchWrapper":"switch-module_switchWrapper__Per-F","slider":"switch-module_slider__axqSk","toggle":"switch-module_toggle__L3590","toggleActive":"switch-module_toggleActive__eqhkO","toggleInactive":"switch-module_toggleInactive__VNI0Y","checked":"switch-module_checked__BZmr9","unchecked":"switch-module_unchecked__x3QU-","sliderDisabled":"switch-module_sliderDisabled__TY4hA","label":"switch-module_label__0mo-C","viewError":"switch-module_viewError__2rBxV","disabled":"switch-module_disabled__jGYrk"};
styleInject(css_248z);
var Switch = function (props) {
var checked = props.checked, className = props.className, disabled = props.disabled, label = props.label, name = props.name, error = props.error, isRequired = props.isRequired, popover = props.popover, rest = __rest(props, ["checked", "className", "disabled", "label", "name", "error", "isRequired", "popover"]);
return (jsxRuntimeExports.jsxs("label", { htmlFor: name, className: classnames(styles.container, className, disabled && styles.disabled), children: [jsxRuntimeExports.jsxs("div", { className: styles.switchWrapper, children: [jsxRuntimeExports.jsx("input", __assign({ id: name, name: name, type: "checkbox", checked: checked, disabled: disabled }, rest)), jsxRuntimeExports.jsx("span", { className: classnames(styles.slider, checked ? styles.checked : styles.unchecked, disabled && styles.sliderDisabled), children: jsxRuntimeExports.jsx("span", { className: classnames(styles.toggle, checked ? styles.toggleActive : styles.toggleInactive) }) }), error && (jsxRuntimeExports.jsxs("div", { className: styles.viewError, children: [jsxRuntimeExports.jsx(IconErrorTriangle, {}), jsxRuntimeExports.jsx("span", { children: label })] })), popover && jsxRuntimeExports.jsx("div", { className: styles.popover, children: popover })] }), label && (jsxRuntimeExports.jsxs("div", { className: styles.label, children: [label, " ", isRequired && jsxRuntimeExports.jsx("span", { children: "*" })] }))] }));
};
export { Switch };
//# sourceMappingURL=index.esm.js.map