@jobber/hooks 1.9.2-pre.27 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -4
- package/dist/useCollectionQuery/useCollectionQuery.d.ts +1 -1
- package/dist/useLiveAnnounce/index.d.ts +1 -0
- package/dist/useLiveAnnounce/index.js +4 -0
- package/dist/useLiveAnnounce/useLiveAnnounce.d.ts +8 -0
- package/dist/useLiveAnnounce/useLiveAnnounce.js +57 -0
- package/dist/useLiveAnnounce/useLiveAnnounce.test.d.ts +1 -0
- package/dist/useLiveAnnounce/useLiveAnnounce.test.js +121 -0
- package/dist/usePasswordStrength/usePasswordStrength.d.ts +1 -4
- package/dist/useResizeObserver/index.d.ts +1 -0
- package/dist/useResizeObserver/index.js +6 -0
- package/dist/{useResizeObserver.d.ts → useResizeObserver/useResizeObserver.d.ts} +0 -0
- package/dist/{useResizeObserver.js → useResizeObserver/useResizeObserver.js} +0 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,28 @@ menu: Changelog
|
|
|
8
8
|
All notable changes to this project will be documented in this file.
|
|
9
9
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
10
10
|
|
|
11
|
+
# [1.11.0](https://github.com/GetJobber/atlantis/compare/@jobber/hooks@1.10.0...@jobber/hooks@1.11.0) (2022-01-28)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* Announce chip deletion and addition JOB-41252 ([#848](https://github.com/GetJobber/atlantis/issues/848)) ([f251b42](https://github.com/GetJobber/atlantis/commit/f251b42c5aa98ee07f7e16d3605a6bd965a8231b))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [1.10.0](https://github.com/GetJobber/atlantis/compare/@jobber/hooks@1.9.1...@jobber/hooks@1.10.0) (2022-01-21)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **hooks:** Create the hooks index dynamically ([#839](https://github.com/GetJobber/atlantis/issues/839)) ([dc770a8](https://github.com/GetJobber/atlantis/commit/dc770a813268cc2f3d011e2a559761043ae398ab))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
11
33
|
## [1.9.1](https://github.com/GetJobber/atlantis/compare/@jobber/hooks@1.9.0...@jobber/hooks@1.9.1) (2021-12-15)
|
|
12
34
|
|
|
13
35
|
**Note:** Version bump only for package @jobber/hooks
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./useFormState";
|
|
3
|
-
export * from "./useOnKeyDown";
|
|
1
|
+
export * from "./useAssert";
|
|
4
2
|
export * from "./useCollectionQuery";
|
|
3
|
+
export * from "./useFormState";
|
|
5
4
|
export * from "./useIsMounted";
|
|
5
|
+
export * from "./useLiveAnnounce";
|
|
6
|
+
export * from "./useOnKeyDown";
|
|
6
7
|
export * from "./usePasswordStrength";
|
|
7
8
|
export * from "./useRefocusOnActivator";
|
|
8
|
-
export * from "./
|
|
9
|
+
export * from "./useResizeObserver";
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,12 @@ function __export(m) {
|
|
|
3
3
|
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
4
|
}
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
__export(require("./
|
|
7
|
-
__export(require("./useFormState"));
|
|
8
|
-
__export(require("./useOnKeyDown"));
|
|
6
|
+
__export(require("./useAssert"));
|
|
9
7
|
__export(require("./useCollectionQuery"));
|
|
8
|
+
__export(require("./useFormState"));
|
|
10
9
|
__export(require("./useIsMounted"));
|
|
10
|
+
__export(require("./useLiveAnnounce"));
|
|
11
|
+
__export(require("./useOnKeyDown"));
|
|
11
12
|
__export(require("./usePasswordStrength"));
|
|
12
13
|
__export(require("./useRefocusOnActivator"));
|
|
13
|
-
__export(require("./
|
|
14
|
+
__export(require("./useResizeObserver"));
|
|
@@ -7,7 +7,7 @@ interface UseCollectionQueryArguments<TQuery, TSubscription> {
|
|
|
7
7
|
*/
|
|
8
8
|
query: DocumentNode;
|
|
9
9
|
/**
|
|
10
|
-
* A list of options for us to pass into the apollo `useQuery` hook
|
|
10
|
+
* A list of options for us to pass into the apollo `useQuery` hook
|
|
11
11
|
*/
|
|
12
12
|
queryOptions?: QueryHookOptions<TQuery>;
|
|
13
13
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLiveAnnounce } from "./useLiveAnnounce";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Announce a message on voice over whenever you do an action. This is
|
|
3
|
+
* especially helpful when you have an action that adds or deletes an element
|
|
4
|
+
* from the screen.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useLiveAnnounce(): {
|
|
7
|
+
liveAnnounce: (message: string) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var react_1 = require("react");
|
|
20
|
+
/**
|
|
21
|
+
* Announce a message on voice over whenever you do an action. This is
|
|
22
|
+
* especially helpful when you have an action that adds or deletes an element
|
|
23
|
+
* from the screen.
|
|
24
|
+
*/
|
|
25
|
+
function useLiveAnnounce() {
|
|
26
|
+
var _a = __read(react_1.useState(""), 2), announcedMessage = _a[0], setAnnouncedMessage = _a[1];
|
|
27
|
+
react_1.useEffect(function () {
|
|
28
|
+
var target;
|
|
29
|
+
if (announcedMessage) {
|
|
30
|
+
target = createAnnouncedElement();
|
|
31
|
+
setTimeout(function () { return target.append(announcedMessage); }, 100);
|
|
32
|
+
}
|
|
33
|
+
return function () { return target === null || target === void 0 ? void 0 : target.remove(); };
|
|
34
|
+
}, [announcedMessage]);
|
|
35
|
+
return {
|
|
36
|
+
liveAnnounce: function (message) {
|
|
37
|
+
setAnnouncedMessage(message);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.useLiveAnnounce = useLiveAnnounce;
|
|
42
|
+
// eslint-disable-next-line max-statements
|
|
43
|
+
function createAnnouncedElement() {
|
|
44
|
+
var el = document.createElement("div");
|
|
45
|
+
el.style.position = "absolute";
|
|
46
|
+
el.style.width = "1px";
|
|
47
|
+
el.style.height = "1px";
|
|
48
|
+
el.style.overflow = "hidden";
|
|
49
|
+
el.style.clipPath = " inset(100%)";
|
|
50
|
+
el.style.whiteSpace = " nowrap";
|
|
51
|
+
el.style.top = "0";
|
|
52
|
+
el.setAttribute("role", "status");
|
|
53
|
+
el.setAttribute("aria-atomic", "true");
|
|
54
|
+
el.setAttribute("aria-live", "assertive");
|
|
55
|
+
document.body.appendChild(el);
|
|
56
|
+
return el;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = __importDefault(require("react"));
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
var _1 = require(".");
|
|
56
|
+
function setupHook() {
|
|
57
|
+
var returnVal = {
|
|
58
|
+
liveAnnounce: jest.fn,
|
|
59
|
+
};
|
|
60
|
+
function TestComponent() {
|
|
61
|
+
Object.assign(returnVal, _1.useLiveAnnounce());
|
|
62
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
63
|
+
}
|
|
64
|
+
var rerender = react_2.render(react_1.default.createElement(TestComponent, null)).rerender;
|
|
65
|
+
return __assign(__assign({}, returnVal), { rerenderComponent: function () { return rerender(react_1.default.createElement(TestComponent, null)); } });
|
|
66
|
+
}
|
|
67
|
+
it("should render a div to announce", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
+
var liveAnnounce, message;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
liveAnnounce = setupHook().liveAnnounce;
|
|
73
|
+
message = "Huzzah";
|
|
74
|
+
react_2.act(function () { return liveAnnounce(message); });
|
|
75
|
+
return [4 /*yield*/, react_2.waitFor(function () {
|
|
76
|
+
var expectedElement = react_2.screen.queryByRole("status");
|
|
77
|
+
expect(expectedElement).toBeInTheDocument();
|
|
78
|
+
expect(expectedElement === null || expectedElement === void 0 ? void 0 : expectedElement.textContent).toBe(message);
|
|
79
|
+
expect(expectedElement).toHaveAttribute("role", "status");
|
|
80
|
+
expect(expectedElement).toHaveAttribute("aria-atomic", "true");
|
|
81
|
+
expect(expectedElement).toHaveAttribute("aria-live", "assertive");
|
|
82
|
+
})];
|
|
83
|
+
case 1:
|
|
84
|
+
_a.sent();
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); });
|
|
89
|
+
it("should not render the announced div", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
setupHook();
|
|
92
|
+
expect(react_2.screen.queryByRole("status")).not.toBeInTheDocument();
|
|
93
|
+
return [2 /*return*/];
|
|
94
|
+
});
|
|
95
|
+
}); });
|
|
96
|
+
it("should only have 1 div to announce a message on a single instance of the hook", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
+
var liveAnnounce, firstMessage, secondMessage;
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
switch (_a.label) {
|
|
100
|
+
case 0:
|
|
101
|
+
liveAnnounce = setupHook().liveAnnounce;
|
|
102
|
+
firstMessage = "I am first";
|
|
103
|
+
secondMessage = "I am second";
|
|
104
|
+
react_2.act(function () { return liveAnnounce(firstMessage); });
|
|
105
|
+
return [4 /*yield*/, react_2.waitFor(function () {
|
|
106
|
+
expect(react_2.screen.queryAllByRole("status")).toHaveLength(1);
|
|
107
|
+
expect(react_2.screen.getByRole("status").textContent).toBe(firstMessage);
|
|
108
|
+
})];
|
|
109
|
+
case 1:
|
|
110
|
+
_a.sent();
|
|
111
|
+
react_2.act(function () { return liveAnnounce(secondMessage); });
|
|
112
|
+
return [4 /*yield*/, react_2.waitFor(function () {
|
|
113
|
+
expect(react_2.screen.queryAllByRole("status")).toHaveLength(1);
|
|
114
|
+
expect(react_2.screen.getByRole("status").textContent).toBe(secondMessage);
|
|
115
|
+
})];
|
|
116
|
+
case 2:
|
|
117
|
+
_a.sent();
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}); });
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/// <reference types="@emotion/core" />
|
|
3
|
-
/// <reference types="theme-ui" />
|
|
4
1
|
import calculateStrength from "zxcvbn";
|
|
5
2
|
export declare function usePasswordStrength(password: string, dictionary?: string[]): {
|
|
6
3
|
guesses: number;
|
|
7
4
|
score: calculateStrength.ZXCVBNScore;
|
|
8
5
|
warning: calculateStrength.ZXCVBNFeedbackWarning;
|
|
9
6
|
suggestions: string[];
|
|
10
|
-
timeToCrack:
|
|
7
|
+
timeToCrack: string | number;
|
|
11
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useResizeObserver";
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@jobber/formatters": "^0.2.0",
|
|
19
19
|
"@testing-library/react": "^10.2.1",
|
|
20
20
|
"@testing-library/react-hooks": "^7.0.0",
|
|
21
|
+
"@types/jest": "^26.0.23",
|
|
21
22
|
"@types/lodash": "4.14.136",
|
|
22
23
|
"@types/react": "16.14.2",
|
|
23
24
|
"@types/react-dom": "16.9.10",
|
|
@@ -39,5 +40,5 @@
|
|
|
39
40
|
"@apollo/client": "^3.3.16",
|
|
40
41
|
"react": "^16.8.6"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "ce09a40fb99f912afc3db58e6396c3ce8fbb31db"
|
|
43
44
|
}
|