@dnb/eufemia 10.1.0 → 10.2.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/cjs/components/anchor/style/deps.scss +9 -0
  3. package/cjs/components/button/style/themes/dnb-button-theme-eiendom.css +4 -0
  4. package/cjs/components/button/style/themes/dnb-button-theme-eiendom.min.css +1 -1
  5. package/cjs/components/button/style/themes/dnb-button-theme-ui.css +4 -0
  6. package/cjs/components/button/style/themes/dnb-button-theme-ui.min.css +1 -1
  7. package/cjs/components/button/style/themes/dnb-button-theme-ui.scss +5 -0
  8. package/cjs/components/global-status/GlobalStatus.d.ts +3 -3
  9. package/cjs/components/heading/Heading.d.ts +89 -106
  10. package/cjs/components/heading/Heading.js +119 -184
  11. package/cjs/components/heading/HeadingContext.d.ts +12 -5
  12. package/cjs/components/heading/HeadingContext.js +2 -2
  13. package/cjs/components/heading/HeadingCounter.d.ts +38 -14
  14. package/cjs/components/heading/HeadingCounter.js +20 -17
  15. package/cjs/components/heading/HeadingHelpers.d.ts +45 -23
  16. package/cjs/components/heading/HeadingHelpers.js +29 -24
  17. package/cjs/components/heading/HeadingProvider.d.ts +9 -12
  18. package/cjs/components/heading/HeadingProvider.js +47 -90
  19. package/cjs/components/info-card/style/dnb-info-card.css +1 -1
  20. package/cjs/components/info-card/style/dnb-info-card.min.css +1 -1
  21. package/cjs/components/info-card/style/dnb-info-card.scss +1 -1
  22. package/cjs/shared/Eufemia.d.ts +1 -1
  23. package/cjs/shared/Eufemia.js +2 -2
  24. package/cjs/shared/index.d.ts +2 -1
  25. package/cjs/style/dnb-ui-components.css +1 -1
  26. package/cjs/style/dnb-ui-components.min.css +1 -1
  27. package/cjs/style/themes/theme-eiendom/eiendom-theme-components.css +9 -1
  28. package/cjs/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
  29. package/cjs/style/themes/theme-sbanken/sbanken-theme-components.css +1 -1
  30. package/cjs/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
  31. package/cjs/style/themes/theme-ui/ui-theme-components.css +5 -1
  32. package/cjs/style/themes/theme-ui/ui-theme-components.min.css +1 -1
  33. package/components/anchor/style/deps.scss +9 -0
  34. package/components/button/style/themes/dnb-button-theme-eiendom.css +4 -0
  35. package/components/button/style/themes/dnb-button-theme-eiendom.min.css +1 -1
  36. package/components/button/style/themes/dnb-button-theme-ui.css +4 -0
  37. package/components/button/style/themes/dnb-button-theme-ui.min.css +1 -1
  38. package/components/button/style/themes/dnb-button-theme-ui.scss +5 -0
  39. package/components/global-status/GlobalStatus.d.ts +3 -3
  40. package/components/heading/Heading.d.ts +89 -106
  41. package/components/heading/Heading.js +115 -183
  42. package/components/heading/HeadingContext.d.ts +12 -5
  43. package/components/heading/HeadingContext.js +2 -2
  44. package/components/heading/HeadingCounter.d.ts +38 -14
  45. package/components/heading/HeadingCounter.js +20 -17
  46. package/components/heading/HeadingHelpers.d.ts +45 -23
  47. package/components/heading/HeadingHelpers.js +27 -13
  48. package/components/heading/HeadingProvider.d.ts +9 -12
  49. package/components/heading/HeadingProvider.js +46 -90
  50. package/components/info-card/style/dnb-info-card.css +1 -1
  51. package/components/info-card/style/dnb-info-card.min.css +1 -1
  52. package/components/info-card/style/dnb-info-card.scss +1 -1
  53. package/es/components/anchor/style/deps.scss +9 -0
  54. package/es/components/button/style/themes/dnb-button-theme-eiendom.css +4 -0
  55. package/es/components/button/style/themes/dnb-button-theme-eiendom.min.css +1 -1
  56. package/es/components/button/style/themes/dnb-button-theme-ui.css +4 -0
  57. package/es/components/button/style/themes/dnb-button-theme-ui.min.css +1 -1
  58. package/es/components/button/style/themes/dnb-button-theme-ui.scss +5 -0
  59. package/es/components/global-status/GlobalStatus.d.ts +3 -3
  60. package/es/components/heading/Heading.d.ts +89 -106
  61. package/es/components/heading/Heading.js +115 -183
  62. package/es/components/heading/HeadingContext.d.ts +12 -5
  63. package/es/components/heading/HeadingContext.js +2 -2
  64. package/es/components/heading/HeadingCounter.d.ts +38 -14
  65. package/es/components/heading/HeadingCounter.js +19 -18
  66. package/es/components/heading/HeadingHelpers.d.ts +45 -23
  67. package/es/components/heading/HeadingHelpers.js +27 -13
  68. package/es/components/heading/HeadingProvider.d.ts +9 -12
  69. package/es/components/heading/HeadingProvider.js +46 -90
  70. package/es/components/info-card/style/dnb-info-card.css +1 -1
  71. package/es/components/info-card/style/dnb-info-card.min.css +1 -1
  72. package/es/components/info-card/style/dnb-info-card.scss +1 -1
  73. package/es/shared/Eufemia.d.ts +1 -1
  74. package/es/shared/Eufemia.js +2 -2
  75. package/es/shared/index.d.ts +2 -1
  76. package/es/style/dnb-ui-components.css +1 -1
  77. package/es/style/dnb-ui-components.min.css +1 -1
  78. package/es/style/themes/theme-eiendom/eiendom-theme-components.css +9 -1
  79. package/es/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
  80. package/es/style/themes/theme-sbanken/sbanken-theme-components.css +1 -1
  81. package/es/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
  82. package/es/style/themes/theme-ui/ui-theme-components.css +5 -1
  83. package/es/style/themes/theme-ui/ui-theme-components.min.css +1 -1
  84. package/esm/dnb-ui-basis.min.mjs +1 -1
  85. package/esm/dnb-ui-components.min.mjs +1 -1
  86. package/esm/dnb-ui-elements.min.mjs +1 -1
  87. package/esm/dnb-ui-extensions.min.mjs +1 -1
  88. package/esm/dnb-ui-lib.min.mjs +1 -1
  89. package/package.json +1 -1
  90. package/shared/Eufemia.d.ts +1 -1
  91. package/shared/Eufemia.js +2 -2
  92. package/shared/index.d.ts +2 -1
  93. package/style/dnb-ui-components.css +1 -1
  94. package/style/dnb-ui-components.min.css +1 -1
  95. package/style/themes/theme-eiendom/eiendom-theme-components.css +9 -1
  96. package/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
  97. package/style/themes/theme-sbanken/sbanken-theme-components.css +1 -1
  98. package/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
  99. package/style/themes/theme-ui/ui-theme-components.css +5 -1
  100. package/style/themes/theme-ui/ui-theme-components.min.css +1 -1
  101. package/umd/dnb-ui-basis.min.js +1 -1
  102. package/umd/dnb-ui-components.min.js +1 -1
  103. package/umd/dnb-ui-elements.min.js +1 -1
  104. package/umd/dnb-ui-extensions.min.js +1 -1
  105. package/umd/dnb-ui-lib.min.js +1 -1
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.levelResolution = exports.default = void 0;
6
+ exports.default = Heading;
7
+ exports.levelResolution = void 0;
7
8
  Object.defineProperty(exports, "resetAllLevels", {
8
9
  enumerable: true,
9
10
  get: function () {
@@ -25,8 +26,6 @@ Object.defineProperty(exports, "setNextLevel", {
25
26
 
26
27
  var _react = _interopRequireDefault(require("react"));
27
28
 
28
- var _propTypes = _interopRequireDefault(require("prop-types"));
29
-
30
29
  var _classnames = _interopRequireDefault(require("classnames"));
31
30
 
32
31
  var _componentHelper = require("../../shared/component-helper");
@@ -47,7 +46,7 @@ var _HeadingHelpers = require("./HeadingHelpers");
47
46
 
48
47
  var _HeadingCounter = require("./HeadingCounter");
49
48
 
50
- const _excluded = ["text", "relevel", "group", "debug", "debug_counter", "reset", "skip_correction", "increase", "decrease", "up", "down", "inherit", "level", "size", "skeleton", "element", "class", "className", "children"];
49
+ const _excluded = ["text", "group", "debug", "debug_counter", "reset", "skip_correction", "increase", "decrease", "up", "down", "inherit", "level", "size", "skeleton", "element", "className", "children"];
51
50
 
52
51
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
53
52
 
@@ -57,12 +56,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
57
56
 
58
57
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
59
58
 
59
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
60
+
60
61
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
61
62
 
62
63
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
63
64
 
64
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
65
-
66
65
  const levelResolution = {
67
66
  1: 'xx-large',
68
67
  2: 'large',
@@ -73,207 +72,143 @@ const levelResolution = {
73
72
  };
74
73
  exports.levelResolution = levelResolution;
75
74
 
76
- class Heading extends _react.default.PureComponent {
77
- static getDerivedStateFromProps(props, state) {
78
- if (state._listenForPropChanges) {
79
- const level = parseFloat(props.level);
80
-
81
- if (state.prevLevel !== props.level && level > 0 && level !== state.level || props.relevel) {
82
- var _state$context$headin, _state$context$headin2;
83
-
84
- state.counter.skipMakeMeReady();
85
- const {
86
- level: newLevel
87
- } = (0, _HeadingHelpers.correctHeadingLevel)({
88
- counter: state.counter,
89
- level,
90
- bypassChecks: (0, _componentHelper.isTrue)(props.skip_correction) || (0, _componentHelper.isTrue)((_state$context$headin = state.context.heading) === null || _state$context$headin === void 0 ? void 0 : _state$context$headin.skip_correction),
91
- source: props.text || props.children,
92
- debug: props.debug || ((_state$context$headin2 = state.context.heading) === null || _state$context$headin2 === void 0 ? void 0 : _state$context$headin2.debug)
93
- });
94
- state.level = state.prevLevel = newLevel;
95
- }
96
- }
75
+ function Heading(props) {
76
+ var _headingContext$headi2, _headingContext$headi3;
77
+
78
+ const context = _react.default.useContext(_Context.default);
79
+
80
+ const headingContext = _react.default.useContext(_HeadingContext.default);
81
+
82
+ const _ref = _react.default.useRef();
83
+
84
+ const {
85
+ text,
86
+ group: _group,
87
+ debug: _debug,
88
+ debug_counter: _debug_counter,
89
+ reset: _reset,
90
+ skip_correction: _skip_correction,
91
+ increase: _increase,
92
+ decrease: _decrease,
93
+ up: _up,
94
+ down: _down,
95
+ inherit: _inherit,
96
+ level: _level,
97
+ size: _size = 'auto',
98
+ skeleton: _skeleton,
99
+ element: _element,
100
+ className,
101
+ children
102
+ } = props,
103
+ rest = _objectWithoutProperties(props, _excluded);
104
+
105
+ const [state, setState] = _react.default.useState(() => {
106
+ var _headingContext$headi, _state$headingContext, _state$headingContext2, _state$headingContext3, _state$headingContext4;
97
107
 
98
- state._listenForPropChanges = true;
99
- return state;
100
- }
101
-
102
- constructor(props, context) {
103
- var _context$heading, _state$context$headin3, _state$context$headin4;
104
-
105
- super(props);
106
- this._ref = _react.default.createRef();
107
108
  const state = {
109
+ level: null,
110
+ counter: null,
108
111
  context,
109
- _listenForPropChanges: true
112
+ headingContext
110
113
  };
111
-
112
- if ((_context$heading = context.heading) !== null && _context$heading !== void 0 && _context$heading.counter) {
113
- state.counter = (0, _HeadingCounter.initCounter)(props);
114
- state.counter.setContextCounter(context.heading.counter);
115
- state.counter.isHeading = true;
116
- } else {
117
- state.counter = (0, _HeadingCounter.initCounter)(props);
118
- state.counter.setContextCounter(_HeadingHelpers.globalHeadingCounter.current);
119
- state.counter.isHeading = true;
120
- }
121
-
122
- state.counter = (0, _HeadingHelpers.correctHeadingLevel)({
123
- ref: props,
114
+ state.counter = (0, _HeadingCounter.initCounter)(props);
115
+ const counter = (_headingContext$headi = headingContext.heading) !== null && _headingContext$headi !== void 0 && _headingContext$headi.counter ? headingContext.heading.counter : _HeadingHelpers.globalHeadingCounter.current;
116
+ state.counter.setContextCounter(counter);
117
+ state.counter.isHeading = true;
118
+ state.counter = (0, _HeadingHelpers.correctInternalHeadingLevel)({
124
119
  counter: state.counter,
125
- level: parseFloat(props.level),
120
+ ref: props,
121
+ level: parseFloat(String(props.level)),
126
122
  inherit: (0, _componentHelper.isTrue)(props.inherit),
127
123
  reset: props.reset,
128
124
  increase: (0, _componentHelper.isTrue)(props.increase) || (0, _componentHelper.isTrue)(props.up),
129
125
  decrease: (0, _componentHelper.isTrue)(props.decrease) || (0, _componentHelper.isTrue)(props.down),
130
- bypassChecks: (0, _componentHelper.isTrue)(props.skip_correction) || (0, _componentHelper.isTrue)((_state$context$headin3 = state.context.heading) === null || _state$context$headin3 === void 0 ? void 0 : _state$context$headin3.skip_correction),
126
+ bypassChecks: (0, _componentHelper.isTrue)(props.skip_correction) || (0, _componentHelper.isTrue)((_state$headingContext = state.headingContext) === null || _state$headingContext === void 0 ? void 0 : (_state$headingContext2 = _state$headingContext.heading) === null || _state$headingContext2 === void 0 ? void 0 : _state$headingContext2.skip_correction),
131
127
  source: props.text || props.children,
132
- debug: props.debug || ((_state$context$headin4 = state.context.heading) === null || _state$context$headin4 === void 0 ? void 0 : _state$context$headin4.debug)
128
+ debug: props.debug || ((_state$headingContext3 = state.headingContext) === null || _state$headingContext3 === void 0 ? void 0 : (_state$headingContext4 = _state$headingContext3.heading) === null || _state$headingContext4 === void 0 ? void 0 : _state$headingContext4.debug)
133
129
  });
134
130
  _HeadingHelpers.globalSyncCounter.current = state.counter;
135
131
  state.level = state.counter.level;
136
- state.prevLevel = props.level;
137
- this.state = state;
138
- }
132
+ state.prevLevel = parseFloat(String(props.level));
133
+ return state;
134
+ });
139
135
 
140
- componentDidMount() {
136
+ _react.default.useEffect(() => {
141
137
  (0, _HeadingHelpers.windupHeadings)();
142
- this.state.counter.windup();
143
- }
138
+ state.counter.windup();
139
+ return () => {
140
+ (0, _HeadingHelpers.teardownHeadings)();
141
+ state.counter.teardown();
142
+ };
143
+ }, []);
144
+
145
+ _react.default.useEffect(() => {
146
+ const level = parseFloat(String(props.level));
147
+
148
+ if (state.prevLevel !== props.level && level > 0 && level !== state.level) {
149
+ var _state$headingContext5, _state$headingContext6, _state$headingContext7, _state$headingContext8;
150
+
151
+ const {
152
+ level: newLevel
153
+ } = (0, _HeadingHelpers.correctInternalHeadingLevel)({
154
+ counter: state.counter,
155
+ isRerender: true,
156
+ level,
157
+ bypassChecks: (0, _componentHelper.isTrue)(props.skip_correction) || (0, _componentHelper.isTrue)((_state$headingContext5 = state.headingContext) === null || _state$headingContext5 === void 0 ? void 0 : (_state$headingContext6 = _state$headingContext5.heading) === null || _state$headingContext6 === void 0 ? void 0 : _state$headingContext6.skip_correction),
158
+ source: props.text || props.children,
159
+ debug: props.debug || ((_state$headingContext7 = state.headingContext) === null || _state$headingContext7 === void 0 ? void 0 : (_state$headingContext8 = _state$headingContext7.heading) === null || _state$headingContext8 === void 0 ? void 0 : _state$headingContext8.debug)
160
+ });
161
+ state.level = state.prevLevel = newLevel;
162
+ setState(_objectSpread({}, state));
163
+ }
164
+ }, [props.level]);
165
+
166
+ let {
167
+ size,
168
+ element = 'auto',
169
+ skeleton
170
+ } = props;
171
+ const {
172
+ level
173
+ } = state;
174
+ const debug = _debug || (headingContext === null || headingContext === void 0 ? void 0 : (_headingContext$headi2 = headingContext.heading) === null || _headingContext$headi2 === void 0 ? void 0 : _headingContext$headi2.debug);
175
+ const debug_counter = _debug_counter || (headingContext === null || headingContext === void 0 ? void 0 : (_headingContext$headi3 = headingContext.heading) === null || _headingContext$headi3 === void 0 ? void 0 : _headingContext$headi3.debug_counter);
176
+
177
+ const attributes = _objectSpread({}, rest);
178
+
179
+ if (element === 'auto' || element === null) {
180
+ element = `h${level || 'x-small'}`;
181
+
182
+ if (_size === 'auto' || _size === null) {
183
+ size = levelResolution[level || 'x-small'];
184
+ }
185
+ } else {
186
+ if (!attributes.role) {
187
+ attributes.role = 'heading';
188
+ }
144
189
 
145
- componentWillUnmount() {
146
- (0, _HeadingHelpers.teardownHeadings)();
147
- this.state.counter.teardown();
190
+ if (!attributes['aria-level']) {
191
+ attributes['aria-level'] = String(level);
192
+ }
148
193
  }
149
194
 
150
- render() {
151
- var _this$context$heading, _this$context$heading2;
152
-
153
- const _this$props = this.props,
154
- {
155
- text,
156
- relevel: _relevel,
157
- group: _group,
158
- debug: _debug,
159
- debug_counter: _debug_counter,
160
- reset: _reset,
161
- skip_correction: _skip_correction,
162
- increase: _increase,
163
- decrease: _decrease,
164
- up: _up,
165
- down: _down,
166
- inherit: _inherit,
167
- level: _level,
168
- size: _size,
169
- skeleton: _skeleton,
170
- element: _element,
171
- class: _className,
172
- className,
173
- children
174
- } = _this$props,
175
- rest = _objectWithoutProperties(_this$props, _excluded);
176
-
177
- let {
178
- size,
179
- element,
180
- skeleton
181
- } = this.props;
182
- const {
183
- level
184
- } = this.state;
185
- const debug = _debug || ((_this$context$heading = this.context.heading) === null || _this$context$heading === void 0 ? void 0 : _this$context$heading.debug);
186
- const debug_counter = _debug_counter || ((_this$context$heading2 = this.context.heading) === null || _this$context$heading2 === void 0 ? void 0 : _this$context$heading2.debug_counter);
187
-
188
- const attributes = _objectSpread({}, rest);
189
-
190
- if (element === 'auto' || element === null) {
191
- element = `h${level || '6'}`;
192
-
193
- if (_size === 'auto' || _size === null) {
194
- size = levelResolution[level || '6'];
195
- }
196
- } else {
197
- if (!attributes.role) {
198
- attributes.role = 'heading';
199
- }
200
-
201
- if (!attributes['aria-level']) {
202
- attributes['aria-level'] = String(level);
203
- }
204
- }
195
+ (0, _componentHelper.validateDOMAttributes)(props, attributes);
205
196
 
206
- (0, _componentHelper.validateDOMAttributes)(this.props, attributes);
207
- const Element = element;
208
- return _react.default.createElement(_Context.default.Consumer, null, context => {
209
- if (typeof (context === null || context === void 0 ? void 0 : context.skeleton) !== 'undefined') {
210
- skeleton = context.skeleton;
211
- }
212
-
213
- attributes.className = (0, _classnames.default)(`dnb-heading dnb-h--${size}`, (0, _SkeletonHelper.createSkeletonClass)('font', skeleton, this.context), className, _className, (0, _SpacingHelper.createSpacingClasses)(this.props));
214
- attributes.children = _react.default.createElement(_react.default.Fragment, null, debug && _react.default.createElement("span", {
215
- className: "dnb-heading__debug"
216
- }, `[h${level || '6'}] `, debug_counter && _react.default.createElement(_react.default.Fragment, null, ' ', _react.default.createElement("span", {
217
- className: "dnb-code"
218
- }, (0, _HeadingHelpers.debugCounter)(this.state.counter)))), text || children);
219
- return _react.default.createElement(Element, _extends({
220
- ref: this._ref
221
- }, attributes));
222
- });
197
+ if (typeof (context === null || context === void 0 ? void 0 : context.skeleton) !== 'undefined') {
198
+ skeleton = context.skeleton;
223
199
  }
224
200
 
201
+ const Element = element;
202
+ return _react.default.createElement(Element, _extends({}, attributes, {
203
+ ref: _ref,
204
+ className: (0, _classnames.default)(`dnb-heading dnb-h--${size}`, (0, _SkeletonHelper.createSkeletonClass)('font', skeleton, headingContext), className, (0, _SpacingHelper.createSpacingClasses)(props))
205
+ }), debug && _react.default.createElement("span", {
206
+ className: "dnb-heading__debug"
207
+ }, `[h${level || '6'}] `, debug_counter && _react.default.createElement(_react.default.Fragment, null, ' ', _react.default.createElement("span", {
208
+ className: "dnb-code"
209
+ }, (0, _HeadingHelpers.debugCounter)(state.counter)))), text || children);
225
210
  }
226
211
 
227
- exports.default = Heading;
228
-
229
- _defineProperty(Heading, "contextType", _HeadingContext.default);
230
-
231
- _defineProperty(Heading, "defaultProps", {
232
- id: null,
233
- group: null,
234
- text: null,
235
- size: 'auto',
236
- level: null,
237
- increase: null,
238
- decrease: null,
239
- up: null,
240
- down: null,
241
- skip_correction: null,
242
- debug: null,
243
- debug_counter: null,
244
- counter: null,
245
- reset: null,
246
- inherit: null,
247
- skeleton: null,
248
- element: 'auto',
249
- class: null,
250
- className: null,
251
- children: null
252
- });
253
-
254
- process.env.NODE_ENV !== "production" ? Heading.propTypes = _objectSpread(_objectSpread({
255
- id: _propTypes.default.string,
256
- group: _propTypes.default.string,
257
- text: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
258
- size: _propTypes.default.oneOf(['auto', 'xx-large', 'x-large', 'large', 'medium', 'basis', 'small', 'x-small']),
259
- level: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
260
- increase: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
261
- decrease: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
262
- up: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
263
- down: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
264
- skip_correction: _propTypes.default.bool,
265
- debug: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.func]),
266
- debug_counter: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.func]),
267
- counter: _propTypes.default.any,
268
- inherit: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
269
- reset: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string, _propTypes.default.bool]),
270
- skeleton: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
271
- element: _propTypes.default.string
272
- }, _SpacingHelper.spacingPropTypes), {}, {
273
- class: _propTypes.default.string,
274
- className: _propTypes.default.string,
275
- children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
276
- }) : void 0;
277
212
  Heading.Level = _HeadingProvider.default;
278
213
 
279
214
  Heading.Increase = props => _react.default.createElement(_HeadingProvider.default, _extends({
@@ -1,5 +1,12 @@
1
- export default Context;
2
- declare const Context: React.Context<{
3
- heading: any;
4
- }>;
5
- import React from "react";
1
+ /**
2
+ * Web Heading Context
3
+ *
4
+ */
5
+ import React from 'react';
6
+ import { SkeletonContextProps } from '../skeleton/SkeletonHelper';
7
+ import { HeadingProps } from './Heading';
8
+ export declare type HeadingContextProps = {
9
+ heading?: HeadingProps;
10
+ } & SkeletonContextProps;
11
+ declare const HeadingContext: React.Context<HeadingContextProps>;
12
+ export default HeadingContext;
@@ -9,9 +9,9 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- const Context = _react.default.createContext({
12
+ const HeadingContext = _react.default.createContext({
13
13
  heading: null
14
14
  });
15
15
 
16
- var _default = Context;
16
+ var _default = HeadingContext;
17
17
  exports.default = _default;
@@ -1,18 +1,42 @@
1
- export function initCounter(props?: any): any;
2
- export class Counter {
3
- constructor(props?: any);
4
- level: number;
5
- entry: number;
1
+ /**
2
+ * Web Heading Counter Instance
3
+ *
4
+ */
5
+ import { HeadingAllProps, InternalHeadingLevel } from './Heading';
6
+ export declare type HeadingCounter = Counter;
7
+ export declare type HeadingDebugCounter = boolean | (() => void);
8
+ export declare type ContextCounter = {
9
+ level: InternalHeadingLevel;
10
+ entry: InternalHeadingLevel;
11
+ countHeadings: number;
12
+ _initCount: number;
13
+ _isReady: boolean;
14
+ isGlobal?: boolean;
15
+ };
16
+ export declare const initCounter: (props?: CounterProps) => Counter;
17
+ export declare type CounterGroup = HeadingAllProps['group'];
18
+ export declare type CounterChildren = HeadingAllProps['children'];
19
+ export declare type CounterProps = {
20
+ isGlobal?: boolean;
21
+ group?: CounterGroup;
22
+ children?: CounterChildren;
23
+ counter?: CounterProps;
24
+ };
25
+ export declare class Counter {
26
+ level: InternalHeadingLevel;
27
+ entry: InternalHeadingLevel;
28
+ lastResetLevel: InternalHeadingLevel;
6
29
  _isReady: boolean;
7
30
  countHeadings: number;
8
31
  _initCount: number;
9
32
  isGlobal: boolean;
10
33
  isHeading: boolean;
11
34
  bypassChecks: boolean;
12
- contextCounter: any;
35
+ contextCounter: ContextCounter;
13
36
  reports: any[];
14
- group: any;
15
- children: any;
37
+ group: CounterGroup;
38
+ children: CounterChildren;
39
+ constructor(props?: CounterProps);
16
40
  report(...str: any[]): void;
17
41
  useLastReport(): any;
18
42
  enableBypassChecks(): void;
@@ -20,23 +44,23 @@ export class Counter {
20
44
  getLevel(): number;
21
45
  hasEntryLevel(): boolean;
22
46
  hasCorrection(): boolean;
23
- setEntryLevel(level?: any): void;
47
+ setEntryLevel(level?: InternalHeadingLevel): void;
24
48
  isInContext(): boolean;
25
- setContextCounter(contextCounter: any): void;
26
- skipMakeMeReady(): void;
49
+ setContextCounter(contextCounter: ContextCounter): void;
27
50
  windup(): void;
28
51
  teardown(): void;
29
- makeMeReady(): void;
52
+ makeMeReady({ level }?: {
53
+ level?: InternalHeadingLevel;
54
+ }): void;
30
55
  factorCheck({ action, level, current, report }: {
31
56
  action: any;
32
57
  level: any;
33
58
  current: any;
34
59
  report: any;
35
60
  }): any;
36
- setLevel(level: any, action?: string): void;
61
+ setLevel(level: InternalHeadingLevel, action?: string): void;
37
62
  increment(): void;
38
63
  decrement(): void;
39
64
  force(level?: number): void;
40
65
  reset(toLevel?: any): void;
41
- lastResetLevel: any;
42
66
  }
@@ -19,7 +19,11 @@ const initCounter = function () {
19
19
  });
20
20
  }
21
21
 
22
- return props && props.counter || new Counter(props);
22
+ if (props !== null && props !== void 0 && props.counter) {
23
+ return props.counter;
24
+ }
25
+
26
+ return new Counter(props);
23
27
  };
24
28
 
25
29
  exports.initCounter = initCounter;
@@ -32,6 +36,8 @@ class Counter {
32
36
 
33
37
  _defineProperty(this, "entry", 0);
34
38
 
39
+ _defineProperty(this, "lastResetLevel", null);
40
+
35
41
  _defineProperty(this, "_isReady", false);
36
42
 
37
43
  _defineProperty(this, "countHeadings", 0);
@@ -48,6 +54,10 @@ class Counter {
48
54
 
49
55
  _defineProperty(this, "reports", []);
50
56
 
57
+ _defineProperty(this, "group", null);
58
+
59
+ _defineProperty(this, "children", null);
60
+
51
61
  props = props || {};
52
62
 
53
63
  if (props.group) {
@@ -97,7 +107,7 @@ class Counter {
97
107
 
98
108
  setEntryLevel() {
99
109
  let level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
100
- this.entry = parseFloat(level) || 1;
110
+ this.entry = parseFloat(String(level)) || 1;
101
111
  }
102
112
 
103
113
  isInContext() {
@@ -108,13 +118,6 @@ class Counter {
108
118
  this.contextCounter = contextCounter;
109
119
  }
110
120
 
111
- skipMakeMeReady() {
112
- this._isReady = true;
113
- this.entry = 1;
114
- this.level = 1;
115
- this.contextCounter.entry = 2;
116
- }
117
-
118
121
  windup() {
119
122
  this.contextCounter.countHeadings++;
120
123
  }
@@ -129,6 +132,10 @@ class Counter {
129
132
  }
130
133
 
131
134
  makeMeReady() {
135
+ let {
136
+ level
137
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
138
+
132
139
  if (!this.hasCorrection()) {
133
140
  if (this.contextCounter.level > 1) {
134
141
  this.level = this.contextCounter.level;
@@ -139,7 +146,7 @@ class Counter {
139
146
  } else if (!this.contextCounter._isReady) {
140
147
  this.contextCounter._isReady = true;
141
148
 
142
- if (!this.bypassChecks) {
149
+ if (!this.bypassChecks && !level) {
143
150
  this.level = 1;
144
151
  }
145
152
  }
@@ -191,19 +198,15 @@ class Counter {
191
198
  var _globalSyncCounter$cu;
192
199
 
193
200
  let action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'set';
194
- level = parseFloat(level);
201
+ level = parseFloat(String(level));
195
202
  const report = [];
196
203
 
197
- if (!this._isReady && this.level === 1 && (!_HeadingHelpers.globalSyncCounter.current || _HeadingHelpers.globalSyncCounter.current.level < 2)) {
198
- return;
199
- }
200
-
201
204
  if (((_globalSyncCounter$cu = _HeadingHelpers.globalSyncCounter.current) === null || _globalSyncCounter$cu === void 0 ? void 0 : _globalSyncCounter$cu.level) > 0) {
202
205
  level = this.factorCheck({
203
- report,
204
206
  action,
205
207
  level,
206
- current: _HeadingHelpers.globalSyncCounter.current.level
208
+ current: _HeadingHelpers.globalSyncCounter.current.level,
209
+ report
207
210
  });
208
211
  }
209
212
 
@@ -1,27 +1,49 @@
1
- export function resetAllLevels(): void;
2
- export function resetLevels(level: any, { overwriteContext }?: {
1
+ /**
2
+ * Web Heading Counter
3
+ *
4
+ */
5
+ import { HeadingAllProps, InternalHeadingLevel } from './Heading';
6
+ import { HeadingCounter } from './HeadingCounter';
7
+ declare type GlobalSyncCounter = {
8
+ current: HeadingCounter;
9
+ };
10
+ declare type GlobalHeadingCounter = {
11
+ current: HeadingCounter;
12
+ };
13
+ export declare const globalSyncCounter: GlobalSyncCounter;
14
+ export declare const globalHeadingCounter: GlobalHeadingCounter;
15
+ declare type CorrectInternalHeadingLevel = {
16
+ counter: HeadingCounter;
17
+ level: InternalHeadingLevel;
18
+ ref?: HeadingAllProps;
19
+ reset?: HeadingAllProps['reset'];
20
+ inherit?: boolean;
21
+ increase?: boolean;
22
+ decrease?: boolean;
23
+ source?: HeadingAllProps['children'];
24
+ bypassChecks?: boolean;
25
+ isRerender?: boolean;
26
+ debug?: HeadingAllProps['debug'];
27
+ };
28
+ export declare const correctInternalHeadingLevel: ({ counter, level, ref, reset, inherit, increase, decrease, source, bypassChecks, isRerender, debug, }: CorrectInternalHeadingLevel) => import("./HeadingCounter").Counter;
29
+ export declare function resetAllLevels(): void;
30
+ export declare const globalResetNextTime: {
31
+ current: GlobalNextLevel;
32
+ };
33
+ export declare function resetLevels(level: InternalHeadingLevel, { overwriteContext }?: {
3
34
  overwriteContext?: boolean;
4
35
  }): void;
5
- export function setNextLevel(level: any, { overwriteContext }?: {
36
+ declare type GlobalNextLevel = {
37
+ level: InternalHeadingLevel;
38
+ overwriteContext: boolean;
39
+ };
40
+ export declare const globalNextLevel: {
41
+ current: GlobalNextLevel;
42
+ };
43
+ export declare function setNextLevel(level: InternalHeadingLevel, { overwriteContext }?: {
6
44
  overwriteContext?: boolean;
7
45
  }): void;
8
- export function windupHeadings(): void;
9
- export function teardownHeadings(): void;
10
- export function debugCounter(counter: any): string;
11
- export const globalSyncCounter: React.RefObject<any>;
12
- export const globalHeadingCounter: React.RefObject<any>;
13
- export function correctHeadingLevel({ counter, level, ref, reset, inherit, increase, decrease, source, bypassChecks, debug, }: {
14
- counter: any;
15
- level: any;
16
- ref?: any;
17
- reset?: any;
18
- inherit?: any;
19
- increase?: boolean;
20
- decrease?: boolean;
21
- source?: any;
22
- bypassChecks?: boolean;
23
- debug?: any;
24
- }): any;
25
- export const globalResetNextTime: React.RefObject<any>;
26
- export const globalNextLevel: React.RefObject<any>;
27
- import React from "react";
46
+ export declare function windupHeadings(): void;
47
+ export declare function teardownHeadings(): void;
48
+ export declare function debugCounter(counter: any): string;
49
+ export {};