@oanda/labs-widget-common 1.0.252 → 1.0.254
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/CHANGELOG.md +774 -62520
- package/dist/main/components/style.css +1 -1
- package/dist/module/chart/BaseChart.js +15 -7
- package/dist/module/chart/BaseChart.js.map +1 -1
- package/dist/module/chart/formatters.js +12 -3
- package/dist/module/chart/formatters.js.map +1 -1
- package/dist/module/chart/getGridLines.js +16 -9
- package/dist/module/chart/getGridLines.js.map +1 -1
- package/dist/module/chart/getTheme.js +38 -31
- package/dist/module/chart/getTheme.js.map +1 -1
- package/dist/module/chart/getZoomControls.js +12 -5
- package/dist/module/chart/getZoomControls.js.map +1 -1
- package/dist/module/chart/index.js +82 -7
- package/dist/module/chart/index.js.map +1 -1
- package/dist/module/chart/sharedOptions.js +11 -4
- package/dist/module/chart/sharedOptions.js.map +1 -1
- package/dist/module/chart/types.js +5 -1
- package/dist/module/components/Button/Button.js +18 -11
- package/dist/module/components/Button/Button.js.map +1 -1
- package/dist/module/components/Button/index.js +27 -2
- package/dist/module/components/Button/index.js.map +1 -1
- package/dist/module/components/Button/types.js +8 -2
- package/dist/module/components/Button/types.js.map +1 -1
- package/dist/module/components/Card/Card.js +24 -16
- package/dist/module/components/Card/Card.js.map +1 -1
- package/dist/module/components/Card/CardHeader.js +21 -14
- package/dist/module/components/Card/CardHeader.js.map +1 -1
- package/dist/module/components/Card/index.js +38 -3
- package/dist/module/components/Card/index.js.map +1 -1
- package/dist/module/components/Card/rows/DailyChangeCardRow.js +15 -7
- package/dist/module/components/Card/rows/DailyChangeCardRow.js.map +1 -1
- package/dist/module/components/Card/rows/LineChartCardRow.js +17 -10
- package/dist/module/components/Card/rows/LineChartCardRow.js.map +1 -1
- package/dist/module/components/Card/rows/PriceCardRow.js +16 -8
- package/dist/module/components/Card/rows/PriceCardRow.js.map +1 -1
- package/dist/module/components/Card/rows/SentimentCardRow.js +18 -10
- package/dist/module/components/Card/rows/SentimentCardRow.js.map +1 -1
- package/dist/module/components/Card/rows/SpreadCardRow.js +15 -7
- package/dist/module/components/Card/rows/SpreadCardRow.js.map +1 -1
- package/dist/module/components/Card/rows/index.js +60 -5
- package/dist/module/components/Card/rows/index.js.map +1 -1
- package/dist/module/components/Card/types.js +5 -1
- package/dist/module/components/Disclaimer/Disclaimer.js +32 -24
- package/dist/module/components/Disclaimer/Disclaimer.js.map +1 -1
- package/dist/module/components/Disclaimer/index.js +16 -1
- package/dist/module/components/Disclaimer/index.js.map +1 -1
- package/dist/module/components/Error/Error.js +27 -18
- package/dist/module/components/Error/Error.js.map +1 -1
- package/dist/module/components/Error/index.js +16 -1
- package/dist/module/components/Error/index.js.map +1 -1
- package/dist/module/components/InfoBox/InfoBox.js +10 -3
- package/dist/module/components/InfoBox/InfoBox.js.map +1 -1
- package/dist/module/components/InfoBox/index.js +27 -2
- package/dist/module/components/InfoBox/index.js.map +1 -1
- package/dist/module/components/InfoBox/types.js +5 -1
- package/dist/module/components/Input/NumberInput.js +21 -13
- package/dist/module/components/Input/NumberInput.js.map +1 -1
- package/dist/module/components/Input/index.js +38 -3
- package/dist/module/components/Input/index.js.map +1 -1
- package/dist/module/components/Input/types.js +5 -1
- package/dist/module/components/Input/useNumberFormat.js +11 -4
- package/dist/module/components/Input/useNumberFormat.js.map +1 -1
- package/dist/module/components/InstrumentRate/InstrumentRate.js +37 -30
- package/dist/module/components/InstrumentRate/InstrumentRate.js.map +1 -1
- package/dist/module/components/InstrumentRate/InstrumentRateWithChart.js +19 -13
- package/dist/module/components/InstrumentRate/InstrumentRateWithChart.js.map +1 -1
- package/dist/module/components/InstrumentRate/index.js +38 -3
- package/dist/module/components/InstrumentRate/index.js.map +1 -1
- package/dist/module/components/InstrumentRate/types.js +5 -1
- package/dist/module/components/InstrumentRate/utils.js +13 -6
- package/dist/module/components/InstrumentRate/utils.js.map +1 -1
- package/dist/module/components/Label/Label.js +12 -6
- package/dist/module/components/Label/Label.js.map +1 -1
- package/dist/module/components/Label/index.js +16 -1
- package/dist/module/components/Label/index.js.map +1 -1
- package/dist/module/components/LabelWrapper/LabelWrapper.js +24 -17
- package/dist/module/components/LabelWrapper/LabelWrapper.js.map +1 -1
- package/dist/module/components/LabelWrapper/index.js +27 -2
- package/dist/module/components/LabelWrapper/index.js.map +1 -1
- package/dist/module/components/LabelWrapper/types.js +7 -1
- package/dist/module/components/LabelWrapper/types.js.map +1 -1
- package/dist/module/components/LastUpdated/LastUpdated.js +13 -6
- package/dist/module/components/LastUpdated/LastUpdated.js.map +1 -1
- package/dist/module/components/LastUpdated/index.js +27 -2
- package/dist/module/components/LastUpdated/index.js.map +1 -1
- package/dist/module/components/LastUpdated/types.js +5 -1
- package/dist/module/components/LineChart/LineChart.js +18 -11
- package/dist/module/components/LineChart/LineChart.js.map +1 -1
- package/dist/module/components/LineChart/LineChartWithData.js +14 -8
- package/dist/module/components/LineChart/LineChartWithData.js.map +1 -1
- package/dist/module/components/LineChart/index.js +49 -4
- package/dist/module/components/LineChart/index.js.map +1 -1
- package/dist/module/components/LineChart/types.js +7 -1
- package/dist/module/components/LineChart/types.js.map +1 -1
- package/dist/module/components/LineChart/utils.js +16 -8
- package/dist/module/components/LineChart/utils.js.map +1 -1
- package/dist/module/components/Loader/Loader.js +18 -11
- package/dist/module/components/Loader/Loader.js.map +1 -1
- package/dist/module/components/Loader/index.js +27 -2
- package/dist/module/components/Loader/index.js.map +1 -1
- package/dist/module/components/Loader/types.js +7 -1
- package/dist/module/components/Loader/types.js.map +1 -1
- package/dist/module/components/Pagination/Pagination.js +40 -33
- package/dist/module/components/Pagination/Pagination.js.map +1 -1
- package/dist/module/components/Pagination/index.js +27 -2
- package/dist/module/components/Pagination/index.js.map +1 -1
- package/dist/module/components/Pagination/types.js +5 -1
- package/dist/module/components/Pagination/utils.js +8 -1
- package/dist/module/components/Pagination/utils.js.map +1 -1
- package/dist/module/components/Price/Price.js +23 -15
- package/dist/module/components/Price/Price.js.map +1 -1
- package/dist/module/components/Price/index.js +27 -2
- package/dist/module/components/Price/index.js.map +1 -1
- package/dist/module/components/Price/types.js +7 -1
- package/dist/module/components/Price/types.js.map +1 -1
- package/dist/module/components/SearchInput/SearchInput.js +12 -5
- package/dist/module/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/module/components/SearchInput/index.js +27 -2
- package/dist/module/components/SearchInput/index.js.map +1 -1
- package/dist/module/components/SearchInput/types.js +5 -1
- package/dist/module/components/Select/Select.js +44 -36
- package/dist/module/components/Select/Select.js.map +1 -1
- package/dist/module/components/Select/index.js +27 -2
- package/dist/module/components/Select/index.js.map +1 -1
- package/dist/module/components/Select/types.js +5 -1
- package/dist/module/components/Sentiment/Sentiment.js +28 -20
- package/dist/module/components/Sentiment/Sentiment.js.map +1 -1
- package/dist/module/components/Sentiment/SentimentError.js +17 -10
- package/dist/module/components/Sentiment/SentimentError.js.map +1 -1
- package/dist/module/components/Sentiment/SentimentLoader.js +17 -10
- package/dist/module/components/Sentiment/SentimentLoader.js.map +1 -1
- package/dist/module/components/Sentiment/index.js +38 -3
- package/dist/module/components/Sentiment/index.js.map +1 -1
- package/dist/module/components/Sentiment/types.js +7 -1
- package/dist/module/components/Sentiment/types.js.map +1 -1
- package/dist/module/components/Sentiment/utils.js +7 -1
- package/dist/module/components/Sentiment/utils.js.map +1 -1
- package/dist/module/components/Spinner/Spinner.js +18 -10
- package/dist/module/components/Spinner/Spinner.js.map +1 -1
- package/dist/module/components/Spinner/index.js +27 -2
- package/dist/module/components/Spinner/index.js.map +1 -1
- package/dist/module/components/Spinner/types.js +7 -1
- package/dist/module/components/Spinner/types.js.map +1 -1
- package/dist/module/components/Switch/Switch.js +26 -18
- package/dist/module/components/Switch/Switch.js.map +1 -1
- package/dist/module/components/Switch/SwitchItem.js +18 -10
- package/dist/module/components/Switch/SwitchItem.js.map +1 -1
- package/dist/module/components/Switch/constants.js +7 -1
- package/dist/module/components/Switch/constants.js.map +1 -1
- package/dist/module/components/Switch/index.js +16 -1
- package/dist/module/components/Switch/index.js.map +1 -1
- package/dist/module/components/Switch/types.js +5 -1
- package/dist/module/components/Table/Table.js +21 -14
- package/dist/module/components/Table/Table.js.map +1 -1
- package/dist/module/components/Table/TableCell.js +19 -12
- package/dist/module/components/Table/TableCell.js.map +1 -1
- package/dist/module/components/Table/TableHeader.js +20 -13
- package/dist/module/components/Table/TableHeader.js.map +1 -1
- package/dist/module/components/Table/TableRow.js +15 -8
- package/dist/module/components/Table/TableRow.js.map +1 -1
- package/dist/module/components/Table/columns/ChartColumn.js +20 -12
- package/dist/module/components/Table/columns/ChartColumn.js.map +1 -1
- package/dist/module/components/Table/columns/DailyChangeColumn.js +15 -7
- package/dist/module/components/Table/columns/DailyChangeColumn.js.map +1 -1
- package/dist/module/components/Table/columns/InstrumentColumn.js +19 -11
- package/dist/module/components/Table/columns/InstrumentColumn.js.map +1 -1
- package/dist/module/components/Table/columns/PriceColumn.js +16 -8
- package/dist/module/components/Table/columns/PriceColumn.js.map +1 -1
- package/dist/module/components/Table/columns/SentimentColumn.js +16 -8
- package/dist/module/components/Table/columns/SentimentColumn.js.map +1 -1
- package/dist/module/components/Table/columns/SpreadColumn.js +17 -9
- package/dist/module/components/Table/columns/SpreadColumn.js.map +1 -1
- package/dist/module/components/Table/columns/index.js +71 -6
- package/dist/module/components/Table/columns/index.js.map +1 -1
- package/dist/module/components/Table/index.js +60 -5
- package/dist/module/components/Table/index.js.map +1 -1
- package/dist/module/components/Table/types.js +5 -1
- package/dist/module/components/TableWidget/CardRecordRow.js +22 -14
- package/dist/module/components/TableWidget/CardRecordRow.js.map +1 -1
- package/dist/module/components/TableWidget/CardRenderer.js +20 -12
- package/dist/module/components/TableWidget/CardRenderer.js.map +1 -1
- package/dist/module/components/TableWidget/Cards.js +14 -6
- package/dist/module/components/TableWidget/Cards.js.map +1 -1
- package/dist/module/components/TableWidget/ColumnRenderer.js +42 -34
- package/dist/module/components/TableWidget/ColumnRenderer.js.map +1 -1
- package/dist/module/components/TableWidget/DataRecordRow.js +20 -12
- package/dist/module/components/TableWidget/DataRecordRow.js.map +1 -1
- package/dist/module/components/TableWidget/TableWidget.js +34 -26
- package/dist/module/components/TableWidget/TableWidget.js.map +1 -1
- package/dist/module/components/TableWidget/index.js +27 -2
- package/dist/module/components/TableWidget/index.js.map +1 -1
- package/dist/module/components/TableWidget/types.js +5 -1
- package/dist/module/components/TableWidget/utils.js +12 -4
- package/dist/module/components/TableWidget/utils.js.map +1 -1
- package/dist/module/components/Tabs/Tab.js +16 -10
- package/dist/module/components/Tabs/Tab.js.map +1 -1
- package/dist/module/components/Tabs/Tabs.js +11 -5
- package/dist/module/components/Tabs/Tabs.js.map +1 -1
- package/dist/module/components/Tabs/index.js +16 -1
- package/dist/module/components/Tabs/index.js.map +1 -1
- package/dist/module/components/Tabs/types.js +5 -1
- package/dist/module/components/TextInput/TextInput.js +17 -10
- package/dist/module/components/TextInput/TextInput.js.map +1 -1
- package/dist/module/components/TextInput/index.js +16 -1
- package/dist/module/components/TextInput/index.js.map +1 -1
- package/dist/module/components/TimeUnitSwitch/TimeUnitSelect.js +14 -7
- package/dist/module/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/module/components/TimeUnitSwitch/TimeUnitSwitch.js +22 -15
- package/dist/module/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/module/components/TimeUnitSwitch/index.js +16 -1
- package/dist/module/components/TimeUnitSwitch/index.js.map +1 -1
- package/dist/module/components/TimeUnitSwitch/types.js +5 -1
- package/dist/module/components/Tooltip/Tooltip.js +11 -4
- package/dist/module/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/module/components/Tooltip/index.js +27 -2
- package/dist/module/components/Tooltip/index.js.map +1 -1
- package/dist/module/components/Tooltip/types.js +5 -1
- package/dist/module/components/Truncate/Truncate.js +18 -11
- package/dist/module/components/Truncate/Truncate.js.map +1 -1
- package/dist/module/components/Truncate/index.js +27 -2
- package/dist/module/components/Truncate/index.js.map +1 -1
- package/dist/module/components/Truncate/types.js +5 -1
- package/dist/module/components/WidgetWrapper/WidgetWrapper.js +14 -6
- package/dist/module/components/WidgetWrapper/WidgetWrapper.js.map +1 -1
- package/dist/module/components/WidgetWrapper/index.js +16 -1
- package/dist/module/components/WidgetWrapper/index.js.map +1 -1
- package/dist/module/components/constant.js +8 -2
- package/dist/module/components/constant.js.map +1 -1
- package/dist/module/components/index.js +292 -27
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/style.css +1 -1
- package/dist/module/constants/index.js +13 -7
- package/dist/module/constants/index.js.map +1 -1
- package/dist/module/fonts/index.js +27 -4
- package/dist/module/fonts/index.js.map +1 -1
- package/dist/module/hooks/index.js +71 -6
- package/dist/module/hooks/index.js.map +1 -1
- package/dist/module/hooks/useFetchCombinedDataRecords.js +14 -7
- package/dist/module/hooks/useFetchCombinedDataRecords.js.map +1 -1
- package/dist/module/hooks/useLiveRates.js +12 -5
- package/dist/module/hooks/useLiveRates.js.map +1 -1
- package/dist/module/hooks/useLiveRatesMessage.js +26 -19
- package/dist/module/hooks/useLiveRatesMessage.js.map +1 -1
- package/dist/module/hooks/useLiveRatesQuery.js +12 -5
- package/dist/module/hooks/useLiveRatesQuery.js.map +1 -1
- package/dist/module/hooks/useRecords.js +13 -7
- package/dist/module/hooks/useRecords.js.map +1 -1
- package/dist/module/hooks/useVisibleLiveDataRecord.js +16 -9
- package/dist/module/hooks/useVisibleLiveDataRecord.js.map +1 -1
- package/dist/module/images/index.js +111 -16
- package/dist/module/images/index.js.map +1 -1
- package/dist/module/index.js +126 -11
- package/dist/module/index.js.map +1 -1
- package/dist/module/providers/ConditionalProvider.js +11 -3
- package/dist/module/providers/ConditionalProvider.js.map +1 -1
- package/dist/module/providers/Layout/LayoutContext.js +12 -4
- package/dist/module/providers/Layout/LayoutContext.js.map +1 -1
- package/dist/module/providers/Layout/LayoutProvider.js +30 -22
- package/dist/module/providers/Layout/LayoutProvider.js.map +1 -1
- package/dist/module/providers/Layout/LayoutProvider.test.js +61 -58
- package/dist/module/providers/Layout/LayoutProvider.test.js.map +1 -1
- package/dist/module/providers/Layout/index.js +27 -2
- package/dist/module/providers/Layout/index.js.map +1 -1
- package/dist/module/providers/LiveRates/LiveRatesContext.js +11 -4
- package/dist/module/providers/LiveRates/LiveRatesContext.js.map +1 -1
- package/dist/module/providers/LiveRates/LiveRatesProvider.js +37 -29
- package/dist/module/providers/LiveRates/LiveRatesProvider.js.map +1 -1
- package/dist/module/providers/LiveRates/index.js +27 -2
- package/dist/module/providers/LiveRates/index.js.map +1 -1
- package/dist/module/providers/Widget/WidgetProvider.js +26 -18
- package/dist/module/providers/Widget/WidgetProvider.js.map +1 -1
- package/dist/module/providers/Widget/index.js +16 -1
- package/dist/module/providers/Widget/index.js.map +1 -1
- package/dist/module/providers/index.js +38 -3
- package/dist/module/providers/index.js.map +1 -1
- package/dist/module/tailwind/cn.js +11 -4
- package/dist/module/tailwind/cn.js.map +1 -1
- package/dist/module/tailwind/colors.js +9 -3
- package/dist/module/tailwind/colors.js.map +1 -1
- package/dist/module/tailwind/index.js +39 -3
- package/dist/module/tailwind/index.js.map +1 -1
- package/dist/module/tailwind/preset.js +11 -5
- package/dist/module/tailwind/preset.js.map +1 -1
- package/dist/module/tailwind/themes/background.js +14 -8
- package/dist/module/tailwind/themes/background.js.map +1 -1
- package/dist/module/tailwind/themes/border.js +10 -4
- package/dist/module/tailwind/themes/border.js.map +1 -1
- package/dist/module/tailwind/themes/index.js +12 -6
- package/dist/module/tailwind/themes/index.js.map +1 -1
- package/dist/module/tailwind/themes/text.js +18 -12
- package/dist/module/tailwind/themes/text.js.map +1 -1
- package/dist/module/tailwind/themes/themeColors.js +26 -20
- package/dist/module/tailwind/themes/themeColors.js.map +1 -1
- package/dist/module/tailwind/types.js +5 -1
- package/dist/module/tailwind/utils.js +8 -1
- package/dist/module/tailwind/utils.js.map +1 -1
- package/dist/module/testUtils/index.js +15 -7
- package/dist/module/testUtils/index.js.map +1 -1
- package/dist/module/translations/index.js +15 -8
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js +7 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/module/types/dataTypes.js +7 -1
- package/dist/module/types/dataTypes.js.map +1 -1
- package/dist/module/types/index.js +36 -4
- package/dist/module/types/index.js.map +1 -1
- package/dist/module/types/liveRatesTypes.js +5 -1
- package/dist/module/utils/dateUtils.js +9 -1
- package/dist/module/utils/dateUtils.js.map +1 -1
- package/dist/module/utils/getLocale.js +20 -13
- package/dist/module/utils/getLocale.js.map +1 -1
- package/dist/module/utils/index.js +38 -3
- package/dist/module/utils/index.js.map +1 -1
- package/dist/module/utils/liveRates/buildUrl.js +8 -1
- package/dist/module/utils/liveRates/buildUrl.js.map +1 -1
- package/dist/module/utils/liveRates/calculatePipsChangeFromOpen.js +7 -1
- package/dist/module/utils/liveRates/calculatePipsChangeFromOpen.js.map +1 -1
- package/dist/module/utils/liveRates/calculatePriceChange.js +8 -1
- package/dist/module/utils/liveRates/calculatePriceChange.js.map +1 -1
- package/dist/module/utils/liveRates/calculatePriceChangeFromOpen.js +8 -1
- package/dist/module/utils/liveRates/calculatePriceChangeFromOpen.js.map +1 -1
- package/dist/module/utils/liveRates/calculateSpread.js +8 -1
- package/dist/module/utils/liveRates/calculateSpread.js.map +1 -1
- package/dist/module/utils/liveRates/decodeLiveRateMessage.js +9 -2
- package/dist/module/utils/liveRates/decodeLiveRateMessage.js.map +1 -1
- package/dist/module/utils/liveRates/decodeUtilities.js +18 -6
- package/dist/module/utils/liveRates/decodeUtilities.js.map +1 -1
- package/dist/module/utils/liveRates/index.js +82 -7
- package/dist/module/utils/liveRates/index.js.map +1 -1
- package/dist/module/utils/validateToolParams.js +7 -1
- package/dist/module/utils/validateToolParams.js.map +1 -1
- package/package.json +9 -4
- package/src/components/style.css +1 -1
- package/tsconfig.types.json +2 -4
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConditionalProvider = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const ConditionalProvider = _ref => {
|
|
3
10
|
let {
|
|
4
11
|
children,
|
|
5
12
|
render = false,
|
|
6
13
|
Provider
|
|
7
14
|
} = _ref;
|
|
8
|
-
return render ?
|
|
15
|
+
return render ? _react.default.cloneElement(Provider, {}, children) : _react.default.createElement(_react.default.Fragment, null, children);
|
|
9
16
|
};
|
|
17
|
+
exports.ConditionalProvider = ConditionalProvider;
|
|
10
18
|
//# sourceMappingURL=ConditionalProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionalProvider.js","names":["
|
|
1
|
+
{"version":3,"file":"ConditionalProvider.js","names":["_react","_interopRequireDefault","require","e","__esModule","default","ConditionalProvider","_ref","children","render","Provider","React","cloneElement","createElement","Fragment","exports"],"sources":["../../../src/providers/ConditionalProvider.tsx"],"sourcesContent":["import type { PropsWithChildren, ReactElement } from 'react';\nimport React from 'react';\n\ntype ConditionalProviderProps = PropsWithChildren<{\n render: boolean;\n Provider: ReactElement;\n}>;\n\nexport const ConditionalProvider: React.FC<ConditionalProviderProps> = ({\n children,\n render = false,\n Provider,\n}) => (render ? React.cloneElement(Provider, {}, children) : <>{children}</>);\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAOnB,MAAMG,mBAAuD,GAAGC,IAAA;EAAA,IAAC;IACtEC,QAAQ;IACRC,MAAM,GAAG,KAAK;IACdC;EACF,CAAC,GAAAH,IAAA;EAAA,OAAME,MAAM,GAAGE,cAAK,CAACC,YAAY,CAACF,QAAQ,EAAE,CAAC,CAAC,EAAEF,QAAQ,CAAC,GAAGR,MAAA,CAAAK,OAAA,CAAAQ,aAAA,CAAAb,MAAA,CAAAK,OAAA,CAAAS,QAAA,QAAGN,QAAW,CAAC;AAAA,CAAC;AAACO,OAAA,CAAAT,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useLayoutProvider = exports.LayoutContext = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const LayoutContext = exports.LayoutContext = _react.default.createContext(undefined);
|
|
3
10
|
LayoutContext.displayName = 'LayoutContext';
|
|
4
|
-
|
|
5
|
-
const layoutDetails =
|
|
11
|
+
const useLayoutProvider = () => {
|
|
12
|
+
const layoutDetails = _react.default.useContext(LayoutContext);
|
|
6
13
|
if (!layoutDetails) {
|
|
7
14
|
throw new Error('Hook used outside of LayoutContextProvider');
|
|
8
15
|
}
|
|
9
16
|
return layoutDetails;
|
|
10
17
|
};
|
|
18
|
+
exports.useLayoutProvider = useLayoutProvider;
|
|
11
19
|
//# sourceMappingURL=LayoutContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutContext.js","names":["
|
|
1
|
+
{"version":3,"file":"LayoutContext.js","names":["_react","_interopRequireDefault","require","e","__esModule","default","LayoutContext","exports","React","createContext","undefined","displayName","useLayoutProvider","layoutDetails","useContext","Error"],"sources":["../../../../src/providers/Layout/LayoutContext.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { Size, Theme, Voidable } from '../../types';\n\nexport interface LayoutContextValue {\n size: Size | null;\n isDark: boolean;\n theme?: Theme;\n}\n\nexport const LayoutContext =\n React.createContext<Voidable<LayoutContextValue>>(undefined);\n\nLayoutContext.displayName = 'LayoutContext';\n\nexport const useLayoutProvider = () => {\n const layoutDetails = React.useContext(LayoutContext);\n\n if (!layoutDetails) {\n throw new Error('Hook used outside of LayoutContextProvider');\n }\n\n return layoutDetails;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAUnB,MAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GACxBE,cAAK,CAACC,aAAa,CAA+BC,SAAS,CAAC;AAE9DJ,aAAa,CAACK,WAAW,GAAG,eAAe;AAEpC,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrC,MAAMC,aAAa,GAAGL,cAAK,CAACM,UAAU,CAACR,aAAa,CAAC;EAErD,IAAI,CAACO,aAAa,EAAE;IAClB,MAAM,IAAIE,KAAK,CAAC,4CAA4C,CAAC;EAC/D;EAEA,OAAOF,aAAa;AACtB,CAAC;AAACN,OAAA,CAAAK,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,50 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LayoutProvider = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _usehooksTs = require("usehooks-ts");
|
|
9
|
+
var _constants = require("../../constants");
|
|
10
|
+
var _tailwind = require("../../tailwind");
|
|
11
|
+
var _types = require("../../types");
|
|
12
|
+
var _LayoutContext = require("./LayoutContext");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
const LayoutProvider = _ref => {
|
|
8
15
|
let {
|
|
9
16
|
children,
|
|
10
|
-
theme = Theme.Light,
|
|
17
|
+
theme = _types.Theme.Light,
|
|
11
18
|
size: fixedSize,
|
|
12
19
|
shouldFitContent = false,
|
|
13
20
|
shouldRemovePadding = false
|
|
14
21
|
} = _ref;
|
|
15
|
-
const isDark = theme === Theme.Dark;
|
|
16
|
-
const [size, setSize] = useState(null);
|
|
17
|
-
const ref = useRef(null);
|
|
18
|
-
const onResize = useDebounceCallback(_ref2 => {
|
|
22
|
+
const isDark = theme === _types.Theme.Dark;
|
|
23
|
+
const [size, setSize] = (0, _react.useState)(null);
|
|
24
|
+
const ref = (0, _react.useRef)(null);
|
|
25
|
+
const onResize = (0, _usehooksTs.useDebounceCallback)(_ref2 => {
|
|
19
26
|
let {
|
|
20
27
|
width
|
|
21
28
|
} = _ref2;
|
|
22
29
|
if (fixedSize) return;
|
|
23
|
-
if (width <= MOBILE_MAX_WIDTH) {
|
|
24
|
-
setSize(Size.MOBILE);
|
|
30
|
+
if (width <= _constants.MOBILE_MAX_WIDTH) {
|
|
31
|
+
setSize(_types.Size.MOBILE);
|
|
25
32
|
}
|
|
26
|
-
if (width > MOBILE_MAX_WIDTH && width < DESKTOP_MIN_WIDTH) {
|
|
27
|
-
setSize(Size.TABLET);
|
|
33
|
+
if (width > _constants.MOBILE_MAX_WIDTH && width < _constants.DESKTOP_MIN_WIDTH) {
|
|
34
|
+
setSize(_types.Size.TABLET);
|
|
28
35
|
}
|
|
29
|
-
if (width >= DESKTOP_MIN_WIDTH) {
|
|
30
|
-
setSize(Size.DESKTOP);
|
|
36
|
+
if (width >= _constants.DESKTOP_MIN_WIDTH) {
|
|
37
|
+
setSize(_types.Size.DESKTOP);
|
|
31
38
|
}
|
|
32
39
|
}, 50, {
|
|
33
40
|
leading: true
|
|
34
41
|
});
|
|
35
|
-
useResizeObserver({
|
|
42
|
+
(0, _usehooksTs.useResizeObserver)({
|
|
36
43
|
ref,
|
|
37
44
|
onResize
|
|
38
45
|
});
|
|
39
|
-
return
|
|
46
|
+
return _react.default.createElement(_LayoutContext.LayoutContext.Provider, {
|
|
40
47
|
value: {
|
|
41
48
|
size: fixedSize || size,
|
|
42
49
|
isDark,
|
|
43
50
|
theme
|
|
44
51
|
}
|
|
45
|
-
},
|
|
52
|
+
}, _react.default.createElement("div", {
|
|
46
53
|
ref: ref,
|
|
47
|
-
className: cn('lw-scoped-preflight lw-isolate lw-overflow-hidden lw-bg-bg-primary lw-font-sans', {
|
|
54
|
+
className: (0, _tailwind.cn)('lw-scoped-preflight lw-isolate lw-overflow-hidden lw-bg-bg-primary lw-font-sans', {
|
|
48
55
|
'lw-p-[0.125rem]': !!size && !shouldRemovePadding,
|
|
49
56
|
'lw-w-fit': !!shouldFitContent
|
|
50
57
|
}),
|
|
@@ -55,4 +62,5 @@ export const LayoutProvider = _ref => {
|
|
|
55
62
|
}
|
|
56
63
|
}, children));
|
|
57
64
|
};
|
|
65
|
+
exports.LayoutProvider = LayoutProvider;
|
|
58
66
|
//# sourceMappingURL=LayoutProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutProvider.js","names":["
|
|
1
|
+
{"version":3,"file":"LayoutProvider.js","names":["_react","_interopRequireWildcard","require","_usehooksTs","_constants","_tailwind","_types","_LayoutContext","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","LayoutProvider","_ref","children","theme","Theme","Light","size","fixedSize","shouldFitContent","shouldRemovePadding","isDark","Dark","setSize","useState","ref","useRef","onResize","useDebounceCallback","_ref2","width","MOBILE_MAX_WIDTH","Size","MOBILE","DESKTOP_MIN_WIDTH","TABLET","DESKTOP","leading","useResizeObserver","createElement","LayoutContext","Provider","value","className","cn","style","colorScheme","exports"],"sources":["../../../../src/providers/Layout/LayoutProvider.tsx"],"sourcesContent":["import type { CSSProperties, FC, PropsWithChildren } from 'react';\nimport React, { useRef, useState } from 'react';\nimport { useDebounceCallback, useResizeObserver } from 'usehooks-ts';\n\nimport { DESKTOP_MIN_WIDTH, MOBILE_MAX_WIDTH } from '../../constants';\nimport { cn } from '../../tailwind';\nimport { Size, Theme } from '../../types';\nimport { LayoutContext } from './LayoutContext';\n\nexport type LayoutWrapperProps = PropsWithChildren & {\n shouldRemovePadding?: boolean;\n size?: Size;\n shouldFitContent?: boolean;\n theme?: Theme;\n};\n\nexport const LayoutProvider: FC<LayoutWrapperProps> = ({\n children,\n theme = Theme.Light,\n size: fixedSize,\n shouldFitContent = false,\n shouldRemovePadding = false,\n}) => {\n const isDark = theme === Theme.Dark;\n const [size, setSize] = useState<null | Size>(null);\n\n const ref = useRef<HTMLDivElement>(null);\n const onResize = useDebounceCallback(\n ({ width }) => {\n if (fixedSize) return;\n\n if (width <= MOBILE_MAX_WIDTH) {\n setSize(Size.MOBILE);\n }\n if (width > MOBILE_MAX_WIDTH && width < DESKTOP_MIN_WIDTH) {\n setSize(Size.TABLET);\n }\n if (width >= DESKTOP_MIN_WIDTH) {\n setSize(Size.DESKTOP);\n }\n },\n 50,\n { leading: true }\n );\n\n useResizeObserver({\n ref,\n onResize,\n });\n\n return (\n <LayoutContext.Provider\n value={{\n size: fixedSize || size,\n isDark,\n theme,\n }}\n >\n <div\n ref={ref}\n className={cn(\n 'lw-scoped-preflight lw-isolate lw-overflow-hidden lw-bg-bg-primary lw-font-sans',\n {\n 'lw-p-[0.125rem]': !!size && !shouldRemovePadding,\n 'lw-w-fit': !!shouldFitContent,\n }\n )}\n data-testid=\"layout-provider\"\n data-theme={theme}\n style={\n {\n colorScheme: isDark ? 'dark' : 'light',\n } as CSSProperties\n }\n >\n {children}\n </div>\n </LayoutContext.Provider>\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAAgD,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAA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,EAAEC,SAAS,IAAID,IAAI;MACvBI,MAAM;MACNP;IACF;EAAE,GAEF9B,MAAA,CAAAkB,OAAA,CAAAqC,aAAA;IACEd,GAAG,EAAEA,GAAI;IACTkB,SAAS,EAAE,IAAAC,YAAE,EACX,iFAAiF,EACjF;MACE,iBAAiB,EAAE,CAAC,CAAC3B,IAAI,IAAI,CAACG,mBAAmB;MACjD,UAAU,EAAE,CAAC,CAACD;IAChB,CACF,CAAE;IACF,eAAY,iBAAiB;IAC7B,cAAYL,KAAM;IAClB+B,KAAK,EACH;MACEC,WAAW,EAAEzB,MAAM,GAAG,MAAM,GAAG;IACjC;EACD,GAEAR,QACE,CACiB,CAAC;AAE7B,CAAC;AAACkC,OAAA,CAAApC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
var _react2 = _interopRequireDefault(require("react"));
|
|
5
|
+
var _constants = require("../../constants");
|
|
6
|
+
var _types = require("../../types");
|
|
7
|
+
var _LayoutContext = require("./LayoutContext");
|
|
8
|
+
var _LayoutProvider = require("./LayoutProvider");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
10
|
let mockResizeCallback = () => {};
|
|
8
11
|
const mockUseResizeObserver = jest.fn(_ref => {
|
|
9
12
|
let {
|
|
@@ -17,18 +20,18 @@ jest.mock('usehooks-ts', () => ({
|
|
|
17
20
|
useDebounceCallback: (callback, _delay, _options) => mockUseDebounceCallback(callback)
|
|
18
21
|
}));
|
|
19
22
|
const TestConsumerComponent = () => {
|
|
20
|
-
const context =
|
|
23
|
+
const context = _react2.default.useContext(_LayoutContext.LayoutContext);
|
|
21
24
|
if (!context) return null;
|
|
22
|
-
return
|
|
25
|
+
return _react2.default.createElement("div", null, _react2.default.createElement("span", {
|
|
23
26
|
"data-testid": "size"
|
|
24
|
-
}, context.size),
|
|
27
|
+
}, context.size), _react2.default.createElement("span", {
|
|
25
28
|
"data-testid": "isDark"
|
|
26
|
-
}, context.isDark.toString()),
|
|
29
|
+
}, context.isDark.toString()), _react2.default.createElement("span", {
|
|
27
30
|
"data-testid": "theme"
|
|
28
31
|
}, context.theme));
|
|
29
32
|
};
|
|
30
33
|
const renderLayoutProvider = props => {
|
|
31
|
-
return render(
|
|
34
|
+
return (0, _react.render)(_react2.default.createElement(_LayoutProvider.LayoutProvider, props, _react2.default.createElement(TestConsumerComponent, null)));
|
|
32
35
|
};
|
|
33
36
|
describe('LayoutProvider', () => {
|
|
34
37
|
beforeEach(() => {
|
|
@@ -37,126 +40,126 @@ describe('LayoutProvider', () => {
|
|
|
37
40
|
});
|
|
38
41
|
it('renders children and provides default context values', () => {
|
|
39
42
|
renderLayoutProvider();
|
|
40
|
-
expect(screen.getByTestId('layout-provider')).toBeInTheDocument();
|
|
41
|
-
expect(screen.getByTestId('size')).toHaveTextContent('');
|
|
42
|
-
expect(screen.getByTestId('isDark')).toHaveTextContent('false');
|
|
43
|
-
expect(screen.getByTestId('theme')).toHaveTextContent(Theme.Light);
|
|
44
|
-
expect(screen.getByTestId('layout-provider')).toHaveClass('lw-p-[0.125rem]');
|
|
45
|
-
expect(screen.getByTestId('layout-provider')).not.toHaveClass('lw-w-fit');
|
|
46
|
-
expect(screen.getByTestId('layout-provider')).toHaveStyle('colorScheme: light');
|
|
43
|
+
expect(_react.screen.getByTestId('layout-provider')).toBeInTheDocument();
|
|
44
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent('');
|
|
45
|
+
expect(_react.screen.getByTestId('isDark')).toHaveTextContent('false');
|
|
46
|
+
expect(_react.screen.getByTestId('theme')).toHaveTextContent(_types.Theme.Light);
|
|
47
|
+
expect(_react.screen.getByTestId('layout-provider')).toHaveClass('lw-p-[0.125rem]');
|
|
48
|
+
expect(_react.screen.getByTestId('layout-provider')).not.toHaveClass('lw-w-fit');
|
|
49
|
+
expect(_react.screen.getByTestId('layout-provider')).toHaveStyle('colorScheme: light');
|
|
47
50
|
});
|
|
48
51
|
it('provides dark theme context values when theme is Dark', () => {
|
|
49
52
|
renderLayoutProvider({
|
|
50
|
-
theme: Theme.Dark
|
|
53
|
+
theme: _types.Theme.Dark
|
|
51
54
|
});
|
|
52
|
-
expect(screen.getByTestId('isDark')).toHaveTextContent('true');
|
|
53
|
-
expect(screen.getByTestId('theme')).toHaveTextContent(Theme.Dark);
|
|
54
|
-
expect(screen.getByTestId('layout-provider')).toHaveStyle('colorScheme: dark');
|
|
55
|
+
expect(_react.screen.getByTestId('isDark')).toHaveTextContent('true');
|
|
56
|
+
expect(_react.screen.getByTestId('theme')).toHaveTextContent(_types.Theme.Dark);
|
|
57
|
+
expect(_react.screen.getByTestId('layout-provider')).toHaveStyle('colorScheme: dark');
|
|
55
58
|
});
|
|
56
59
|
it('provides fixedSize when specified and does not listen to resize', () => {
|
|
57
60
|
renderLayoutProvider({
|
|
58
|
-
size: Size.TABLET
|
|
61
|
+
size: _types.Size.TABLET
|
|
59
62
|
});
|
|
60
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);
|
|
61
|
-
act(() => {
|
|
63
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.TABLET);
|
|
64
|
+
(0, _react.act)(() => {
|
|
62
65
|
mockResizeCallback({
|
|
63
|
-
width: MOBILE_MAX_WIDTH - 100
|
|
66
|
+
width: _constants.MOBILE_MAX_WIDTH - 100
|
|
64
67
|
});
|
|
65
68
|
});
|
|
66
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);
|
|
69
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.TABLET);
|
|
67
70
|
expect(mockUseDebounceCallback).toHaveBeenCalledTimes(1);
|
|
68
71
|
});
|
|
69
72
|
it('applies lw-w-fit class when shouldFitContent is true', () => {
|
|
70
73
|
renderLayoutProvider({
|
|
71
74
|
shouldFitContent: true
|
|
72
75
|
});
|
|
73
|
-
expect(screen.getByTestId('layout-provider')).toHaveClass('lw-w-fit');
|
|
76
|
+
expect(_react.screen.getByTestId('layout-provider')).toHaveClass('lw-w-fit');
|
|
74
77
|
});
|
|
75
78
|
it('removes padding when shouldRemovePadding is true and size is set', () => {
|
|
76
79
|
renderLayoutProvider({
|
|
77
80
|
shouldRemovePadding: true
|
|
78
81
|
});
|
|
79
|
-
act(() => {
|
|
82
|
+
(0, _react.act)(() => {
|
|
80
83
|
mockResizeCallback({
|
|
81
|
-
width: MOBILE_MAX_WIDTH
|
|
84
|
+
width: _constants.MOBILE_MAX_WIDTH
|
|
82
85
|
});
|
|
83
86
|
});
|
|
84
|
-
expect(screen.getByTestId('layout-provider')).not.toHaveClass('lw-p-[0.125rem]');
|
|
87
|
+
expect(_react.screen.getByTestId('layout-provider')).not.toHaveClass('lw-p-[0.125rem]');
|
|
85
88
|
});
|
|
86
89
|
it('does not apply padding if size is null, even if shouldRemovePadding is false', () => {
|
|
87
90
|
renderLayoutProvider({
|
|
88
91
|
shouldRemovePadding: false
|
|
89
92
|
});
|
|
90
|
-
expect(screen.getByTestId('layout-provider')).not.toHaveClass('lw-p-[0.125rem]');
|
|
93
|
+
expect(_react.screen.getByTestId('layout-provider')).not.toHaveClass('lw-p-[0.125rem]');
|
|
91
94
|
});
|
|
92
95
|
it('applies padding when size is set and shouldRemovePadding is false', () => {
|
|
93
96
|
renderLayoutProvider({
|
|
94
97
|
shouldRemovePadding: false
|
|
95
98
|
});
|
|
96
|
-
act(() => {
|
|
99
|
+
(0, _react.act)(() => {
|
|
97
100
|
mockResizeCallback({
|
|
98
|
-
width: MOBILE_MAX_WIDTH
|
|
101
|
+
width: _constants.MOBILE_MAX_WIDTH
|
|
99
102
|
});
|
|
100
103
|
});
|
|
101
|
-
expect(screen.getByTestId('layout-provider')).toHaveClass('lw-p-[0.125rem]');
|
|
104
|
+
expect(_react.screen.getByTestId('layout-provider')).toHaveClass('lw-p-[0.125rem]');
|
|
102
105
|
});
|
|
103
106
|
describe('onResize behavior', () => {
|
|
104
107
|
it('sets size to MOBILE when width is less than or equal to MOBILE_MAX_WIDTH', () => {
|
|
105
108
|
renderLayoutProvider();
|
|
106
|
-
act(() => {
|
|
109
|
+
(0, _react.act)(() => {
|
|
107
110
|
mockResizeCallback({
|
|
108
|
-
width: MOBILE_MAX_WIDTH
|
|
111
|
+
width: _constants.MOBILE_MAX_WIDTH
|
|
109
112
|
});
|
|
110
113
|
});
|
|
111
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.MOBILE);
|
|
112
|
-
act(() => {
|
|
114
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.MOBILE);
|
|
115
|
+
(0, _react.act)(() => {
|
|
113
116
|
mockResizeCallback({
|
|
114
|
-
width: MOBILE_MAX_WIDTH - 100
|
|
117
|
+
width: _constants.MOBILE_MAX_WIDTH - 100
|
|
115
118
|
});
|
|
116
119
|
});
|
|
117
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.MOBILE);
|
|
120
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.MOBILE);
|
|
118
121
|
});
|
|
119
122
|
it('sets size to TABLET when width is between MOBILE_MAX_WIDTH and DESKTOP_MIN_WIDTH', () => {
|
|
120
123
|
renderLayoutProvider();
|
|
121
|
-
act(() => {
|
|
124
|
+
(0, _react.act)(() => {
|
|
122
125
|
mockResizeCallback({
|
|
123
|
-
width: MOBILE_MAX_WIDTH + 1
|
|
126
|
+
width: _constants.MOBILE_MAX_WIDTH + 1
|
|
124
127
|
});
|
|
125
128
|
});
|
|
126
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);
|
|
127
|
-
act(() => {
|
|
129
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.TABLET);
|
|
130
|
+
(0, _react.act)(() => {
|
|
128
131
|
mockResizeCallback({
|
|
129
|
-
width: DESKTOP_MIN_WIDTH - 1
|
|
132
|
+
width: _constants.DESKTOP_MIN_WIDTH - 1
|
|
130
133
|
});
|
|
131
134
|
});
|
|
132
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);
|
|
135
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.TABLET);
|
|
133
136
|
});
|
|
134
137
|
it('sets size to DESKTOP when width is greater than or equal to DESKTOP_MIN_WIDTH', () => {
|
|
135
138
|
renderLayoutProvider();
|
|
136
|
-
act(() => {
|
|
139
|
+
(0, _react.act)(() => {
|
|
137
140
|
mockResizeCallback({
|
|
138
|
-
width: DESKTOP_MIN_WIDTH
|
|
141
|
+
width: _constants.DESKTOP_MIN_WIDTH
|
|
139
142
|
});
|
|
140
143
|
});
|
|
141
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);
|
|
142
|
-
act(() => {
|
|
144
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.DESKTOP);
|
|
145
|
+
(0, _react.act)(() => {
|
|
143
146
|
mockResizeCallback({
|
|
144
|
-
width: DESKTOP_MIN_WIDTH + 100
|
|
147
|
+
width: _constants.DESKTOP_MIN_WIDTH + 100
|
|
145
148
|
});
|
|
146
149
|
});
|
|
147
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);
|
|
150
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.DESKTOP);
|
|
148
151
|
});
|
|
149
152
|
it('does not update size on resize if fixedSize is provided', () => {
|
|
150
153
|
renderLayoutProvider({
|
|
151
|
-
size: Size.DESKTOP
|
|
154
|
+
size: _types.Size.DESKTOP
|
|
152
155
|
});
|
|
153
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);
|
|
154
|
-
act(() => {
|
|
156
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.DESKTOP);
|
|
157
|
+
(0, _react.act)(() => {
|
|
155
158
|
mockResizeCallback({
|
|
156
|
-
width: MOBILE_MAX_WIDTH - 100
|
|
159
|
+
width: _constants.MOBILE_MAX_WIDTH - 100
|
|
157
160
|
});
|
|
158
161
|
});
|
|
159
|
-
expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);
|
|
162
|
+
expect(_react.screen.getByTestId('size')).toHaveTextContent(_types.Size.DESKTOP);
|
|
160
163
|
});
|
|
161
164
|
});
|
|
162
165
|
it('uses debounced callback for onResize', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutProvider.test.js","names":["act","render","screen","React","DESKTOP_MIN_WIDTH","MOBILE_MAX_WIDTH","Size","Theme","LayoutContext","LayoutProvider","mockResizeCallback","mockUseResizeObserver","jest","fn","_ref","onResize","mockUseDebounceCallback","callback","mock","useResizeObserver","props","useDebounceCallback","_delay","_options","TestConsumerComponent","context","useContext","createElement","size","isDark","toString","theme","renderLayoutProvider","describe","beforeEach","clearAllMocks","it","expect","getByTestId","toBeInTheDocument","toHaveTextContent","Light","toHaveClass","not","toHaveStyle","Dark","TABLET","width","toHaveBeenCalledTimes","shouldFitContent","shouldRemovePadding","MOBILE","DESKTOP","toHaveBeenCalledWith","any","Function","leading","ref","Object"],"sources":["../../../../src/providers/Layout/LayoutProvider.test.tsx"],"sourcesContent":["import { act, render, screen } from '@testing-library/react';\nimport React from 'react';\n\nimport { DESKTOP_MIN_WIDTH, MOBILE_MAX_WIDTH } from '../../constants';\nimport { Size, Theme } from '../../types';\nimport { LayoutContext } from './LayoutContext';\nimport type { LayoutWrapperProps } from './LayoutProvider';\nimport { LayoutProvider } from './LayoutProvider';\n\n// Mock usehooks-ts\nlet mockResizeCallback: (entry: { width: number }) => void = () => {};\nconst mockUseResizeObserver = jest.fn(({ onResize }) => {\n mockResizeCallback = onResize;\n});\nconst mockUseDebounceCallback = jest.fn((callback) => callback);\n\njest.mock('usehooks-ts', () => ({\n useResizeObserver: (props: any) => mockUseResizeObserver(props),\n useDebounceCallback: (callback: any, _delay: any, _options: any) =>\n mockUseDebounceCallback(callback),\n}));\n\nconst TestConsumerComponent = () => {\n const context = React.useContext(LayoutContext);\n if (!context) return null;\n return (\n <div>\n <span data-testid=\"size\">{context.size}</span>\n <span data-testid=\"isDark\">{context.isDark.toString()}</span>\n <span data-testid=\"theme\">{context.theme}</span>\n </div>\n );\n};\n\nconst renderLayoutProvider = (props?: Partial<LayoutWrapperProps>) => {\n return render(\n <LayoutProvider {...props}>\n <TestConsumerComponent />\n </LayoutProvider>\n );\n};\n\ndescribe('LayoutProvider', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n // Reset mockResizeCallback to a no-op function before each test\n mockResizeCallback = () => {};\n });\n\n it('renders children and provides default context values', () => {\n renderLayoutProvider();\n expect(screen.getByTestId('layout-provider')).toBeInTheDocument();\n expect(screen.getByTestId('size')).toHaveTextContent(''); // Initially null\n expect(screen.getByTestId('isDark')).toHaveTextContent('false');\n expect(screen.getByTestId('theme')).toHaveTextContent(Theme.Light);\n expect(screen.getByTestId('layout-provider')).toHaveClass(\n 'lw-p-[0.125rem]'\n ); // Padding by default when size is set\n expect(screen.getByTestId('layout-provider')).not.toHaveClass('lw-w-fit');\n expect(screen.getByTestId('layout-provider')).toHaveStyle(\n 'colorScheme: light'\n );\n });\n\n it('provides dark theme context values when theme is Dark', () => {\n renderLayoutProvider({ theme: Theme.Dark });\n expect(screen.getByTestId('isDark')).toHaveTextContent('true');\n expect(screen.getByTestId('theme')).toHaveTextContent(Theme.Dark);\n expect(screen.getByTestId('layout-provider')).toHaveStyle(\n 'colorScheme: dark'\n );\n });\n\n it('provides fixedSize when specified and does not listen to resize', () => {\n renderLayoutProvider({ size: Size.TABLET });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n\n // Simulate resize\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH - 100 });\n });\n // Size should remain fixed\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n expect(mockUseDebounceCallback).toHaveBeenCalledTimes(1); // onResize is debounced\n });\n\n it('applies lw-w-fit class when shouldFitContent is true', () => {\n renderLayoutProvider({ shouldFitContent: true });\n expect(screen.getByTestId('layout-provider')).toHaveClass('lw-w-fit');\n });\n\n it('removes padding when shouldRemovePadding is true and size is set', () => {\n renderLayoutProvider({ shouldRemovePadding: true });\n // Simulate resize to set a size, which would normally add padding\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH });\n });\n expect(screen.getByTestId('layout-provider')).not.toHaveClass(\n 'lw-p-[0.125rem]'\n );\n });\n\n it('does not apply padding if size is null, even if shouldRemovePadding is false', () => {\n renderLayoutProvider({ shouldRemovePadding: false });\n // Size is initially null, so no padding class should be applied yet\n expect(screen.getByTestId('layout-provider')).not.toHaveClass(\n 'lw-p-[0.125rem]'\n );\n });\n\n it('applies padding when size is set and shouldRemovePadding is false', () => {\n renderLayoutProvider({ shouldRemovePadding: false });\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH }); // This will set size to MOBILE\n });\n expect(screen.getByTestId('layout-provider')).toHaveClass(\n 'lw-p-[0.125rem]'\n );\n });\n\n describe('onResize behavior', () => {\n it('sets size to MOBILE when width is less than or equal to MOBILE_MAX_WIDTH', () => {\n renderLayoutProvider();\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.MOBILE);\n\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH - 100 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.MOBILE);\n });\n\n it('sets size to TABLET when width is between MOBILE_MAX_WIDTH and DESKTOP_MIN_WIDTH', () => {\n renderLayoutProvider();\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH + 1 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n\n act(() => {\n mockResizeCallback({ width: DESKTOP_MIN_WIDTH - 1 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n });\n\n it('sets size to DESKTOP when width is greater than or equal to DESKTOP_MIN_WIDTH', () => {\n renderLayoutProvider();\n act(() => {\n mockResizeCallback({ width: DESKTOP_MIN_WIDTH });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n\n act(() => {\n mockResizeCallback({ width: DESKTOP_MIN_WIDTH + 100 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n });\n\n it('does not update size on resize if fixedSize is provided', () => {\n renderLayoutProvider({ size: Size.DESKTOP });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH - 100 });\n });\n // Size should remain fixed\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n });\n });\n\n it('uses debounced callback for onResize', () => {\n renderLayoutProvider();\n expect(mockUseDebounceCallback).toHaveBeenCalledTimes(1);\n expect(mockUseDebounceCallback).toHaveBeenCalledWith(\n expect.any(Function),\n 50,\n { leading: true }\n );\n });\n\n it('calls useResizeObserver with ref and onResize', () => {\n renderLayoutProvider();\n expect(mockUseResizeObserver).toHaveBeenCalledTimes(1);\n expect(mockUseResizeObserver).toHaveBeenCalledWith({\n ref: expect.any(Object), // React.RefObject\n onResize: expect.any(Function), // The debounced callback\n });\n });\n});\n"],"mappings":"AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,MAAM,QAAQ,wBAAwB;AAC5D,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,iBAAiB;AACrE,SAASC,IAAI,EAAEC,KAAK,QAAQ,aAAa;AACzC,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,cAAc,QAAQ,kBAAkB;AAGjD,IAAIC,kBAAsD,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrE,MAAMC,qBAAqB,GAAGC,IAAI,CAACC,EAAE,CAACC,IAAA,IAAkB;EA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,MAAM,CAACnC,MAAM,CAACoC,WAAW,CAAC,MAAM,CAAC,CAAC,CAACE,iBAAiB,CAAClC,IAAI,CAAC8C,OAAO,CAAC;IACpE,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFhB,EAAE,CAAC,sCAAsC,EAAE,MAAM;IAC/CJ,oBAAoB,CAAC,CAAC;IACtBK,MAAM,CAACrB,uBAAuB,CAAC,CAACgC,qBAAqB,CAAC,CAAC,CAAC;IACxDX,MAAM,CAACrB,uBAAuB,CAAC,CAACqC,oBAAoB,CAClDhB,MAAM,CAACiB,GAAG,CAACC,QAAQ,CAAC,EACpB,EAAE,EACF;MAAEC,OAAO,EAAE;IAAK,CAClB,CAAC;EACH,CAAC,CAAC;EAEFpB,EAAE,CAAC,+CAA+C,EAAE,MAAM;IACxDJ,oBAAoB,CAAC,CAAC;IACtBK,MAAM,CAAC1B,qBAAqB,CAAC,CAACqC,qBAAqB,CAAC,CAAC,CAAC;IACtDX,MAAM,CAAC1B,qBAAqB,CAAC,CAAC0C,oBAAoB,CAAC;MACjDI,GAAG,EAAEpB,MAAM,CAACiB,GAAG,CAACI,MAAM,CAAC;MACvB3C,QAAQ,EAAEsB,MAAM,CAACiB,GAAG,CAACC,QAAQ;IAC/B,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LayoutProvider.test.js","names":["_react","require","_react2","_interopRequireDefault","_constants","_types","_LayoutContext","_LayoutProvider","e","__esModule","default","mockResizeCallback","mockUseResizeObserver","jest","fn","_ref","onResize","mockUseDebounceCallback","callback","mock","useResizeObserver","props","useDebounceCallback","_delay","_options","TestConsumerComponent","context","React","useContext","LayoutContext","createElement","size","isDark","toString","theme","renderLayoutProvider","render","LayoutProvider","describe","beforeEach","clearAllMocks","it","expect","screen","getByTestId","toBeInTheDocument","toHaveTextContent","Theme","Light","toHaveClass","not","toHaveStyle","Dark","Size","TABLET","act","width","MOBILE_MAX_WIDTH","toHaveBeenCalledTimes","shouldFitContent","shouldRemovePadding","MOBILE","DESKTOP_MIN_WIDTH","DESKTOP","toHaveBeenCalledWith","any","Function","leading","ref","Object"],"sources":["../../../../src/providers/Layout/LayoutProvider.test.tsx"],"sourcesContent":["import { act, render, screen } from '@testing-library/react';\nimport React from 'react';\n\nimport { DESKTOP_MIN_WIDTH, MOBILE_MAX_WIDTH } from '../../constants';\nimport { Size, Theme } from '../../types';\nimport { LayoutContext } from './LayoutContext';\nimport type { LayoutWrapperProps } from './LayoutProvider';\nimport { LayoutProvider } from './LayoutProvider';\n\n// Mock usehooks-ts\nlet mockResizeCallback: (entry: { width: number }) => void = () => {};\nconst mockUseResizeObserver = jest.fn(({ onResize }) => {\n mockResizeCallback = onResize;\n});\nconst mockUseDebounceCallback = jest.fn((callback) => callback);\n\njest.mock('usehooks-ts', () => ({\n useResizeObserver: (props: any) => mockUseResizeObserver(props),\n useDebounceCallback: (callback: any, _delay: any, _options: any) =>\n mockUseDebounceCallback(callback),\n}));\n\nconst TestConsumerComponent = () => {\n const context = React.useContext(LayoutContext);\n if (!context) return null;\n return (\n <div>\n <span data-testid=\"size\">{context.size}</span>\n <span data-testid=\"isDark\">{context.isDark.toString()}</span>\n <span data-testid=\"theme\">{context.theme}</span>\n </div>\n );\n};\n\nconst renderLayoutProvider = (props?: Partial<LayoutWrapperProps>) => {\n return render(\n <LayoutProvider {...props}>\n <TestConsumerComponent />\n </LayoutProvider>\n );\n};\n\ndescribe('LayoutProvider', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n // Reset mockResizeCallback to a no-op function before each test\n mockResizeCallback = () => {};\n });\n\n it('renders children and provides default context values', () => {\n renderLayoutProvider();\n expect(screen.getByTestId('layout-provider')).toBeInTheDocument();\n expect(screen.getByTestId('size')).toHaveTextContent(''); // Initially null\n expect(screen.getByTestId('isDark')).toHaveTextContent('false');\n expect(screen.getByTestId('theme')).toHaveTextContent(Theme.Light);\n expect(screen.getByTestId('layout-provider')).toHaveClass(\n 'lw-p-[0.125rem]'\n ); // Padding by default when size is set\n expect(screen.getByTestId('layout-provider')).not.toHaveClass('lw-w-fit');\n expect(screen.getByTestId('layout-provider')).toHaveStyle(\n 'colorScheme: light'\n );\n });\n\n it('provides dark theme context values when theme is Dark', () => {\n renderLayoutProvider({ theme: Theme.Dark });\n expect(screen.getByTestId('isDark')).toHaveTextContent('true');\n expect(screen.getByTestId('theme')).toHaveTextContent(Theme.Dark);\n expect(screen.getByTestId('layout-provider')).toHaveStyle(\n 'colorScheme: dark'\n );\n });\n\n it('provides fixedSize when specified and does not listen to resize', () => {\n renderLayoutProvider({ size: Size.TABLET });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n\n // Simulate resize\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH - 100 });\n });\n // Size should remain fixed\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n expect(mockUseDebounceCallback).toHaveBeenCalledTimes(1); // onResize is debounced\n });\n\n it('applies lw-w-fit class when shouldFitContent is true', () => {\n renderLayoutProvider({ shouldFitContent: true });\n expect(screen.getByTestId('layout-provider')).toHaveClass('lw-w-fit');\n });\n\n it('removes padding when shouldRemovePadding is true and size is set', () => {\n renderLayoutProvider({ shouldRemovePadding: true });\n // Simulate resize to set a size, which would normally add padding\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH });\n });\n expect(screen.getByTestId('layout-provider')).not.toHaveClass(\n 'lw-p-[0.125rem]'\n );\n });\n\n it('does not apply padding if size is null, even if shouldRemovePadding is false', () => {\n renderLayoutProvider({ shouldRemovePadding: false });\n // Size is initially null, so no padding class should be applied yet\n expect(screen.getByTestId('layout-provider')).not.toHaveClass(\n 'lw-p-[0.125rem]'\n );\n });\n\n it('applies padding when size is set and shouldRemovePadding is false', () => {\n renderLayoutProvider({ shouldRemovePadding: false });\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH }); // This will set size to MOBILE\n });\n expect(screen.getByTestId('layout-provider')).toHaveClass(\n 'lw-p-[0.125rem]'\n );\n });\n\n describe('onResize behavior', () => {\n it('sets size to MOBILE when width is less than or equal to MOBILE_MAX_WIDTH', () => {\n renderLayoutProvider();\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.MOBILE);\n\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH - 100 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.MOBILE);\n });\n\n it('sets size to TABLET when width is between MOBILE_MAX_WIDTH and DESKTOP_MIN_WIDTH', () => {\n renderLayoutProvider();\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH + 1 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n\n act(() => {\n mockResizeCallback({ width: DESKTOP_MIN_WIDTH - 1 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.TABLET);\n });\n\n it('sets size to DESKTOP when width is greater than or equal to DESKTOP_MIN_WIDTH', () => {\n renderLayoutProvider();\n act(() => {\n mockResizeCallback({ width: DESKTOP_MIN_WIDTH });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n\n act(() => {\n mockResizeCallback({ width: DESKTOP_MIN_WIDTH + 100 });\n });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n });\n\n it('does not update size on resize if fixedSize is provided', () => {\n renderLayoutProvider({ size: Size.DESKTOP });\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n\n act(() => {\n mockResizeCallback({ width: MOBILE_MAX_WIDTH - 100 });\n });\n // Size should remain fixed\n expect(screen.getByTestId('size')).toHaveTextContent(Size.DESKTOP);\n });\n });\n\n it('uses debounced callback for onResize', () => {\n renderLayoutProvider();\n expect(mockUseDebounceCallback).toHaveBeenCalledTimes(1);\n expect(mockUseDebounceCallback).toHaveBeenCalledWith(\n expect.any(Function),\n 50,\n { leading: true }\n );\n });\n\n it('calls useResizeObserver with ref and onResize', () => {\n renderLayoutProvider();\n expect(mockUseResizeObserver).toHaveBeenCalledTimes(1);\n expect(mockUseResizeObserver).toHaveBeenCalledWith({\n ref: expect.any(Object), // React.RefObject\n onResize: expect.any(Function), // The debounced callback\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAN,OAAA;AAAkD,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGlD,IAAIG,kBAAsD,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrE,MAAMC,qBAAqB,GAAGC,IAAI,CAACC,EAAE,CAACC,IAAA,IAAkB;EAAA,IAAjB;IAAEC;EAAS,CAAC,GAAAD,IAAA;EACjDJ,kBAAkB,GAAGK,QAAQ;AAC/B,CAAC,CAAC;AACF,MAAMC,uBAAuB,GAAGJ,IAAI,CAACC,EAAE,CAAEI,QAAQ,IAAKA,QAAQ,CAAC;AAE/DL,IAAI,CAACM,IAAI,CAAC,aAAa,EAAE,OAAO;EAC9BC,iBAAiB,EAAGC,KAAU,IAAKT,qBAAqB,CAACS,KAAK,CAAC;EAC/DC,mBAAmB,EAAEA,CAACJ,QAAa,EAAEK,MAAW,EAAEC,QAAa,KAC7DP,uBAAuB,CAACC,QAAQ;AACpC,CAAC,CAAC,CAAC;AAEH,MAAMO,qBAAqB,GAAGA,CAAA,KAAM;EAClC,MAAMC,OAAO,GAAGC,eAAK,CAACC,UAAU,CAACC,4BAAa,CAAC;EAC/C,IAAI,CAACH,OAAO,EAAE,OAAO,IAAI;EACzB,OACExB,OAAA,CAAAQ,OAAA,CAAAoB,aAAA,c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AAC,CAAC8C,qBAAqB,CAAC,CAAC,CAAC;IACtDhB,MAAM,CAAC9B,qBAAqB,CAAC,CAACoD,oBAAoB,CAAC;MACjDI,GAAG,EAAE1B,MAAM,CAACuB,GAAG,CAACI,MAAM,CAAC;MACvBrD,QAAQ,EAAE0B,MAAM,CAACuB,GAAG,CAACC,QAAQ;IAC/B,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _LayoutContext = require("./LayoutContext");
|
|
7
|
+
Object.keys(_LayoutContext).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _LayoutContext[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _LayoutContext[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _LayoutProvider = require("./LayoutProvider");
|
|
18
|
+
Object.keys(_LayoutProvider).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _LayoutProvider[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _LayoutProvider[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
3
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/providers/Layout/index.ts"],"sourcesContent":["export * from './LayoutContext';\nexport * from './LayoutProvider';\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_LayoutContext","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_LayoutProvider"],"sources":["../../../../src/providers/Layout/index.ts"],"sourcesContent":["export * from './LayoutContext';\nexport * from './LayoutProvider';\n"],"mappings":";;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,cAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,eAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,eAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,eAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,eAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useLiveRatesProvider = exports.LiveRatesContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const LiveRatesContext = exports.LiveRatesContext = (0, _react.createContext)(undefined);
|
|
3
9
|
LiveRatesContext.displayName = 'LiveRatesContext';
|
|
4
|
-
|
|
5
|
-
const liveRates = useContext(LiveRatesContext);
|
|
10
|
+
const useLiveRatesProvider = skip => {
|
|
11
|
+
const liveRates = (0, _react.useContext)(LiveRatesContext);
|
|
6
12
|
if (skip) {
|
|
7
13
|
return null;
|
|
8
14
|
}
|
|
@@ -11,4 +17,5 @@ export const useLiveRatesProvider = skip => {
|
|
|
11
17
|
}
|
|
12
18
|
return liveRates;
|
|
13
19
|
};
|
|
20
|
+
exports.useLiveRatesProvider = useLiveRatesProvider;
|
|
14
21
|
//# sourceMappingURL=LiveRatesContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveRatesContext.js","names":["
|
|
1
|
+
{"version":3,"file":"LiveRatesContext.js","names":["_react","require","LiveRatesContext","exports","createContext","undefined","displayName","useLiveRatesProvider","skip","liveRates","useContext","Error"],"sources":["../../../../src/providers/LiveRates/LiveRatesContext.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { Nullable, Voidable } from '../../types';\n\ninterface LiveRatesContextValue {\n target: Nullable<EventTarget>;\n source: Voidable<EventSource>;\n}\n\nexport const LiveRatesContext =\n createContext<Voidable<LiveRatesContextValue>>(undefined);\n\nLiveRatesContext.displayName = 'LiveRatesContext';\n\nexport const useLiveRatesProvider = (skip?: boolean) => {\n const liveRates = useContext(LiveRatesContext);\n\n if (skip) {\n return null;\n }\n\n if (!liveRates) {\n throw new Error('Hook used outside of LiveRatesContextProvider');\n }\n\n return liveRates;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASO,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAC3B,IAAAE,oBAAa,EAAkCC,SAAS,CAAC;AAE3DH,gBAAgB,CAACI,WAAW,GAAG,kBAAkB;AAE1C,MAAMC,oBAAoB,GAAIC,IAAc,IAAK;EACtD,MAAMC,SAAS,GAAG,IAAAC,iBAAU,EAACR,gBAAgB,CAAC;EAE9C,IAAIM,IAAI,EAAE;IACR,OAAO,IAAI;EACb;EAEA,IAAI,CAACC,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,CAAC,+CAA+C,CAAC;EAClE;EAEA,OAAOF,SAAS;AAClB,CAAC;AAACN,OAAA,CAAAI,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|