@stellar-expert/ui-framework 1.9.3 → 1.9.5

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.
@@ -41,7 +41,7 @@ function decodeBase32(input) {
41
41
  /**
42
42
  * Draw Stellar address identicon on the given canvas
43
43
  * @param {String} address - StrKey-encoded account address
44
- * @param {Number} size? - Identicon size
44
+ * @param {Number} [size] - Identicon painting area size, in pixels (by default 448)
45
45
  * @return {String}
46
46
  */
47
47
  export function drawIdenticon(address, size = SIZE) {
@@ -49,9 +49,9 @@ function decodeSigner(signer) {
49
49
  /**
50
50
  * Account signer key description
51
51
  * @param {Signer} signer - StrKey-encoded Account/MuxedAccount/Sha256Hash/PreAuthTx/SignedPayload
52
- * @param {String} name? - Explicit account name that overrides the name from Directory; if false, friendly name is ignored
53
- * @param {String} className? - Optional CSS class attribute
54
- * @param {Boolean} showWeight? - Whether to display weight attribute
52
+ * @param {String} [name] - Explicit account name that overrides the name from Directory; if false, friendly name is ignored
53
+ * @param {String} [className] - Optional CSS class attribute
54
+ * @param {Boolean} [showWeight] - Whether to display weight attribute
55
55
  * @constructor
56
56
  */
57
57
  export const SignerKey = React.memo(function SignerKey({signer, name, className, showWeight = true}) {
package/asset/amount.js CHANGED
@@ -7,11 +7,11 @@ import {AssetLink} from './asset-link'
7
7
  * Formatted tokens amount
8
8
  * @param {String|Number} amount - Amount of tokens
9
9
  * @param {String|AssetDescriptor|Asset} asset - Asset name/descriptor
10
- * @param {String|Number|'auto'} decimals? - Formatted number decimals to show
11
- * @param {Boolean} adjust? - Denominate raw Int64 stroops to string format
12
- * @param {Boolean|'floor'} round? - Round or trim the number
13
- * @param {Boolean} issuer? - Whether to show asset issuer
14
- * @param {Boolean} icon? - Wheter to show asset icon
10
+ * @param {String|Number|'auto'} decimals - Number of decimals to show for a formatted numeric value
11
+ * @param {Boolean} [adjust] - Treat amount value as raw Int64 stroops amount
12
+ * @param {Boolean|'floor'} [round] - Round the amount
13
+ * @param {Boolean} [issuer] - Whether to show asset issuer
14
+ * @param {Boolean} [icon] - Whether to show asset icon
15
15
  * @constructor
16
16
  */
17
17
  export const Amount = React.memo(function Amount({amount, asset, decimals, adjust, round, issuer, icon}) {
@@ -1,4 +1,5 @@
1
1
  import React from 'react'
2
+ import cn from 'classnames'
2
3
  import {xdr, scValToBigInt} from '@stellar/stellar-base'
3
4
  import {xdrParserUtils} from '@stellar-expert/tx-meta-effects-parser'
4
5
  import {shortenString} from '@stellar-expert/formatter'
@@ -7,7 +8,7 @@ import './sc-val.scss'
7
8
 
8
9
  export const ScVal = React.memo(function ScVal({value, nested = false, indent = false}) {
9
10
  if (!nested)
10
- return <code className="sc-val"><ScVal value={value} indent={indent} nested/></code>
11
+ return <code className={cn('sc-val', {block: indent})}><ScVal value={value} indent={indent} nested/></code>
11
12
  if (!value)
12
13
  return 'void'
13
14
  if (typeof value === 'string') {
package/controls/tabs.js CHANGED
@@ -7,12 +7,12 @@ import './tabs.scss'
7
7
  /**
8
8
  * Tabs control
9
9
  * @param {TabDescriptor[]} tabs - Tabs list
10
- * @param {String} selectedTab? - Currently selected tab
11
- * @param {Function} onChange? - Handler for tabChanged event
12
- * @param {String} queryParam? - Associated query param name
13
- * @param {String} className? - Optional CSS class name
14
- * @param {Boolean} right? - Inline tabs to the right within the header
15
- * @param {*} children? - Additional content to render in the tabs header
10
+ * @param {String} [selectedTab] - Currently selected tab
11
+ * @param {Function} [onChange] - Handler for tabChanged event
12
+ * @param {String} [queryParam] - Associated query param name (control will auto-update query string)
13
+ * @param {String} [className] - Optional CSS class name
14
+ * @param {Boolean} [right] - Position tabs to the right within the header
15
+ * @param {*} [children] - Additional content to render in the tabs header
16
16
  * @constructor
17
17
  */
18
18
  export function Tabs({tabs, selectedTab, queryParam, className, onChange, right, children}) {
@@ -88,7 +88,7 @@ export function Tabs({tabs, selectedTab, queryParam, className, onChange, right,
88
88
  /**
89
89
  * @typedef {{}} TabDescriptor
90
90
  * @property {String} name - Unique table name
91
- * @property {String} title? - Optional display name (if differs from tab name)
92
- * @property {Function} render? - Render callback
93
- * @property {Boolean} isDefault? - Whether this tab should be displayed by default
91
+ * @property {String} [title] - Display name (if differs from tab name)
92
+ * @property {Function} [render] - Render callback
93
+ * @property {Boolean} [isDefault] - Whether this tab should be displayed by default
94
94
  */
@@ -207,8 +207,8 @@ export const Tooltip = React.memo(function Tooltip({trigger, desiredPlace = 'top
207
207
  */
208
208
  /**
209
209
  * @typedef {Object} PositionOffset
210
- * @property {Number} top? - Top offset
211
- * @property {Number} bottom? - Bottom offset
212
- * @property {Number} left? - Left offset
213
- * @property {Number} right? - Right offset
210
+ * @property {Number} [top] - Top offset
211
+ * @property {Number} [bottom] - Bottom offset
212
+ * @property {Number} [left] - Left offset
213
+ * @property {Number} [right] - Right offset
214
214
  */
package/index.js CHANGED
@@ -44,6 +44,7 @@ export * from './interaction/autofocus'
44
44
  export * from './interaction/block-select'
45
45
  export * from './interaction/copy-to-clipboard'
46
46
  export * from './interaction/spoiler'
47
+ export * from './interaction/accordion'
47
48
  export * from './interaction/theme-selector'
48
49
  export * from './interaction/inline-progress'
49
50
  export * from './interaction/responsive'
@@ -0,0 +1,29 @@
1
+ import React, {useCallback, useEffect, useState} from 'react'
2
+ import cn from 'classnames'
3
+ import './accordion.scss'
4
+
5
+ /**
6
+ * @param {{title, content}[]} options
7
+ */
8
+ export function Accordion({options}) {
9
+ const [selectedOption, setSelectedOption] = useState()
10
+ useEffect(() => {
11
+ setSelectedOption(options[0].title)
12
+ }, [options])
13
+ const changeSelected = useCallback(e => {
14
+ const {title} = e.currentTarget.dataset
15
+ setSelectedOption(title)
16
+ }, [options])
17
+ return <div className="accordion">
18
+ {options.map(({title, content}) => <div key={title} className={cn('option', {open: selectedOption === title})}>
19
+ <div className="accordion-header" data-title={title} onClick={changeSelected}>
20
+ {title}
21
+ </div>
22
+ <div className="accordion-collapse">
23
+ <div className="accordion-body">
24
+ {content}
25
+ </div>
26
+ </div>
27
+ </div>)}
28
+ </div>
29
+ }
@@ -0,0 +1,32 @@
1
+ .accordion {
2
+ .accordion-header {
3
+ position: relative;
4
+ cursor: pointer;
5
+ user-select: none;
6
+
7
+ &:before {
8
+ content: '+';
9
+ position: absolute;
10
+ top: 50%;
11
+ transform: translateY(-50%);
12
+ left: -20px;
13
+ }
14
+ }
15
+
16
+ .accordion-collapse {
17
+ height: 0;
18
+ overflow-y: hidden;
19
+ }
20
+
21
+ .option {
22
+ &.open {
23
+ .accordion-header:before {
24
+ content: '-';
25
+ }
26
+
27
+ .accordion-collapse {
28
+ height: auto;
29
+ }
30
+ }
31
+ }
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/ui-framework",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "description": "StellarExpert shared UI components library",
5
5
  "main": "index.js",
6
6
  "module": "./index.js",