baseui
Version:
A React Component library implementing the Base design language
52 lines (48 loc) • 3.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.LocaleContext = void 0;
var React = _interopRequireWildcard(require("react"));
var _justExtend = _interopRequireDefault(require("just-extend"));
var _en_US = _interopRequireDefault(require("./en_US"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/*
Copyright (c) Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @ts-ignore
const LocaleContext = exports.LocaleContext = /*#__PURE__*/React.createContext(_en_US.default);
const LocaleProvider = props => {
const {
locale,
children
} = props;
const parentLocale = React.useContext(LocaleContext) ?? {};
return (
/*#__PURE__*/
// this is poorly documented but specifying true enforces that the object is deeply extended
// https://www.npmjs.com/package/just-extend
// @ts-expect-error todo(ts-migration) TS2740 Type '{}' is missing the following properties from type 'Locale': accordion, breadcrumbs, datepicker, datatable, and 8 more.
React.createElement(LocaleContext.Provider, {
value: (0, _justExtend.default)(true, {}, _en_US.default, parentLocale, locale)
}, children)
);
};
var _default = exports.default = LocaleProvider;
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */
/** @deprecated inded use type exported from the component itself */