playbook_ui 11.13.0 → 11.15.0.pre.alpha.table1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +39 -0
  3. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.tsx +3 -2
  4. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -0
  5. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +4 -0
  6. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height.jsx +2 -2
  7. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.html.erb +13 -1
  8. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.jsx +32 -8
  9. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_scrollable.md +5 -2
  10. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.jsx +2 -2
  11. data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +3 -0
  12. data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +56 -97
  13. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb +145 -1
  14. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.jsx +127 -3
  15. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.md +11 -2
  16. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.html.erb +136 -0
  17. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.jsx +90 -8
  18. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.md +5 -0
  19. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.html.erb +51 -0
  20. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.jsx +39 -0
  21. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.html.erb +0 -2
  22. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.jsx +6 -20
  23. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.html.erb +2 -2
  24. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.jsx +1 -1
  25. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.html.erb +318 -5
  26. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx +134 -48
  27. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.md +11 -5
  28. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.html.erb +123 -0
  29. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.jsx +96 -20
  30. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.md +6 -2
  31. data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +4 -0
  32. data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
  33. data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
  34. data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +5 -9
  35. data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +0 -47
  36. data/app/pb_kits/playbook/pb_table/styles/_all.scss +0 -1
  37. data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +4 -0
  38. data/app/pb_kits/playbook/pb_table/styles/_hover.scss +28 -25
  39. data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +4 -0
  40. data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +4 -0
  41. data/app/pb_kits/playbook/pb_table/styles/_single-line.scss +0 -1
  42. data/app/pb_kits/playbook/pb_table/styles/_table-card.scss +0 -27
  43. data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +4 -0
  44. data/lib/playbook/version.rb +2 -2
  45. metadata +9 -9
  46. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.md +0 -1
  47. data/app/pb_kits/playbook/pb_passphrase/passwordStrength.js +0 -55
  48. data/app/pb_kits/playbook/pb_passphrase/useHaveIBeenPwned.js +0 -52
  49. data/app/pb_kits/playbook/pb_passphrase/useZxcvbn.js +0 -58
  50. data/app/pb_kits/playbook/pb_table/styles/_as-cards.scss +0 -49
@@ -1,55 +0,0 @@
1
- import zxcvbn from 'zxcvbn'
2
-
3
- export const zxcvbnPasswordScore = (options) => {
4
- const {
5
- calculate = zxcvbn,
6
- averageThreshold = 2,
7
- strongThreshold = 3,
8
- minLength = 12,
9
- } = options
10
-
11
- return {
12
- minLength,
13
- averageThreshold,
14
- strongThreshold,
15
- test: function (password = '', common = false) {
16
- const feedbackValues = (str) => {
17
- let percent, variant, text
18
-
19
- if (password.length <= 0) {
20
- percent = '0'
21
- variant = 'negative'
22
- text = '\u00A0' //nbsp to keep form from jumping when typing beings
23
- } else if (common) {
24
- percent = '25'
25
- variant = 'negative'
26
- text = 'This passphrase is too common'
27
- } else if (password.length < this.minLength || str < this.averageThreshold) {
28
- percent = '25'
29
- variant = 'negative'
30
- text = 'Too weak'
31
- } else if (str < this.strongThreshold){
32
- percent = '50'
33
- variant = 'warning'
34
- text = 'Almost there, keep going!'
35
- } else if (str >= this.strongThreshold) {
36
- percent = '100'
37
- variant = 'positive'
38
- text = 'Success! Strong passphrase'
39
- }
40
- return { percent, variant, text }
41
- }
42
-
43
- const result = calculate(password)
44
-
45
- return (
46
- {
47
- suggestions: result.feedback.suggestions,
48
- warning: result.feedback.warning,
49
- strength: result.score,
50
- ...feedbackValues(result.score),
51
- }
52
- )
53
- },
54
- }
55
- }
@@ -1,52 +0,0 @@
1
-
2
- import { useEffect, useState } from 'react'
3
-
4
- const checkHaveIBeenPwned = async function (passphrase) {
5
- const buffer = new TextEncoder('utf-8').encode(passphrase)
6
- const digest = await crypto.subtle.digest('SHA-1', buffer)
7
- const hashArray = Array.from(new Uint8Array(digest))
8
- const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('')
9
-
10
- const firstFive = hashHex.slice(0, 5)
11
- const endOfHash = hashHex.slice(5)
12
-
13
- const resp = await fetch(`https://api.pwnedpasswords.com/range/${firstFive}`)
14
- const text = await resp.text()
15
-
16
- const match = text.split('\n').some((line) => {
17
- //Each line is <sha-1-hash-suffix>:<count of incidents>
18
- return line.split(':')[0] === endOfHash.toUpperCase()
19
- })
20
- return match
21
- }
22
-
23
- /**
24
- * If the input hasn't changed in <delay> ms,
25
- * hit the haveibeenpwned api and check if the given passphrase is compromised
26
- */
27
- export default function useHaveIBeenPwned(passphrase, minLength, delay = 400) {
28
- const [isPwned, setIsPwned] = useState(false)
29
-
30
- useEffect(
31
- () => {
32
- // only check the API for passphrases above the minimum size
33
- if (passphrase.length < minLength) {
34
- setIsPwned(false)
35
- return
36
- }
37
-
38
- const handler = setTimeout(() => {
39
- checkHaveIBeenPwned(passphrase)
40
- .then((pwned) => setIsPwned(pwned))
41
- .catch(() => setIsPwned(false))
42
- }, delay)
43
-
44
- return () => {
45
- clearTimeout(handler)
46
- }
47
- },
48
- [passphrase, minLength, delay]
49
- )
50
-
51
- return isPwned
52
- }
@@ -1,58 +0,0 @@
1
- import { useEffect, useMemo, useState } from 'react'
2
- import zxcvbn from 'zxcvbn'
3
-
4
- export default function useZxcvbn(options) {
5
- const { passphrase = '', common, isPwned, confirmation, averageThreshold, minLength, strongThreshold } = options
6
- const calculator = useMemo(
7
- () => confirmation ? () => ({ score: 0 }) : zxcvbn,
8
- [confirmation]
9
- )
10
-
11
- const [percent, setPercent] = useState('0')
12
- const [variant, setVariant] = useState('negative')
13
- const [text, setText] = useState('\u00A0') //nbsp to keep height constant
14
- const [result, setResult] = useState({})
15
-
16
- useEffect(() => {
17
- if (confirmation) return
18
- const newResult = calculator(passphrase)
19
- setResult(newResult)
20
- const str = newResult.score
21
-
22
- const noPassphrase = passphrase.length <= 0
23
- const commonPassphrase = common || isPwned
24
- const weakPassphrase = passphrase.length < minLength || str < averageThreshold
25
- const averagePassphrase = str < strongThreshold
26
- const strongPassphrase = str >= strongThreshold
27
-
28
- if (noPassphrase) {
29
- setPercent('0')
30
- setVariant('negative')
31
- setText('\u00A0') //nbsp to keep height constant
32
- } else if (commonPassphrase) {
33
- setPercent('25')
34
- setVariant('negative')
35
- setText('This passphrase is too common')
36
- } else if (weakPassphrase) {
37
- setPercent('25')
38
- setVariant('negative')
39
- setText('Too weak')
40
- } else if (averagePassphrase){
41
- setPercent('50')
42
- setVariant('warning')
43
- setText('Almost there, keep going!')
44
- } else if (strongPassphrase) {
45
- setPercent('100')
46
- setVariant('positive')
47
- setText('Success! Strong passphrase')
48
- }
49
- }, [passphrase, common, isPwned, averageThreshold, minLength, strongThreshold]
50
- )
51
-
52
- return {
53
- strength: common || isPwned ? 0 : result.score,
54
- percent,
55
- variant,
56
- text,
57
- }
58
- }
@@ -1,49 +0,0 @@
1
- [class^=pb_table] {
2
- &.table-sm,
3
- &.table-md,
4
- &.table-lg {
5
- &.as-cards {
6
- thead {
7
- tr {
8
- display: flex;
9
- width: 100%;
10
-
11
- th {
12
- flex-grow: 1;
13
- }
14
- }
15
- }
16
- tbody {
17
- tr {
18
- display: flex;
19
- align-items: stretch;
20
- flex-direction: row;
21
- justify-content: flex-start;
22
- width: 100%;
23
- margin: $space-xs 0;
24
-
25
- td {
26
- background: $white;
27
- flex-grow: 1;
28
- border-width: 1px 0;
29
-
30
- &:first-child {
31
- border-left-width: 1px;
32
- border-radius: 4px 0 0 4px;
33
- }
34
- &:last-child {
35
- border-right-width: 1px;
36
- border-radius: 0 4px 4px 0;
37
- }
38
- }
39
-
40
- &:last-child {
41
- td {
42
- border-top-width: 1px !important;
43
- }
44
- }
45
- }
46
- }
47
- }
48
- }
49
- }