arc-ux 0.0.10 → 0.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arc-ux",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "A purely functional router for independently evaluating a path against a list of routes",
5
5
  "main": "src/ArcUX.js",
6
6
  "type": "module",
package/src/ArcUX.js CHANGED
@@ -146,6 +146,14 @@ class ArcUX {
146
146
  this.setKeyVal('route', `${this.#rootPath}${_route}`, _suppressEmit);
147
147
  }
148
148
 
149
+ pushURI(_newURI, _replace) {
150
+ const fullHistoryString = decodeURI(_newURI);
151
+ if (_replace) {
152
+ return window.history.replaceState({ code: fullHistoryString }, "", fullHistoryString);
153
+ }
154
+ return window.history.pushState({ code: fullHistoryString }, "", fullHistoryString);
155
+ }
156
+
149
157
  renderModal(_Modal, _props) {
150
158
  this.emit('modal', [_Modal, _props || {}]);
151
159
  }
package/src/Form.js CHANGED
@@ -29,6 +29,7 @@ class Form {
29
29
  this.#form[_name] = _value;
30
30
  this.#validChecks[_name] = _isValid;
31
31
  this.emit('change', [this]);
32
+ this.emit(_name, [_value, _isValid, this]);
32
33
  }
33
34
 
34
35
  modifyField(_name, _value) {
@@ -24,6 +24,12 @@ class App extends React.Component {
24
24
  async componentDidMount() {
25
25
  const initialRoute = this.props.ArcUX.getKeyVal('route');
26
26
 
27
+ window.onpopstate = (_event) => {
28
+ if (_event.state) {
29
+ this.props.ArcUX.loadPage(_event.state.code);
30
+ }
31
+ };
32
+
27
33
  this.props.ArcUX.emit('log', {message: `Our initial route is ${initialRoute}`})
28
34
  const match = this.props.ArcUX.renderRoute(initialRoute);
29
35
  if(match){