@coreui/react 4.9.0-alpha.0 → 4.9.0-beta.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/README.md +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/tooltip/CTooltip.d.ts +2 -2
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/useColorModes.d.ts +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +184 -243
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +185 -242
- package/dist/index.js.map +1 -1
- package/dist/props.d.ts +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/isRTL.d.ts +2 -0
- package/package.json +9 -9
- package/src/components/accordion/index.ts +1 -7
- package/src/components/dropdown/CDropdownMenu.tsx +5 -4
- package/src/components/form/CFormSelect.tsx +3 -1
- package/src/components/modal/CModal.tsx +2 -0
- package/src/components/popover/CPopover.tsx +60 -25
- package/src/components/popover/__tests__/__snapshots__/CPopover.spec.tsx.snap +2 -1
- package/src/components/progress/CProgress.tsx +1 -0
- package/src/components/sidebar/CSidebar.tsx +2 -2
- package/src/components/spinner/CSpinner.tsx +4 -2
- package/src/components/spinner/__tests__/__snapshots__/CSpinner.spec.tsx.snap +2 -2
- package/src/components/table/CTable.tsx +2 -1
- package/src/components/tooltip/CTooltip.tsx +64 -30
- package/src/components/tooltip/__tests__/CTooltip.spec.tsx +1 -1
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useColorModes.ts +55 -0
- package/src/hooks/useForkedRef.ts +1 -1
- package/src/index.ts +1 -0
- package/src/props.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/isRTL.ts +13 -0
- package/src/components/accordion/__tests__/__snapshots__/CAccordionCollapse.spec.tsx.snap +0 -11
package/dist/index.js
CHANGED
|
@@ -2492,6 +2492,46 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, T
|
|
|
2492
2492
|
}) : {};
|
|
2493
2493
|
var CSSTransition$1 = CSSTransition;
|
|
2494
2494
|
|
|
2495
|
+
var getStoredTheme = function (localStorageItemName) { return localStorage.getItem(localStorageItemName); };
|
|
2496
|
+
var setStoredTheme = function (localStorageItemName, colorMode) {
|
|
2497
|
+
return localStorage.setItem(localStorageItemName, colorMode);
|
|
2498
|
+
};
|
|
2499
|
+
var getPreferredColorScheme = function (localStorageItemName) {
|
|
2500
|
+
var storedTheme = getStoredTheme(localStorageItemName);
|
|
2501
|
+
if (storedTheme) {
|
|
2502
|
+
return storedTheme;
|
|
2503
|
+
}
|
|
2504
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
2505
|
+
};
|
|
2506
|
+
var setTheme = function (colorMode) {
|
|
2507
|
+
document.documentElement.dataset.coreuiTheme =
|
|
2508
|
+
colorMode === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
2509
|
+
? 'dark'
|
|
2510
|
+
: colorMode;
|
|
2511
|
+
var event = new Event('ColorSchemeChange');
|
|
2512
|
+
document.documentElement.dispatchEvent(event);
|
|
2513
|
+
};
|
|
2514
|
+
var useColorModes = function (localStorageItemName) {
|
|
2515
|
+
if (localStorageItemName === void 0) { localStorageItemName = 'coreui-react-color-scheme'; }
|
|
2516
|
+
var _a = React.useState(getPreferredColorScheme(localStorageItemName)), colorMode = _a[0], setColorMode = _a[1];
|
|
2517
|
+
React.useEffect(function () {
|
|
2518
|
+
setStoredTheme(localStorageItemName, colorMode);
|
|
2519
|
+
setTheme(colorMode);
|
|
2520
|
+
}, [colorMode]);
|
|
2521
|
+
React.useEffect(function () {
|
|
2522
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function () {
|
|
2523
|
+
var storedTheme = getStoredTheme(localStorageItemName);
|
|
2524
|
+
if (storedTheme !== 'light' && storedTheme !== 'dark') {
|
|
2525
|
+
setTheme(colorMode);
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
}, []);
|
|
2529
|
+
return {
|
|
2530
|
+
getColorMode: function () { return colorMode; },
|
|
2531
|
+
setColorMode: function (mode) { return setColorMode(mode); },
|
|
2532
|
+
};
|
|
2533
|
+
};
|
|
2534
|
+
|
|
2495
2535
|
// code borrowed from https://github.com/reach/reach-ui
|
|
2496
2536
|
// problem described https://github.com/facebook/react/issues/13029
|
|
2497
2537
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2525,7 +2565,7 @@ value) {
|
|
|
2525
2565
|
try {
|
|
2526
2566
|
ref.current = value;
|
|
2527
2567
|
}
|
|
2528
|
-
catch (
|
|
2568
|
+
catch (_a) {
|
|
2529
2569
|
throw new Error("Cannot assign value \"".concat(value, "\" to ref \"").concat(ref, "\""));
|
|
2530
2570
|
}
|
|
2531
2571
|
}
|
|
@@ -2697,7 +2737,10 @@ var textColorsPropType = PropTypes.oneOfType([
|
|
|
2697
2737
|
PropTypes.oneOf(['white', 'muted']),
|
|
2698
2738
|
PropTypes.string,
|
|
2699
2739
|
]);
|
|
2700
|
-
var triggerPropType = PropTypes.
|
|
2740
|
+
var triggerPropType = PropTypes.oneOfType([
|
|
2741
|
+
PropTypes.arrayOf(PropTypes.oneOf(['hover', 'focus', 'click']).isRequired),
|
|
2742
|
+
PropTypes.oneOf(['hover', 'focus', 'click']),
|
|
2743
|
+
]);
|
|
2701
2744
|
|
|
2702
2745
|
var CAlert = React.forwardRef(function (_a, ref) {
|
|
2703
2746
|
var children = _a.children, className = _a.className, _b = _a.color, color = _b === void 0 ? 'primary' : _b, dismissible = _a.dismissible, variant = _a.variant, _c = _a.visible, visible = _c === void 0 ? true : _c, onClose = _a.onClose, rest = __rest(_a, ["children", "className", "color", "dismissible", "variant", "visible", "onClose"]);
|
|
@@ -3041,6 +3084,16 @@ var isInViewport = function (element) {
|
|
|
3041
3084
|
Math.floor(rect.right) <= (window.innerWidth || document.documentElement.clientWidth));
|
|
3042
3085
|
};
|
|
3043
3086
|
|
|
3087
|
+
var isRTL = function (element) {
|
|
3088
|
+
if (typeof document !== 'undefined' && document.documentElement.dir === 'rtl') {
|
|
3089
|
+
return true;
|
|
3090
|
+
}
|
|
3091
|
+
if (element) {
|
|
3092
|
+
return element.closest('[dir="rtl"]') !== null;
|
|
3093
|
+
}
|
|
3094
|
+
return false;
|
|
3095
|
+
};
|
|
3096
|
+
|
|
3044
3097
|
var CCarouselContext = React.createContext({});
|
|
3045
3098
|
var CCarousel = React.forwardRef(function (_a, ref) {
|
|
3046
3099
|
var children = _a.children, _b = _a.activeIndex, activeIndex = _b === void 0 ? 0 : _b, className = _a.className, controls = _a.controls, dark = _a.dark, indicators = _a.indicators, _c = _a.interval, interval = _c === void 0 ? 5000 : _c, onSlid = _a.onSlid, onSlide = _a.onSlide, _d = _a.pause, pause = _d === void 0 ? 'hover' : _d, _e = _a.touch, touch = _e === void 0 ? true : _e, transition = _a.transition, _f = _a.wrap, wrap = _f === void 0 ? true : _f, rest = __rest(_a, ["children", "activeIndex", "className", "controls", "dark", "indicators", "interval", "onSlid", "onSlide", "pause", "touch", "transition", "wrap"]);
|
|
@@ -3817,17 +3870,7 @@ function effect$1(_ref2) {
|
|
|
3817
3870
|
}
|
|
3818
3871
|
}
|
|
3819
3872
|
|
|
3820
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3821
|
-
if (!isHTMLElement(arrowElement)) {
|
|
3822
|
-
console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
|
|
3823
|
-
}
|
|
3824
|
-
}
|
|
3825
|
-
|
|
3826
3873
|
if (!contains(state.elements.popper, arrowElement)) {
|
|
3827
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3828
|
-
console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
|
|
3829
|
-
}
|
|
3830
|
-
|
|
3831
3874
|
return;
|
|
3832
3875
|
}
|
|
3833
3876
|
|
|
@@ -3969,17 +4012,6 @@ function computeStyles(_ref5) {
|
|
|
3969
4012
|
adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
|
3970
4013
|
_options$roundOffsets = options.roundOffsets,
|
|
3971
4014
|
roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
|
3972
|
-
|
|
3973
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3974
|
-
var transitionProperty = getComputedStyle$1(state.elements.popper).transitionProperty || '';
|
|
3975
|
-
|
|
3976
|
-
if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
|
|
3977
|
-
return transitionProperty.indexOf(property) >= 0;
|
|
3978
|
-
})) {
|
|
3979
|
-
console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
|
|
3980
|
-
}
|
|
3981
|
-
}
|
|
3982
|
-
|
|
3983
4015
|
var commonStyles = {
|
|
3984
4016
|
placement: getBasePlacement(state.placement),
|
|
3985
4017
|
variation: getVariation(state.placement),
|
|
@@ -4420,10 +4452,6 @@ function computeAutoPlacement(state, options) {
|
|
|
4420
4452
|
|
|
4421
4453
|
if (allowedPlacements.length === 0) {
|
|
4422
4454
|
allowedPlacements = placements$1;
|
|
4423
|
-
|
|
4424
|
-
if (process.env.NODE_ENV !== "production") {
|
|
4425
|
-
console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
|
|
4426
|
-
}
|
|
4427
4455
|
} // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
|
|
4428
4456
|
|
|
4429
4457
|
|
|
@@ -4975,108 +5003,6 @@ function debounce(fn) {
|
|
|
4975
5003
|
};
|
|
4976
5004
|
}
|
|
4977
5005
|
|
|
4978
|
-
function format(str) {
|
|
4979
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4980
|
-
args[_key - 1] = arguments[_key];
|
|
4981
|
-
}
|
|
4982
|
-
|
|
4983
|
-
return [].concat(args).reduce(function (p, c) {
|
|
4984
|
-
return p.replace(/%s/, c);
|
|
4985
|
-
}, str);
|
|
4986
|
-
}
|
|
4987
|
-
|
|
4988
|
-
var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
|
|
4989
|
-
var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
|
|
4990
|
-
var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
|
|
4991
|
-
function validateModifiers(modifiers) {
|
|
4992
|
-
modifiers.forEach(function (modifier) {
|
|
4993
|
-
[].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
|
|
4994
|
-
.filter(function (value, index, self) {
|
|
4995
|
-
return self.indexOf(value) === index;
|
|
4996
|
-
}).forEach(function (key) {
|
|
4997
|
-
switch (key) {
|
|
4998
|
-
case 'name':
|
|
4999
|
-
if (typeof modifier.name !== 'string') {
|
|
5000
|
-
console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
|
|
5001
|
-
}
|
|
5002
|
-
|
|
5003
|
-
break;
|
|
5004
|
-
|
|
5005
|
-
case 'enabled':
|
|
5006
|
-
if (typeof modifier.enabled !== 'boolean') {
|
|
5007
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
|
|
5008
|
-
}
|
|
5009
|
-
|
|
5010
|
-
break;
|
|
5011
|
-
|
|
5012
|
-
case 'phase':
|
|
5013
|
-
if (modifierPhases.indexOf(modifier.phase) < 0) {
|
|
5014
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
|
|
5015
|
-
}
|
|
5016
|
-
|
|
5017
|
-
break;
|
|
5018
|
-
|
|
5019
|
-
case 'fn':
|
|
5020
|
-
if (typeof modifier.fn !== 'function') {
|
|
5021
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
|
|
5022
|
-
}
|
|
5023
|
-
|
|
5024
|
-
break;
|
|
5025
|
-
|
|
5026
|
-
case 'effect':
|
|
5027
|
-
if (modifier.effect != null && typeof modifier.effect !== 'function') {
|
|
5028
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
|
|
5029
|
-
}
|
|
5030
|
-
|
|
5031
|
-
break;
|
|
5032
|
-
|
|
5033
|
-
case 'requires':
|
|
5034
|
-
if (modifier.requires != null && !Array.isArray(modifier.requires)) {
|
|
5035
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
|
|
5036
|
-
}
|
|
5037
|
-
|
|
5038
|
-
break;
|
|
5039
|
-
|
|
5040
|
-
case 'requiresIfExists':
|
|
5041
|
-
if (!Array.isArray(modifier.requiresIfExists)) {
|
|
5042
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
|
|
5043
|
-
}
|
|
5044
|
-
|
|
5045
|
-
break;
|
|
5046
|
-
|
|
5047
|
-
case 'options':
|
|
5048
|
-
case 'data':
|
|
5049
|
-
break;
|
|
5050
|
-
|
|
5051
|
-
default:
|
|
5052
|
-
console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
|
|
5053
|
-
return "\"" + s + "\"";
|
|
5054
|
-
}).join(', ') + "; but \"" + key + "\" was provided.");
|
|
5055
|
-
}
|
|
5056
|
-
|
|
5057
|
-
modifier.requires && modifier.requires.forEach(function (requirement) {
|
|
5058
|
-
if (modifiers.find(function (mod) {
|
|
5059
|
-
return mod.name === requirement;
|
|
5060
|
-
}) == null) {
|
|
5061
|
-
console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
|
|
5062
|
-
}
|
|
5063
|
-
});
|
|
5064
|
-
});
|
|
5065
|
-
});
|
|
5066
|
-
}
|
|
5067
|
-
|
|
5068
|
-
function uniqueBy(arr, fn) {
|
|
5069
|
-
var identifiers = new Set();
|
|
5070
|
-
return arr.filter(function (item) {
|
|
5071
|
-
var identifier = fn(item);
|
|
5072
|
-
|
|
5073
|
-
if (!identifiers.has(identifier)) {
|
|
5074
|
-
identifiers.add(identifier);
|
|
5075
|
-
return true;
|
|
5076
|
-
}
|
|
5077
|
-
});
|
|
5078
|
-
}
|
|
5079
|
-
|
|
5080
5006
|
function mergeByName(modifiers) {
|
|
5081
5007
|
var merged = modifiers.reduce(function (merged, current) {
|
|
5082
5008
|
var existing = merged[current.name];
|
|
@@ -5092,8 +5018,6 @@ function mergeByName(modifiers) {
|
|
|
5092
5018
|
});
|
|
5093
5019
|
}
|
|
5094
5020
|
|
|
5095
|
-
var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
|
|
5096
|
-
var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
|
|
5097
5021
|
var DEFAULT_OPTIONS = {
|
|
5098
5022
|
placement: 'bottom',
|
|
5099
5023
|
modifiers: [],
|
|
@@ -5155,42 +5079,7 @@ function popperGenerator(generatorOptions) {
|
|
|
5155
5079
|
|
|
5156
5080
|
state.orderedModifiers = orderedModifiers.filter(function (m) {
|
|
5157
5081
|
return m.enabled;
|
|
5158
|
-
});
|
|
5159
|
-
// if one of the modifiers is invalid for any reason
|
|
5160
|
-
|
|
5161
|
-
if (process.env.NODE_ENV !== "production") {
|
|
5162
|
-
var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
|
|
5163
|
-
var name = _ref.name;
|
|
5164
|
-
return name;
|
|
5165
|
-
});
|
|
5166
|
-
validateModifiers(modifiers);
|
|
5167
|
-
|
|
5168
|
-
if (getBasePlacement(state.options.placement) === auto) {
|
|
5169
|
-
var flipModifier = state.orderedModifiers.find(function (_ref2) {
|
|
5170
|
-
var name = _ref2.name;
|
|
5171
|
-
return name === 'flip';
|
|
5172
|
-
});
|
|
5173
|
-
|
|
5174
|
-
if (!flipModifier) {
|
|
5175
|
-
console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
|
|
5176
|
-
}
|
|
5177
|
-
}
|
|
5178
|
-
|
|
5179
|
-
var _getComputedStyle = getComputedStyle$1(popper),
|
|
5180
|
-
marginTop = _getComputedStyle.marginTop,
|
|
5181
|
-
marginRight = _getComputedStyle.marginRight,
|
|
5182
|
-
marginBottom = _getComputedStyle.marginBottom,
|
|
5183
|
-
marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
|
|
5184
|
-
// cause bugs with positioning, so we'll warn the consumer
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
|
|
5188
|
-
return parseFloat(margin);
|
|
5189
|
-
})) {
|
|
5190
|
-
console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
|
-
|
|
5082
|
+
});
|
|
5194
5083
|
runModifierEffects();
|
|
5195
5084
|
return instance.update();
|
|
5196
5085
|
},
|
|
@@ -5210,10 +5099,6 @@ function popperGenerator(generatorOptions) {
|
|
|
5210
5099
|
// anymore
|
|
5211
5100
|
|
|
5212
5101
|
if (!areValidElements(reference, popper)) {
|
|
5213
|
-
if (process.env.NODE_ENV !== "production") {
|
|
5214
|
-
console.error(INVALID_ELEMENT_ERROR);
|
|
5215
|
-
}
|
|
5216
|
-
|
|
5217
5102
|
return;
|
|
5218
5103
|
} // Store the reference and popper rects to be read by modifiers
|
|
5219
5104
|
|
|
@@ -5236,18 +5121,8 @@ function popperGenerator(generatorOptions) {
|
|
|
5236
5121
|
state.orderedModifiers.forEach(function (modifier) {
|
|
5237
5122
|
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
|
5238
5123
|
});
|
|
5239
|
-
var __debug_loops__ = 0;
|
|
5240
5124
|
|
|
5241
5125
|
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
|
5242
|
-
if (process.env.NODE_ENV !== "production") {
|
|
5243
|
-
__debug_loops__ += 1;
|
|
5244
|
-
|
|
5245
|
-
if (__debug_loops__ > 100) {
|
|
5246
|
-
console.error(INFINITE_LOOP_ERROR);
|
|
5247
|
-
break;
|
|
5248
|
-
}
|
|
5249
|
-
}
|
|
5250
|
-
|
|
5251
5126
|
if (state.reset === true) {
|
|
5252
5127
|
state.reset = false;
|
|
5253
5128
|
index = -1;
|
|
@@ -5285,10 +5160,6 @@ function popperGenerator(generatorOptions) {
|
|
|
5285
5160
|
};
|
|
5286
5161
|
|
|
5287
5162
|
if (!areValidElements(reference, popper)) {
|
|
5288
|
-
if (process.env.NODE_ENV !== "production") {
|
|
5289
|
-
console.error(INVALID_ELEMENT_ERROR);
|
|
5290
|
-
}
|
|
5291
|
-
|
|
5292
5163
|
return instance;
|
|
5293
5164
|
}
|
|
5294
5165
|
|
|
@@ -5303,11 +5174,11 @@ function popperGenerator(generatorOptions) {
|
|
|
5303
5174
|
// one.
|
|
5304
5175
|
|
|
5305
5176
|
function runModifierEffects() {
|
|
5306
|
-
state.orderedModifiers.forEach(function (
|
|
5307
|
-
var name =
|
|
5308
|
-
|
|
5309
|
-
options =
|
|
5310
|
-
effect =
|
|
5177
|
+
state.orderedModifiers.forEach(function (_ref) {
|
|
5178
|
+
var name = _ref.name,
|
|
5179
|
+
_ref$options = _ref.options,
|
|
5180
|
+
options = _ref$options === void 0 ? {} : _ref$options,
|
|
5181
|
+
effect = _ref.effect;
|
|
5311
5182
|
|
|
5312
5183
|
if (typeof effect === 'function') {
|
|
5313
5184
|
var cleanupFn = effect({
|
|
@@ -5906,19 +5777,19 @@ var CDropdownMenu = function (_a) {
|
|
|
5906
5777
|
_placement = 'bottom';
|
|
5907
5778
|
}
|
|
5908
5779
|
if (direction === 'dropup') {
|
|
5909
|
-
_placement = 'top-start';
|
|
5780
|
+
_placement = isRTL(dropdownMenuRef.current) ? 'top-end' : 'top-start';
|
|
5910
5781
|
}
|
|
5911
5782
|
if (direction === 'dropup-center') {
|
|
5912
5783
|
_placement = 'top';
|
|
5913
5784
|
}
|
|
5914
5785
|
if (direction === 'dropend') {
|
|
5915
|
-
_placement = 'right-start';
|
|
5786
|
+
_placement = isRTL(dropdownMenuRef.current) ? 'left-start' : 'right-start';
|
|
5916
5787
|
}
|
|
5917
5788
|
if (direction === 'dropstart') {
|
|
5918
|
-
_placement = 'left-start';
|
|
5789
|
+
_placement = isRTL(dropdownMenuRef.current) ? 'right-start' : 'left-start';
|
|
5919
5790
|
}
|
|
5920
5791
|
if (alignment === 'end') {
|
|
5921
|
-
_placement = 'bottom-end';
|
|
5792
|
+
_placement = isRTL(dropdownMenuRef.current) ? 'bottom-start' : 'bottom-end';
|
|
5922
5793
|
}
|
|
5923
5794
|
var dropdownMenuComponent = function (style, ref) { return (React.createElement(CConditionalPortal, { portal: portal !== null && portal !== void 0 ? portal : false },
|
|
5924
5795
|
React.createElement(Component, __assign({ className: classNames('dropdown-menu', {
|
|
@@ -6189,7 +6060,8 @@ var CFormSelect = React.forwardRef(function (_a, ref) {
|
|
|
6189
6060
|
_b), className), size: htmlSize }, rest, { ref: ref }), options
|
|
6190
6061
|
? options.map(function (option, index) {
|
|
6191
6062
|
return (React.createElement("option", __assign({}, (typeof option === 'object' &&
|
|
6192
|
-
option.disabled && { disabled: option.disabled }), (typeof option === 'object' &&
|
|
6063
|
+
option.disabled && { disabled: option.disabled }), (typeof option === 'object' &&
|
|
6064
|
+
option.value !== undefined && { value: option.value }), { key: index }), typeof option === 'string' ? option : option.label));
|
|
6193
6065
|
})
|
|
6194
6066
|
: children)));
|
|
6195
6067
|
});
|
|
@@ -6617,6 +6489,7 @@ var CModal = React.forwardRef(function (_a, ref) {
|
|
|
6617
6489
|
if (backdrop === 'static') {
|
|
6618
6490
|
return setStaticBackdrop(true);
|
|
6619
6491
|
}
|
|
6492
|
+
setVisible(false);
|
|
6620
6493
|
return onClose && onClose();
|
|
6621
6494
|
};
|
|
6622
6495
|
React.useLayoutEffect(function () {
|
|
@@ -7163,6 +7036,7 @@ CProgressBar.propTypes = {
|
|
|
7163
7036
|
};
|
|
7164
7037
|
CProgressBar.displayName = 'CProgressBar';
|
|
7165
7038
|
|
|
7039
|
+
// TODO: update markup and add '.progress-stacked' in v5
|
|
7166
7040
|
var CProgress = React.forwardRef(function (_a, ref) {
|
|
7167
7041
|
var children = _a.children, className = _a.className, height = _a.height, thin = _a.thin, _b = _a.value, value = _b === void 0 ? 0 : _b, white = _a.white, rest = __rest(_a, ["children", "className", "height", "thin", "value", "white"]);
|
|
7168
7042
|
return (React.createElement("div", { className: classNames('progress', {
|
|
@@ -7180,30 +7054,59 @@ CProgress.propTypes = {
|
|
|
7180
7054
|
};
|
|
7181
7055
|
CProgress.displayName = 'CProgress';
|
|
7182
7056
|
|
|
7057
|
+
var getPlacement$1 = function (placement, element) {
|
|
7058
|
+
switch (placement) {
|
|
7059
|
+
case 'right': {
|
|
7060
|
+
return isRTL(element) ? 'left' : 'right';
|
|
7061
|
+
}
|
|
7062
|
+
case 'left': {
|
|
7063
|
+
return isRTL(element) ? 'right' : 'left';
|
|
7064
|
+
}
|
|
7065
|
+
default: {
|
|
7066
|
+
return placement;
|
|
7067
|
+
}
|
|
7068
|
+
}
|
|
7069
|
+
};
|
|
7183
7070
|
var CPopover = function (_a) {
|
|
7184
7071
|
var children = _a.children, className = _a.className, content = _a.content, _b = _a.offset, offset = _b === void 0 ? [0, 8] : _b, onHide = _a.onHide, onShow = _a.onShow, _c = _a.placement, placement = _c === void 0 ? 'top' : _c, title = _a.title, _d = _a.trigger, trigger = _d === void 0 ? 'click' : _d, visible = _a.visible, rest = __rest(_a, ["children", "className", "content", "offset", "onHide", "onShow", "placement", "title", "trigger", "visible"]);
|
|
7072
|
+
var popoverRef = React.useRef(null);
|
|
7073
|
+
var togglerRef = React.useRef(null);
|
|
7074
|
+
var popper = React.useRef();
|
|
7185
7075
|
var _e = React.useState(visible), _visible = _e[0], setVisible = _e[1];
|
|
7186
|
-
var popoverRef = React.useRef();
|
|
7187
|
-
var _f = React.useState(null), referenceElement = _f[0], setReferenceElement = _f[1];
|
|
7188
|
-
var _g = React.useState(null), popperElement = _g[0], setPopperElement = _g[1];
|
|
7189
|
-
var _h = React.useState(null), arrowElement = _h[0], setArrowElement = _h[1];
|
|
7190
|
-
var _j = usePopper(referenceElement, popperElement, {
|
|
7191
|
-
modifiers: [
|
|
7192
|
-
{ name: 'arrow', options: { element: arrowElement } },
|
|
7193
|
-
{
|
|
7194
|
-
name: 'offset',
|
|
7195
|
-
options: {
|
|
7196
|
-
offset: offset,
|
|
7197
|
-
},
|
|
7198
|
-
},
|
|
7199
|
-
],
|
|
7200
|
-
placement: placement,
|
|
7201
|
-
}), styles = _j.styles, attributes = _j.attributes;
|
|
7202
7076
|
React.useEffect(function () {
|
|
7203
7077
|
setVisible(visible);
|
|
7204
7078
|
}, [visible]);
|
|
7079
|
+
React.useEffect(function () {
|
|
7080
|
+
if (_visible) {
|
|
7081
|
+
initPopper();
|
|
7082
|
+
}
|
|
7083
|
+
return function () {
|
|
7084
|
+
destroyPopper();
|
|
7085
|
+
};
|
|
7086
|
+
}, [_visible]);
|
|
7087
|
+
var initPopper = function () {
|
|
7088
|
+
if (togglerRef.current && popoverRef.current) {
|
|
7089
|
+
popper.current = createPopper(togglerRef.current, popoverRef.current, {
|
|
7090
|
+
modifiers: [
|
|
7091
|
+
{
|
|
7092
|
+
name: 'offset',
|
|
7093
|
+
options: {
|
|
7094
|
+
offset: offset,
|
|
7095
|
+
},
|
|
7096
|
+
},
|
|
7097
|
+
],
|
|
7098
|
+
placement: getPlacement$1(placement, togglerRef.current),
|
|
7099
|
+
});
|
|
7100
|
+
}
|
|
7101
|
+
};
|
|
7102
|
+
var destroyPopper = function () {
|
|
7103
|
+
if (popper.current) {
|
|
7104
|
+
popper.current.destroy();
|
|
7105
|
+
}
|
|
7106
|
+
popper.current = undefined;
|
|
7107
|
+
};
|
|
7205
7108
|
return (React.createElement(React.Fragment, null,
|
|
7206
|
-
React.cloneElement(children, __assign(__assign(__assign({ ref:
|
|
7109
|
+
React.cloneElement(children, __assign(__assign(__assign({ ref: togglerRef }, ((trigger === 'click' || trigger.includes('click')) && {
|
|
7207
7110
|
onClick: function () { return setVisible(!_visible); },
|
|
7208
7111
|
})), ((trigger === 'focus' || trigger.includes('focus')) && {
|
|
7209
7112
|
onFocus: function () { return setVisible(true); },
|
|
@@ -7216,10 +7119,12 @@ var CPopover = function (_a) {
|
|
|
7216
7119
|
ReactDOM.createPortal(React.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: popoverRef, onEnter: onShow, onExit: onHide, timeout: {
|
|
7217
7120
|
enter: 0,
|
|
7218
7121
|
exit: 200,
|
|
7219
|
-
}, unmountOnExit: true }, function (state) { return (React.createElement("div", __assign({ className: classNames('popover', "bs-popover-".concat(placement
|
|
7122
|
+
}, unmountOnExit: true }, function (state) { return (React.createElement("div", __assign({ className: classNames('popover', "bs-popover-".concat(getPlacement$1(placement, togglerRef.current)
|
|
7123
|
+
.replace('left', 'start')
|
|
7124
|
+
.replace('right', 'end')), 'fade', {
|
|
7220
7125
|
show: state === 'entered',
|
|
7221
|
-
}, className), ref:
|
|
7222
|
-
React.createElement("div", {
|
|
7126
|
+
}, className), ref: popoverRef, role: "tooltip" }, rest),
|
|
7127
|
+
React.createElement("div", { "data-popper-arrow": true, className: "popover-arrow" }),
|
|
7223
7128
|
React.createElement("div", { className: "popover-header" }, title),
|
|
7224
7129
|
React.createElement("div", { className: "popover-body" }, content))); }), document.body)));
|
|
7225
7130
|
};
|
|
@@ -7264,7 +7169,7 @@ var CSidebar = React.forwardRef(function (_a, ref) {
|
|
|
7264
7169
|
var _a, _b;
|
|
7265
7170
|
sidebarRef.current && setMobile(isOnMobile(sidebarRef.current));
|
|
7266
7171
|
sidebarRef.current && setInViewport(isInViewport(sidebarRef.current));
|
|
7267
|
-
window.addEventListener('resize',
|
|
7172
|
+
window.addEventListener('resize', handleResize);
|
|
7268
7173
|
window.addEventListener('mouseup', handleClickOutside);
|
|
7269
7174
|
window.addEventListener('keyup', handleKeyup);
|
|
7270
7175
|
(_a = sidebarRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseup', handleOnClick);
|
|
@@ -7273,7 +7178,7 @@ var CSidebar = React.forwardRef(function (_a, ref) {
|
|
|
7273
7178
|
});
|
|
7274
7179
|
return function () {
|
|
7275
7180
|
var _a, _b;
|
|
7276
|
-
window.removeEventListener('resize',
|
|
7181
|
+
window.removeEventListener('resize', handleResize);
|
|
7277
7182
|
window.removeEventListener('mouseup', handleClickOutside);
|
|
7278
7183
|
window.removeEventListener('keyup', handleKeyup);
|
|
7279
7184
|
(_a = sidebarRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', handleOnClick);
|
|
@@ -7382,8 +7287,12 @@ CSidebarHeader.propTypes = {
|
|
|
7382
7287
|
CSidebarHeader.displayName = 'CSidebarHeader';
|
|
7383
7288
|
|
|
7384
7289
|
var CSpinner = React.forwardRef(function (_a, ref) {
|
|
7385
|
-
var
|
|
7386
|
-
|
|
7290
|
+
var _b;
|
|
7291
|
+
var className = _a.className, color = _a.color, _c = _a.component, Component = _c === void 0 ? 'div' : _c, size = _a.size, _d = _a.variant, variant = _d === void 0 ? 'border' : _d, _e = _a.visuallyHiddenLabel, visuallyHiddenLabel = _e === void 0 ? 'Loading...' : _e, rest = __rest(_a, ["className", "color", "component", "size", "variant", "visuallyHiddenLabel"]);
|
|
7292
|
+
return (React.createElement(Component, __assign({ className: classNames("spinner-".concat(variant), (_b = {},
|
|
7293
|
+
_b["spinner-".concat(variant, "-").concat(size)] = size,
|
|
7294
|
+
_b["text-".concat(color)] = color,
|
|
7295
|
+
_b), className), role: "status" }, rest, { ref: ref }),
|
|
7387
7296
|
React.createElement("span", { className: "visually-hidden" }, visuallyHiddenLabel)));
|
|
7388
7297
|
});
|
|
7389
7298
|
CSpinner.propTypes = {
|
|
@@ -7554,7 +7463,8 @@ var CTable = React.forwardRef(function (_a, ref) {
|
|
|
7554
7463
|
React.createElement(CTableRow, null, columns.map(function (column, index) { return (React.createElement(CTableHeaderCell, __assign({}, (column._props && __assign({}, column._props)), (column._style && { style: __assign({}, column._style) }), { key: index }), getColumnLabel(column))); })))),
|
|
7555
7464
|
items && (React.createElement(CTableBody, null, items.map(function (item, index) { return (React.createElement(CTableRow, __assign({}, (item._props && __assign({}, item._props)), { key: index }), columnNames &&
|
|
7556
7465
|
columnNames.map(function (colName, index) {
|
|
7557
|
-
|
|
7466
|
+
// eslint-disable-next-line unicorn/no-negated-condition
|
|
7467
|
+
return item[colName] !== undefined ? (React.createElement(CTableDataCell, __assign({}, (item._cellProps && __assign(__assign({}, (item._cellProps['all'] && __assign({}, item._cellProps['all']))), (item._cellProps[colName] && __assign({}, item._cellProps[colName])))), { key: index }), item[colName])) : null;
|
|
7558
7468
|
}))); }))),
|
|
7559
7469
|
children,
|
|
7560
7470
|
footer && (React.createElement(CTableFoot, __assign({}, tableFootProps),
|
|
@@ -7752,30 +7662,59 @@ CToaster.propTypes = {
|
|
|
7752
7662
|
};
|
|
7753
7663
|
CToaster.displayName = 'CToaster';
|
|
7754
7664
|
|
|
7665
|
+
var getPlacement = function (placement, element) {
|
|
7666
|
+
switch (placement) {
|
|
7667
|
+
case 'right': {
|
|
7668
|
+
return isRTL(element) ? 'left' : 'right';
|
|
7669
|
+
}
|
|
7670
|
+
case 'left': {
|
|
7671
|
+
return isRTL(element) ? 'right' : 'left';
|
|
7672
|
+
}
|
|
7673
|
+
default: {
|
|
7674
|
+
return placement;
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
};
|
|
7755
7678
|
var CTooltip = function (_a) {
|
|
7756
|
-
var children = _a.children, className = _a.className, content = _a.content, _b = _a.offset, offset = _b === void 0 ? [0,
|
|
7757
|
-
var tooltipRef = React.useRef();
|
|
7679
|
+
var children = _a.children, className = _a.className, content = _a.content, _b = _a.offset, offset = _b === void 0 ? [0, 6] : _b, onHide = _a.onHide, onShow = _a.onShow, _c = _a.placement, placement = _c === void 0 ? 'top' : _c, _d = _a.trigger, trigger = _d === void 0 ? 'hover' : _d, visible = _a.visible, rest = __rest(_a, ["children", "className", "content", "offset", "onHide", "onShow", "placement", "trigger", "visible"]);
|
|
7680
|
+
var tooltipRef = React.useRef(null);
|
|
7681
|
+
var togglerRef = React.useRef(null);
|
|
7682
|
+
var popper = React.useRef();
|
|
7758
7683
|
var _e = React.useState(visible), _visible = _e[0], setVisible = _e[1];
|
|
7759
|
-
var _f = React.useState(null), referenceElement = _f[0], setReferenceElement = _f[1];
|
|
7760
|
-
var _g = React.useState(null), popperElement = _g[0], setPopperElement = _g[1];
|
|
7761
|
-
var _h = React.useState(null), arrowElement = _h[0], setArrowElement = _h[1];
|
|
7762
|
-
var _j = usePopper(referenceElement, popperElement, {
|
|
7763
|
-
modifiers: [
|
|
7764
|
-
{ name: 'arrow', options: { element: arrowElement } },
|
|
7765
|
-
{
|
|
7766
|
-
name: 'offset',
|
|
7767
|
-
options: {
|
|
7768
|
-
offset: offset,
|
|
7769
|
-
},
|
|
7770
|
-
},
|
|
7771
|
-
],
|
|
7772
|
-
placement: placement,
|
|
7773
|
-
}), styles = _j.styles, attributes = _j.attributes;
|
|
7774
7684
|
React.useEffect(function () {
|
|
7775
7685
|
setVisible(visible);
|
|
7776
7686
|
}, [visible]);
|
|
7687
|
+
React.useEffect(function () {
|
|
7688
|
+
if (_visible) {
|
|
7689
|
+
initPopper();
|
|
7690
|
+
}
|
|
7691
|
+
return function () {
|
|
7692
|
+
destroyPopper();
|
|
7693
|
+
};
|
|
7694
|
+
}, [_visible]);
|
|
7695
|
+
var initPopper = function () {
|
|
7696
|
+
if (togglerRef.current && tooltipRef.current) {
|
|
7697
|
+
popper.current = createPopper(togglerRef.current, tooltipRef.current, {
|
|
7698
|
+
modifiers: [
|
|
7699
|
+
{
|
|
7700
|
+
name: 'offset',
|
|
7701
|
+
options: {
|
|
7702
|
+
offset: offset,
|
|
7703
|
+
},
|
|
7704
|
+
},
|
|
7705
|
+
],
|
|
7706
|
+
placement: getPlacement(placement, togglerRef.current),
|
|
7707
|
+
});
|
|
7708
|
+
}
|
|
7709
|
+
};
|
|
7710
|
+
var destroyPopper = function () {
|
|
7711
|
+
if (popper.current) {
|
|
7712
|
+
popper.current.destroy();
|
|
7713
|
+
}
|
|
7714
|
+
popper.current = undefined;
|
|
7715
|
+
};
|
|
7777
7716
|
return (React.createElement(React.Fragment, null,
|
|
7778
|
-
React.cloneElement(children, __assign(__assign(__assign({ ref:
|
|
7717
|
+
React.cloneElement(children, __assign(__assign(__assign({ ref: togglerRef }, ((trigger === 'click' || trigger.includes('click')) && {
|
|
7779
7718
|
onClick: function () { return setVisible(!_visible); },
|
|
7780
7719
|
})), ((trigger === 'focus' || trigger.includes('focus')) && {
|
|
7781
7720
|
onFocus: function () { return setVisible(true); },
|
|
@@ -7785,13 +7724,15 @@ var CTooltip = function (_a) {
|
|
|
7785
7724
|
onMouseLeave: function () { return setVisible(false); },
|
|
7786
7725
|
}))),
|
|
7787
7726
|
typeof window !== 'undefined' &&
|
|
7788
|
-
ReactDOM.createPortal(React.createElement(Transition$1, { in: _visible, mountOnEnter: true,
|
|
7727
|
+
ReactDOM.createPortal(React.createElement(Transition$1, { in: _visible, mountOnEnter: true, onEnter: onShow, onExit: onHide, timeout: {
|
|
7789
7728
|
enter: 0,
|
|
7790
7729
|
exit: 200,
|
|
7791
|
-
}, unmountOnExit: true }, function (state) { return (React.createElement("div", __assign({ className: classNames('tooltip', "bs-
|
|
7730
|
+
}, unmountOnExit: true }, function (state) { return (React.createElement("div", __assign({ className: classNames('tooltip', "bs-tooltip-".concat(getPlacement(placement, togglerRef.current)
|
|
7731
|
+
.replace('left', 'start')
|
|
7732
|
+
.replace('right', 'end')), 'fade', {
|
|
7792
7733
|
show: state === 'entered',
|
|
7793
|
-
}, className), ref:
|
|
7794
|
-
React.createElement("div", {
|
|
7734
|
+
}, className), ref: tooltipRef, role: "tooltip" }, rest),
|
|
7735
|
+
React.createElement("div", { "data-popper-arrow": true, className: "tooltip-arrow" }),
|
|
7795
7736
|
React.createElement("div", { className: "tooltip-inner" }, content))); }), document.body)));
|
|
7796
7737
|
};
|
|
7797
7738
|
CTooltip.propTypes = {
|
|
@@ -8059,4 +8000,6 @@ exports.CWidgetStatsC = CWidgetStatsC;
|
|
|
8059
8000
|
exports.CWidgetStatsD = CWidgetStatsD;
|
|
8060
8001
|
exports.CWidgetStatsE = CWidgetStatsE;
|
|
8061
8002
|
exports.CWidgetStatsF = CWidgetStatsF;
|
|
8003
|
+
exports.useColorModes = useColorModes;
|
|
8004
|
+
exports.useForkedRef = useForkedRef;
|
|
8062
8005
|
//# sourceMappingURL=index.js.map
|