@kitsuyui/react-binary 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  This is a React component representing a binary value.
6
6
 
7
+ ## Design role
8
+
9
+ This package provides binary/text visualization primitives.
10
+ `Bits` is the structural primitive, and `SimpleBitString` / `DetailedBitString` are concrete visualizations built on top of it.
11
+
7
12
  ## Demo
8
13
 
9
14
  Storybook: https://react-playground.docs.kitsuyui.com/storybook/
@@ -28,6 +33,19 @@ yarn add @kitsuyui/react-binary
28
33
  pnpm add @kitsuyui/react-binary
29
34
  ```
30
35
 
36
+ ## Usage
37
+
38
+ ```tsx
39
+ import {
40
+ Bits,
41
+ DetailedBitString,
42
+ SimpleBitString,
43
+ type BitsProps,
44
+ type DetailedBitStringProps,
45
+ type SimpleBitStringProps,
46
+ } from '@kitsuyui/react-binary'
47
+ ```
48
+
31
49
  ## License
32
50
 
33
51
  MIT
@@ -1 +1 @@
1
- {"version":3,"file":"Binary.cjs","names":["React"],"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n"],"mappings":"8KA6BA,MAAa,EAAQ,GAII,CACvB,GAAM,CAAE,QAAO,cAAe,EACxB,GAAQ,EAAQ,GAAG,SAAS,EAAE,CAAC,MAAM,GAAG,CACxC,EAAY,EAAK,OACjB,EAAS,EAAM,QAAU,EACzB,EAAiB,KAAK,IAAI,EAAG,EAAY,EAAO,CAChD,EAAoB,KAAK,IAAI,EAAG,EAAS,EAAU,CACnD,EAAkB,KAAK,IAAI,EAAQ,EAAU,CAenD,OAAO,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAdU,MAAM,KAAK,MAAM,EAAgB,CAAC,CAAC,KAAK,EAAG,IAAU,CACpE,IAAM,EAAQ,EAAK,EAAY,EAAkB,KAAW,IACtD,EAAoB,EACpB,EAAW,EAAoB,EAC/B,EAAc,EAAoB,EACxC,OAAOA,EAAAA,QAAM,cAAc,EAAY,CACrC,IAAK,EACL,QACA,WACA,cACA,qBAAsB,EAAkB,EAAQ,EAChD,oBACD,CAAC,EACF,CAAA,CACoB"}
1
+ {"version":3,"file":"Binary.cjs","names":["React"],"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\nexport type BitsProps = {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: BitsProps): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n"],"mappings":"8KAmCA,MAAa,EAAQ,GAAwC,CAC3D,GAAM,CAAE,QAAO,cAAe,EACxB,GAAQ,EAAQ,GAAG,SAAS,EAAE,CAAC,MAAM,GAAG,CACxC,EAAY,EAAK,OACjB,EAAS,EAAM,QAAU,EACzB,EAAiB,KAAK,IAAI,EAAG,EAAY,EAAO,CAChD,EAAoB,KAAK,IAAI,EAAG,EAAS,EAAU,CACnD,EAAkB,KAAK,IAAI,EAAQ,EAAU,CAenD,OAAO,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAdU,MAAM,KAAK,MAAM,EAAgB,CAAC,CAAC,KAAK,EAAG,IAAU,CACpE,IAAM,EAAQ,EAAK,EAAY,EAAkB,KAAW,IACtD,EAAoB,EACpB,EAAW,EAAoB,EAC/B,EAAc,EAAoB,EACxC,OAAOA,EAAAA,QAAM,cAAc,EAAY,CACrC,IAAK,EACL,QACA,WACA,cACA,qBAAsB,EAAkB,EAAQ,EAChD,oBACD,CAAC,EACF,CAAA,CACoB"}
package/dist/Binary.d.cts CHANGED
@@ -19,17 +19,18 @@ type EnhancedBitProps = BitProps & {
19
19
  bigEndianBitOrder: number;
20
20
  };
21
21
  type BitElement = React.FC<EnhancedBitProps>;
22
+ type BitsProps = {
23
+ value: number;
24
+ bitElement: BitElement;
25
+ length?: number | undefined;
26
+ };
22
27
  /**
23
28
  * Bit is a component that displays a bit.
24
29
  * This component supports the behavior of zero padding and overflow.
25
30
  * @param props
26
31
  * @returns A component that displays a bit.
27
32
  */
28
- declare const Bits: (props: {
29
- value: number;
30
- bitElement: BitElement;
31
- length?: number | undefined;
32
- }) => React.JSX.Element;
33
+ declare const Bits: (props: BitsProps) => React.JSX.Element;
33
34
  //#endregion
34
- export { BitElement, BitProps, Bits, EnhancedBitProps };
35
+ export { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps };
35
36
  //# sourceMappingURL=Binary.d.cts.map
package/dist/Binary.d.ts CHANGED
@@ -19,17 +19,18 @@ type EnhancedBitProps = BitProps & {
19
19
  bigEndianBitOrder: number;
20
20
  };
21
21
  type BitElement = React.FC<EnhancedBitProps>;
22
+ type BitsProps = {
23
+ value: number;
24
+ bitElement: BitElement;
25
+ length?: number | undefined;
26
+ };
22
27
  /**
23
28
  * Bit is a component that displays a bit.
24
29
  * This component supports the behavior of zero padding and overflow.
25
30
  * @param props
26
31
  * @returns A component that displays a bit.
27
32
  */
28
- declare const Bits: (props: {
29
- value: number;
30
- bitElement: BitElement;
31
- length?: number | undefined;
32
- }) => React.JSX.Element;
33
+ declare const Bits: (props: BitsProps) => React.JSX.Element;
33
34
  //#endregion
34
- export { BitElement, BitProps, Bits, EnhancedBitProps };
35
+ export { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps };
35
36
  //# sourceMappingURL=Binary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Binary.js","names":[],"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n"],"mappings":"2EA6BA,MAAa,EAAQ,GAII,CACvB,GAAM,CAAE,QAAO,cAAe,EACxB,GAAQ,EAAQ,GAAG,SAAS,EAAE,CAAC,MAAM,GAAG,CACxC,EAAY,EAAK,OACjB,EAAS,EAAM,QAAU,EACzB,EAAiB,KAAK,IAAI,EAAG,EAAY,EAAO,CAChD,EAAoB,KAAK,IAAI,EAAG,EAAS,EAAU,CACnD,EAAkB,KAAK,IAAI,EAAQ,EAAU,CAenD,OAAO,EAAA,EAAA,CAAA,SAdU,MAAM,KAAK,MAAM,EAAgB,CAAC,CAAC,KAAK,EAAG,IAAU,CACpE,IAAM,EAAQ,EAAK,EAAY,EAAkB,KAAW,IACtD,EAAoB,EACpB,EAAW,EAAoB,EAC/B,EAAc,EAAoB,EACxC,OAAO,EAAM,cAAc,EAAY,CACrC,IAAK,EACL,QACA,WACA,cACA,qBAAsB,EAAkB,EAAQ,EAChD,oBACD,CAAC,EACF,CAAA,CACoB"}
1
+ {"version":3,"file":"Binary.js","names":[],"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\nexport type BitsProps = {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: BitsProps): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n"],"mappings":"2EAmCA,MAAa,EAAQ,GAAwC,CAC3D,GAAM,CAAE,QAAO,cAAe,EACxB,GAAQ,EAAQ,GAAG,SAAS,EAAE,CAAC,MAAM,GAAG,CACxC,EAAY,EAAK,OACjB,EAAS,EAAM,QAAU,EACzB,EAAiB,KAAK,IAAI,EAAG,EAAY,EAAO,CAChD,EAAoB,KAAK,IAAI,EAAG,EAAS,EAAU,CACnD,EAAkB,KAAK,IAAI,EAAQ,EAAU,CAenD,OAAO,EAAA,EAAA,CAAA,SAdU,MAAM,KAAK,MAAM,EAAgB,CAAC,CAAC,KAAK,EAAG,IAAU,CACpE,IAAM,EAAQ,EAAK,EAAY,EAAkB,KAAW,IACtD,EAAoB,EACpB,EAAW,EAAoB,EAC/B,EAAc,EAAoB,EACxC,OAAO,EAAM,cAAc,EAAY,CACrC,IAAK,EACL,QACA,WACA,cACA,qBAAsB,EAAkB,EAAQ,EAChD,oBACD,CAAC,EACF,CAAA,CACoB"}
package/dist/Detailed.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./Binary.cjs`);let t=require(`react/jsx-runtime`);const n=e=>{let{stand:n,overflow:i,zeroPadding:a}=e,o=e.displayLittleEndianBitOrder??!1,s=e.displayBigEndianBitOrder??!1;return(0,t.jsxs)(`div`,{style:{display:`inline-block`,fontFamily:`monospace`,margin:`0.5px`},children:[(0,t.jsx)(`div`,{style:{color:n?`#999999`:`#cccccc`,backgroundColor:n?`#000000`:`#ffffff`,border:i?`1px dotted red`:a?`1px dotted gray`:`1px solid #cccccc`},children:n?`1`:`0`}),o&&(0,t.jsx)(r,{index:e.littleEndianBitOrder}),s&&(0,t.jsx)(r,{index:e.bigEndianBitOrder})]})},r=e=>(0,t.jsx)(`div`,{style:{userSelect:`none`,fontSize:`0.5em`,textAlign:`center`,lineHeight:`1em`},children:e.index}),i=r=>{let i=r.showLittleEndianBitOrder??!1,a=r.showBigEndianBitOrder??!1;return(0,t.jsx)(e.Bits,{value:r.value,length:r.length,bitElement:e=>(0,t.jsx)(n,{...e,displayLittleEndianBitOrder:i,displayBigEndianBitOrder:a})})};exports.DetailedBit=n,exports.DetailedBitString=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./Binary.cjs`);let t=require(`react/jsx-runtime`);const n=e=>{let{border:n,color:a,backgroundColor:s,text:c}=r(e.stand,e.overflow,e.zeroPadding),{displayLittleEndianBitOrder:l,displayBigEndianBitOrder:u}=i(e);return(0,t.jsxs)(`div`,{style:{display:`inline-block`,fontFamily:`monospace`,margin:`0.5px`},children:[(0,t.jsx)(`div`,{style:{color:a,backgroundColor:s,border:n},children:c}),(0,t.jsx)(o,{displayLittleEndianBitOrder:l,displayBigEndianBitOrder:u,littleEndianBitOrder:e.littleEndianBitOrder,bigEndianBitOrder:e.bigEndianBitOrder})]})},r=(e,t,n)=>({text:e?`1`:`0`,border:a(t,n),color:e?`#999999`:`#cccccc`,backgroundColor:e?`#000000`:`#ffffff`}),i=e=>({displayLittleEndianBitOrder:e.showLittleEndianBitOrder??e.displayLittleEndianBitOrder??!1,displayBigEndianBitOrder:e.showBigEndianBitOrder??e.displayBigEndianBitOrder??!1}),a=(e,t)=>e?`1px dotted red`:t?`1px dotted gray`:`1px solid #cccccc`,o=e=>{let{displayLittleEndianBitOrder:n,displayBigEndianBitOrder:r,littleEndianBitOrder:i,bigEndianBitOrder:a}=e;return(0,t.jsxs)(t.Fragment,{children:[n?(0,t.jsx)(s,{index:i}):null,r?(0,t.jsx)(s,{index:a}):null]})},s=e=>(0,t.jsx)(`div`,{style:{userSelect:`none`,fontSize:`0.5em`,textAlign:`center`,lineHeight:`1em`},children:e.index}),c=r=>{let i=r.showLittleEndianBitOrder??!1,a=r.showBigEndianBitOrder??!1;return(0,t.jsx)(e.Bits,{value:r.value,length:r.length,bitElement:e=>(0,t.jsx)(n,{...e,showLittleEndianBitOrder:i,showBigEndianBitOrder:a})})};exports.DetailedBit=n,exports.DetailedBitString=c;
2
2
  //# sourceMappingURL=Detailed.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Detailed.cjs","names":["Bits"],"sources":["../src/Detailed.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { stand, overflow, zeroPadding } = props\n const displayLittleEndianBitOrder = props.displayLittleEndianBitOrder ?? false\n const displayBigEndianBitOrder = props.displayBigEndianBitOrder ?? false\n const text = stand ? '1' : '0'\n const border = overflow\n ? '1px dotted red'\n : zeroPadding\n ? '1px dotted gray'\n : '1px solid #cccccc'\n const margin = '0.5px'\n const color = stand ? '#999999' : '#cccccc'\n const backgroundColor = stand ? '#000000' : '#ffffff'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n {displayLittleEndianBitOrder && (\n <IndexLabel index={props.littleEndianBitOrder} />\n )}\n {displayBigEndianBitOrder && (\n <IndexLabel index={props.bigEndianBitOrder} />\n )}\n </div>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport const DetailedBitString = (props: {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n displayLittleEndianBitOrder={showLittleEndianBitOrder}\n displayBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":"sKAQA,MAAa,EAAe,GAA+C,CACzE,GAAM,CAAE,QAAO,WAAU,eAAgB,EACnC,EAA8B,EAAM,6BAA+B,GACnE,EAA2B,EAAM,0BAA4B,GAWnE,OACE,EAAA,EAAA,MAAC,MAAA,CAAI,MAAO,CAAE,QAAS,eAAgB,WAFtB,YAEkC,OALtC,QAK8C,YACzD,EAAA,EAAA,KAAC,MAAA,CACC,MAAO,CACL,MAPM,EAAQ,UAAY,UAQ1B,gBAPgB,EAAQ,UAAY,UAQpC,OAfO,EACX,iBACA,EACE,kBACA,oBAYC,UAjBM,EAAQ,IAAM,KAoBjB,CACL,IACC,EAAA,EAAA,KAAC,EAAA,CAAW,MAAO,EAAM,qBAAA,CAAwB,CAElD,IACC,EAAA,EAAA,KAAC,EAAA,CAAW,MAAO,EAAM,kBAAA,CAAqB,GAE5C,EAIJ,EAAc,IAEhB,EAAA,EAAA,KAAC,MAAA,CACC,MAAO,CACL,WAAY,OACZ,SAAU,QACV,UAAW,SACX,WAAY,MACb,UAEA,EAAM,OACH,CAIG,EAAqB,GAKT,CACvB,IAAM,EAA2B,EAAM,0BAA4B,GAC7D,EAAwB,EAAM,uBAAyB,GAC7D,OACE,EAAA,EAAA,KAACA,EAAAA,KAAAA,CACC,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAa,IACX,EAAA,EAAA,KAAC,EAAA,CACC,GAAI,EACJ,4BAA6B,EAC7B,yBAA0B,GAC1B,EAEJ"}
1
+ {"version":3,"file":"Detailed.cjs","names":["Bits"],"sources":["../src/Detailed.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { border, color, backgroundColor, text } = getDetailedBitPalette(\n props.stand,\n props.overflow,\n props.zeroPadding\n )\n const { displayLittleEndianBitOrder, displayBigEndianBitOrder } =\n getDetailedBitDisplayOptions(props)\n const margin = '0.5px'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n <DetailedBitLabels\n displayLittleEndianBitOrder={displayLittleEndianBitOrder}\n displayBigEndianBitOrder={displayBigEndianBitOrder}\n littleEndianBitOrder={props.littleEndianBitOrder}\n bigEndianBitOrder={props.bigEndianBitOrder}\n />\n </div>\n )\n}\n\nconst getDetailedBitPalette = (\n stand: boolean,\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n return {\n text: stand ? '1' : '0',\n border: getDetailedBitBorder(overflow, zeroPadding),\n color: stand ? '#999999' : '#cccccc',\n backgroundColor: stand ? '#000000' : '#ffffff',\n }\n}\n\nconst getDetailedBitDisplayOptions = (props: DetailedBitProps) => {\n return {\n displayLittleEndianBitOrder:\n props.showLittleEndianBitOrder ?? props.displayLittleEndianBitOrder ?? false,\n displayBigEndianBitOrder:\n props.showBigEndianBitOrder ?? props.displayBigEndianBitOrder ?? false,\n }\n}\n\nconst getDetailedBitBorder = (\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n if (overflow) return '1px dotted red'\n if (zeroPadding) return '1px dotted gray'\n return '1px solid #cccccc'\n}\n\nconst DetailedBitLabels = (props: {\n displayLittleEndianBitOrder: boolean\n displayBigEndianBitOrder: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}) => {\n const {\n displayLittleEndianBitOrder,\n displayBigEndianBitOrder,\n littleEndianBitOrder,\n bigEndianBitOrder,\n } = props\n\n return (\n <>\n {displayLittleEndianBitOrder ? (\n <IndexLabel index={littleEndianBitOrder} />\n ) : null}\n {displayBigEndianBitOrder ? (\n <IndexLabel index={bigEndianBitOrder} />\n ) : null}\n </>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport type DetailedBitStringProps = {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBitString = (props: DetailedBitStringProps): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n showLittleEndianBitOrder={showLittleEndianBitOrder}\n showBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":"sKAUA,MAAa,EAAe,GAA+C,CACzE,GAAM,CAAE,SAAQ,QAAO,kBAAiB,QAAS,EAC/C,EAAM,MACN,EAAM,SACN,EAAM,YACP,CACK,CAAE,8BAA6B,4BACnC,EAA6B,EAAM,CAGrC,OACE,EAAA,EAAA,MAAC,MAAA,CAAI,MAAO,CAAE,QAAS,eAAgB,WAFtB,YAEkC,OAHtC,QAG8C,YACzD,EAAA,EAAA,KAAC,MAAA,CACC,MAAO,CACL,QACA,kBACA,SACD,UAEA,GACG,EACN,EAAA,EAAA,KAAC,EAAA,CAC8B,8BACH,2BAC1B,qBAAsB,EAAM,qBAC5B,kBAAmB,EAAM,mBACzB,CAAA,EACE,EAIJ,GACJ,EACA,EACA,KAEO,CACL,KAAM,EAAQ,IAAM,IACpB,OAAQ,EAAqB,EAAU,EAAY,CACnD,MAAO,EAAQ,UAAY,UAC3B,gBAAiB,EAAQ,UAAY,UACtC,EAGG,EAAgC,IAC7B,CACL,4BACE,EAAM,0BAA4B,EAAM,6BAA+B,GACzE,yBACE,EAAM,uBAAyB,EAAM,0BAA4B,GACpE,EAGG,GACJ,EACA,IAEI,EAAiB,iBACjB,EAAoB,kBACjB,oBAGH,EAAqB,GAKrB,CACJ,GAAM,CACJ,8BACA,2BACA,uBACA,qBACE,EAEJ,OACE,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,CACG,GACC,EAAA,EAAA,KAAC,EAAA,CAAW,MAAO,EAAA,CAAwB,CACzC,KACH,GACC,EAAA,EAAA,KAAC,EAAA,CAAW,MAAO,EAAA,CAAqB,CACtC,KAAA,CAAA,CACH,EAID,EAAc,IAEhB,EAAA,EAAA,KAAC,MAAA,CACC,MAAO,CACL,WAAY,OACZ,SAAU,QACV,UAAW,SACX,WAAY,MACb,UAEA,EAAM,OACH,CAWG,EAAqB,GAAqD,CACrF,IAAM,EAA2B,EAAM,0BAA4B,GAC7D,EAAwB,EAAM,uBAAyB,GAC7D,OACE,EAAA,EAAA,KAACA,EAAAA,KAAAA,CACC,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAa,IACX,EAAA,EAAA,KAAC,EAAA,CACC,GAAI,EACsB,2BACH,yBACvB,EAEJ"}
@@ -3,16 +3,19 @@ import React from "react";
3
3
 
4
4
  //#region src/Detailed.d.ts
5
5
  type DetailedBitProps = EnhancedBitProps & {
6
+ showLittleEndianBitOrder?: boolean | undefined;
7
+ showBigEndianBitOrder?: boolean | undefined;
6
8
  displayLittleEndianBitOrder?: boolean | undefined;
7
9
  displayBigEndianBitOrder?: boolean | undefined;
8
10
  };
9
11
  declare const DetailedBit: (props: DetailedBitProps) => React.JSX.Element;
10
- declare const DetailedBitString: (props: {
12
+ type DetailedBitStringProps = {
11
13
  value: number;
12
14
  length?: number;
13
15
  showLittleEndianBitOrder?: boolean | undefined;
14
16
  showBigEndianBitOrder?: boolean | undefined;
15
- }) => React.JSX.Element;
17
+ };
18
+ declare const DetailedBitString: (props: DetailedBitStringProps) => React.JSX.Element;
16
19
  //#endregion
17
- export { DetailedBit, DetailedBitProps, DetailedBitString };
20
+ export { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps };
18
21
  //# sourceMappingURL=Detailed.d.cts.map
@@ -3,16 +3,19 @@ import React from "react";
3
3
 
4
4
  //#region src/Detailed.d.ts
5
5
  type DetailedBitProps = EnhancedBitProps & {
6
+ showLittleEndianBitOrder?: boolean | undefined;
7
+ showBigEndianBitOrder?: boolean | undefined;
6
8
  displayLittleEndianBitOrder?: boolean | undefined;
7
9
  displayBigEndianBitOrder?: boolean | undefined;
8
10
  };
9
11
  declare const DetailedBit: (props: DetailedBitProps) => React.JSX.Element;
10
- declare const DetailedBitString: (props: {
12
+ type DetailedBitStringProps = {
11
13
  value: number;
12
14
  length?: number;
13
15
  showLittleEndianBitOrder?: boolean | undefined;
14
16
  showBigEndianBitOrder?: boolean | undefined;
15
- }) => React.JSX.Element;
17
+ };
18
+ declare const DetailedBitString: (props: DetailedBitStringProps) => React.JSX.Element;
16
19
  //#endregion
17
- export { DetailedBit, DetailedBitProps, DetailedBitString };
20
+ export { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps };
18
21
  //# sourceMappingURL=Detailed.d.ts.map
package/dist/Detailed.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Bits as e}from"./Binary.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";const r=e=>{let{stand:r,overflow:a,zeroPadding:o}=e,s=e.displayLittleEndianBitOrder??!1,c=e.displayBigEndianBitOrder??!1;return n(`div`,{style:{display:`inline-block`,fontFamily:`monospace`,margin:`0.5px`},children:[t(`div`,{style:{color:r?`#999999`:`#cccccc`,backgroundColor:r?`#000000`:`#ffffff`,border:a?`1px dotted red`:o?`1px dotted gray`:`1px solid #cccccc`},children:r?`1`:`0`}),s&&t(i,{index:e.littleEndianBitOrder}),c&&t(i,{index:e.bigEndianBitOrder})]})},i=e=>t(`div`,{style:{userSelect:`none`,fontSize:`0.5em`,textAlign:`center`,lineHeight:`1em`},children:e.index}),a=n=>{let i=n.showLittleEndianBitOrder??!1,a=n.showBigEndianBitOrder??!1;return t(e,{value:n.value,length:n.length,bitElement:e=>t(r,{...e,displayLittleEndianBitOrder:i,displayBigEndianBitOrder:a})})};export{r as DetailedBit,a as DetailedBitString};
1
+ import{Bits as e}from"./Binary.js";import{Fragment as t,jsx as n,jsxs as r}from"react/jsx-runtime";const i=e=>{let{border:t,color:i,backgroundColor:s,text:l}=a(e.stand,e.overflow,e.zeroPadding),{displayLittleEndianBitOrder:u,displayBigEndianBitOrder:d}=o(e);return r(`div`,{style:{display:`inline-block`,fontFamily:`monospace`,margin:`0.5px`},children:[n(`div`,{style:{color:i,backgroundColor:s,border:t},children:l}),n(c,{displayLittleEndianBitOrder:u,displayBigEndianBitOrder:d,littleEndianBitOrder:e.littleEndianBitOrder,bigEndianBitOrder:e.bigEndianBitOrder})]})},a=(e,t,n)=>({text:e?`1`:`0`,border:s(t,n),color:e?`#999999`:`#cccccc`,backgroundColor:e?`#000000`:`#ffffff`}),o=e=>({displayLittleEndianBitOrder:e.showLittleEndianBitOrder??e.displayLittleEndianBitOrder??!1,displayBigEndianBitOrder:e.showBigEndianBitOrder??e.displayBigEndianBitOrder??!1}),s=(e,t)=>e?`1px dotted red`:t?`1px dotted gray`:`1px solid #cccccc`,c=e=>{let{displayLittleEndianBitOrder:i,displayBigEndianBitOrder:a,littleEndianBitOrder:o,bigEndianBitOrder:s}=e;return r(t,{children:[i?n(l,{index:o}):null,a?n(l,{index:s}):null]})},l=e=>n(`div`,{style:{userSelect:`none`,fontSize:`0.5em`,textAlign:`center`,lineHeight:`1em`},children:e.index}),u=t=>{let r=t.showLittleEndianBitOrder??!1,a=t.showBigEndianBitOrder??!1;return n(e,{value:t.value,length:t.length,bitElement:e=>n(i,{...e,showLittleEndianBitOrder:r,showBigEndianBitOrder:a})})};export{i as DetailedBit,u as DetailedBitString};
2
2
  //# sourceMappingURL=Detailed.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Detailed.js","names":[],"sources":["../src/Detailed.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { stand, overflow, zeroPadding } = props\n const displayLittleEndianBitOrder = props.displayLittleEndianBitOrder ?? false\n const displayBigEndianBitOrder = props.displayBigEndianBitOrder ?? false\n const text = stand ? '1' : '0'\n const border = overflow\n ? '1px dotted red'\n : zeroPadding\n ? '1px dotted gray'\n : '1px solid #cccccc'\n const margin = '0.5px'\n const color = stand ? '#999999' : '#cccccc'\n const backgroundColor = stand ? '#000000' : '#ffffff'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n {displayLittleEndianBitOrder && (\n <IndexLabel index={props.littleEndianBitOrder} />\n )}\n {displayBigEndianBitOrder && (\n <IndexLabel index={props.bigEndianBitOrder} />\n )}\n </div>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport const DetailedBitString = (props: {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n displayLittleEndianBitOrder={showLittleEndianBitOrder}\n displayBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":"qFAQA,MAAa,EAAe,GAA+C,CACzE,GAAM,CAAE,QAAO,WAAU,eAAgB,EACnC,EAA8B,EAAM,6BAA+B,GACnE,EAA2B,EAAM,0BAA4B,GAWnE,OACE,EAAC,MAAA,CAAI,MAAO,CAAE,QAAS,eAAgB,WAFtB,YAEkC,OALtC,QAK8C,WACzD,EAAC,MAAA,CACC,MAAO,CACL,MAPM,EAAQ,UAAY,UAQ1B,gBAPgB,EAAQ,UAAY,UAQpC,OAfO,EACX,iBACA,EACE,kBACA,oBAYC,UAjBM,EAAQ,IAAM,KAoBjB,CACL,GACC,EAAC,EAAA,CAAW,MAAO,EAAM,qBAAA,CAAwB,CAElD,GACC,EAAC,EAAA,CAAW,MAAO,EAAM,kBAAA,CAAqB,GAE5C,EAIJ,EAAc,GAEhB,EAAC,MAAA,CACC,MAAO,CACL,WAAY,OACZ,SAAU,QACV,UAAW,SACX,WAAY,MACb,UAEA,EAAM,OACH,CAIG,EAAqB,GAKT,CACvB,IAAM,EAA2B,EAAM,0BAA4B,GAC7D,EAAwB,EAAM,uBAAyB,GAC7D,OACE,EAAC,EAAA,CACC,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAa,GACX,EAAC,EAAA,CACC,GAAI,EACJ,4BAA6B,EAC7B,yBAA0B,GAC1B,EAEJ"}
1
+ {"version":3,"file":"Detailed.js","names":[],"sources":["../src/Detailed.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { border, color, backgroundColor, text } = getDetailedBitPalette(\n props.stand,\n props.overflow,\n props.zeroPadding\n )\n const { displayLittleEndianBitOrder, displayBigEndianBitOrder } =\n getDetailedBitDisplayOptions(props)\n const margin = '0.5px'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n <DetailedBitLabels\n displayLittleEndianBitOrder={displayLittleEndianBitOrder}\n displayBigEndianBitOrder={displayBigEndianBitOrder}\n littleEndianBitOrder={props.littleEndianBitOrder}\n bigEndianBitOrder={props.bigEndianBitOrder}\n />\n </div>\n )\n}\n\nconst getDetailedBitPalette = (\n stand: boolean,\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n return {\n text: stand ? '1' : '0',\n border: getDetailedBitBorder(overflow, zeroPadding),\n color: stand ? '#999999' : '#cccccc',\n backgroundColor: stand ? '#000000' : '#ffffff',\n }\n}\n\nconst getDetailedBitDisplayOptions = (props: DetailedBitProps) => {\n return {\n displayLittleEndianBitOrder:\n props.showLittleEndianBitOrder ?? props.displayLittleEndianBitOrder ?? false,\n displayBigEndianBitOrder:\n props.showBigEndianBitOrder ?? props.displayBigEndianBitOrder ?? false,\n }\n}\n\nconst getDetailedBitBorder = (\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n if (overflow) return '1px dotted red'\n if (zeroPadding) return '1px dotted gray'\n return '1px solid #cccccc'\n}\n\nconst DetailedBitLabels = (props: {\n displayLittleEndianBitOrder: boolean\n displayBigEndianBitOrder: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}) => {\n const {\n displayLittleEndianBitOrder,\n displayBigEndianBitOrder,\n littleEndianBitOrder,\n bigEndianBitOrder,\n } = props\n\n return (\n <>\n {displayLittleEndianBitOrder ? (\n <IndexLabel index={littleEndianBitOrder} />\n ) : null}\n {displayBigEndianBitOrder ? (\n <IndexLabel index={bigEndianBitOrder} />\n ) : null}\n </>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport type DetailedBitStringProps = {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBitString = (props: DetailedBitStringProps): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n showLittleEndianBitOrder={showLittleEndianBitOrder}\n showBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":"mGAUA,MAAa,EAAe,GAA+C,CACzE,GAAM,CAAE,SAAQ,QAAO,kBAAiB,QAAS,EAC/C,EAAM,MACN,EAAM,SACN,EAAM,YACP,CACK,CAAE,8BAA6B,4BACnC,EAA6B,EAAM,CAGrC,OACE,EAAC,MAAA,CAAI,MAAO,CAAE,QAAS,eAAgB,WAFtB,YAEkC,OAHtC,QAG8C,WACzD,EAAC,MAAA,CACC,MAAO,CACL,QACA,kBACA,SACD,UAEA,GACG,CACN,EAAC,EAAA,CAC8B,8BACH,2BAC1B,qBAAsB,EAAM,qBAC5B,kBAAmB,EAAM,mBACzB,CAAA,EACE,EAIJ,GACJ,EACA,EACA,KAEO,CACL,KAAM,EAAQ,IAAM,IACpB,OAAQ,EAAqB,EAAU,EAAY,CACnD,MAAO,EAAQ,UAAY,UAC3B,gBAAiB,EAAQ,UAAY,UACtC,EAGG,EAAgC,IAC7B,CACL,4BACE,EAAM,0BAA4B,EAAM,6BAA+B,GACzE,yBACE,EAAM,uBAAyB,EAAM,0BAA4B,GACpE,EAGG,GACJ,EACA,IAEI,EAAiB,iBACjB,EAAoB,kBACjB,oBAGH,EAAqB,GAKrB,CACJ,GAAM,CACJ,8BACA,2BACA,uBACA,qBACE,EAEJ,OACE,EAAA,EAAA,CAAA,SAAA,CACG,EACC,EAAC,EAAA,CAAW,MAAO,EAAA,CAAwB,CACzC,KACH,EACC,EAAC,EAAA,CAAW,MAAO,EAAA,CAAqB,CACtC,KAAA,CAAA,CACH,EAID,EAAc,GAEhB,EAAC,MAAA,CACC,MAAO,CACL,WAAY,OACZ,SAAU,QACV,UAAW,SACX,WAAY,MACb,UAEA,EAAM,OACH,CAWG,EAAqB,GAAqD,CACrF,IAAM,EAA2B,EAAM,0BAA4B,GAC7D,EAAwB,EAAM,uBAAyB,GAC7D,OACE,EAAC,EAAA,CACC,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAa,GACX,EAAC,EAAA,CACC,GAAI,EACsB,2BACH,yBACvB,EAEJ"}
package/dist/Simple.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./Binary.cjs`);let t=require(`react/jsx-runtime`);const n=e=>{let{stand:n,overflow:r}=e;return(0,t.jsx)(t.Fragment,{children:r??!1?``:n?`1`:`0`})},r=r=>(0,t.jsx)(e.Bits,{value:r.value,length:8,bitElement:n});exports.Simple8BitString=r,exports.SimpleBit=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./Binary.cjs`);let t=require(`react/jsx-runtime`);const n=e=>{let{stand:n,overflow:r}=e;return(0,t.jsx)(t.Fragment,{children:r??!1?``:n?`1`:`0`})},r=r=>(0,t.jsx)(e.Bits,{value:r.value,length:r.length??8,bitElement:n});exports.SimpleBit=n,exports.SimpleBitString=r;
2
2
  //# sourceMappingURL=Simple.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Simple.cjs","names":["Bits"],"sources":["../src/Simple.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: EnhancedBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport const Simple8BitString = (props: { value: number }): React.JSX.Element => {\n return <Bits value={props.value} length={8} bitElement={SimpleBit} />\n}\n"],"mappings":"sKAQA,MAAa,EAAa,GAA+C,CACvE,GAAM,CAAE,QAAO,YAAa,EAI5B,OAAO,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAFmB,GAAY,GACL,GAFhB,EAAQ,IAAM,IAAA,CAGb,EAGP,EAAoB,IACxB,EAAA,EAAA,KAACA,EAAAA,KAAAA,CAAK,MAAO,EAAM,MAAO,OAAQ,EAAG,WAAY,GAAa"}
1
+ {"version":3,"file":"Simple.cjs","names":["Bits"],"sources":["../src/Simple.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type SimpleBitProps = EnhancedBitProps\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: SimpleBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport type SimpleBitStringProps = {\n value: number\n length?: number\n}\n\nexport const SimpleBitString = (props: SimpleBitStringProps): React.JSX.Element => {\n return <Bits value={props.value} length={props.length ?? 8} bitElement={SimpleBit} />\n}\n"],"mappings":"sKAUA,MAAa,EAAa,GAA6C,CACrE,GAAM,CAAE,QAAO,YAAa,EAI5B,OAAO,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAFmB,GAAY,GACL,GAFhB,EAAQ,IAAM,IAAA,CAGb,EAQP,EAAmB,IACvB,EAAA,EAAA,KAACA,EAAAA,KAAAA,CAAK,MAAO,EAAM,MAAO,OAAQ,EAAM,QAAU,EAAG,WAAY,GAAa"}
package/dist/Simple.d.cts CHANGED
@@ -2,15 +2,18 @@ import { EnhancedBitProps } from "./Binary.cjs";
2
2
  import React from "react";
3
3
 
4
4
  //#region src/Simple.d.ts
5
+ type SimpleBitProps = EnhancedBitProps;
5
6
  /**
6
7
  * SimpleBit is a simple component that displays a bit.
7
8
  * @param props
8
9
  * @returns A component that displays a bit.
9
10
  */
10
- declare const SimpleBit: (props: EnhancedBitProps) => React.JSX.Element;
11
- declare const Simple8BitString: (props: {
11
+ declare const SimpleBit: (props: SimpleBitProps) => React.JSX.Element;
12
+ type SimpleBitStringProps = {
12
13
  value: number;
13
- }) => React.JSX.Element;
14
+ length?: number;
15
+ };
16
+ declare const SimpleBitString: (props: SimpleBitStringProps) => React.JSX.Element;
14
17
  //#endregion
15
- export { Simple8BitString, SimpleBit };
18
+ export { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
16
19
  //# sourceMappingURL=Simple.d.cts.map
package/dist/Simple.d.ts CHANGED
@@ -2,15 +2,18 @@ import { EnhancedBitProps } from "./Binary.js";
2
2
  import React from "react";
3
3
 
4
4
  //#region src/Simple.d.ts
5
+ type SimpleBitProps = EnhancedBitProps;
5
6
  /**
6
7
  * SimpleBit is a simple component that displays a bit.
7
8
  * @param props
8
9
  * @returns A component that displays a bit.
9
10
  */
10
- declare const SimpleBit: (props: EnhancedBitProps) => React.JSX.Element;
11
- declare const Simple8BitString: (props: {
11
+ declare const SimpleBit: (props: SimpleBitProps) => React.JSX.Element;
12
+ type SimpleBitStringProps = {
12
13
  value: number;
13
- }) => React.JSX.Element;
14
+ length?: number;
15
+ };
16
+ declare const SimpleBitString: (props: SimpleBitStringProps) => React.JSX.Element;
14
17
  //#endregion
15
- export { Simple8BitString, SimpleBit };
18
+ export { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
16
19
  //# sourceMappingURL=Simple.d.ts.map
package/dist/Simple.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Bits as e}from"./Binary.js";import{Fragment as t,jsx as n}from"react/jsx-runtime";const r=e=>{let{stand:r,overflow:i}=e;return n(t,{children:i??!1?``:r?`1`:`0`})},i=t=>n(e,{value:t.value,length:8,bitElement:r});export{i as Simple8BitString,r as SimpleBit};
1
+ import{Bits as e}from"./Binary.js";import{Fragment as t,jsx as n}from"react/jsx-runtime";const r=e=>{let{stand:r,overflow:i}=e;return n(t,{children:i??!1?``:r?`1`:`0`})},i=t=>n(e,{value:t.value,length:t.length??8,bitElement:r});export{r as SimpleBit,i as SimpleBitString};
2
2
  //# sourceMappingURL=Simple.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Simple.js","names":[],"sources":["../src/Simple.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: EnhancedBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport const Simple8BitString = (props: { value: number }): React.JSX.Element => {\n return <Bits value={props.value} length={8} bitElement={SimpleBit} />\n}\n"],"mappings":"yFAQA,MAAa,EAAa,GAA+C,CACvE,GAAM,CAAE,QAAO,YAAa,EAI5B,OAAO,EAAA,EAAA,CAAA,SAFmB,GAAY,GACL,GAFhB,EAAQ,IAAM,IAAA,CAGb,EAGP,EAAoB,GACxB,EAAC,EAAA,CAAK,MAAO,EAAM,MAAO,OAAQ,EAAG,WAAY,GAAa"}
1
+ {"version":3,"file":"Simple.js","names":[],"sources":["../src/Simple.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type SimpleBitProps = EnhancedBitProps\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: SimpleBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport type SimpleBitStringProps = {\n value: number\n length?: number\n}\n\nexport const SimpleBitString = (props: SimpleBitStringProps): React.JSX.Element => {\n return <Bits value={props.value} length={props.length ?? 8} bitElement={SimpleBit} />\n}\n"],"mappings":"yFAUA,MAAa,EAAa,GAA6C,CACrE,GAAM,CAAE,QAAO,YAAa,EAI5B,OAAO,EAAA,EAAA,CAAA,SAFmB,GAAY,GACL,GAFhB,EAAQ,IAAM,IAAA,CAGb,EAQP,EAAmB,GACvB,EAAC,EAAA,CAAK,MAAO,EAAM,MAAO,OAAQ,EAAM,QAAU,EAAG,WAAY,GAAa"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Binary.cjs`),t=require(`./Detailed.cjs`),n=require(`./Simple.cjs`);exports.Bits=e.Bits,exports.DetailedBit=t.DetailedBit,exports.DetailedBitString=t.DetailedBitString,exports.Simple8BitString=n.Simple8BitString,exports.SimpleBit=n.SimpleBit;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Binary.cjs`),t=require(`./Detailed.cjs`),n=require(`./Simple.cjs`);exports.Bits=e.Bits,exports.DetailedBit=t.DetailedBit,exports.DetailedBitString=t.DetailedBitString,exports.SimpleBit=n.SimpleBit,exports.SimpleBitString=n.SimpleBitString;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { BitElement, BitProps, Bits, EnhancedBitProps } from "./Binary.cjs";
2
- import { DetailedBit, DetailedBitProps, DetailedBitString } from "./Detailed.cjs";
3
- import { Simple8BitString, SimpleBit } from "./Simple.cjs";
4
- export { BitElement, BitProps, Bits, DetailedBit, DetailedBitProps, DetailedBitString, EnhancedBitProps, Simple8BitString, SimpleBit };
1
+ import { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps } from "./Binary.cjs";
2
+ import { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps } from "./Detailed.cjs";
3
+ import { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps } from "./Simple.cjs";
4
+ export { BitElement, BitProps, Bits, BitsProps, DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps, EnhancedBitProps, SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BitElement, BitProps, Bits, EnhancedBitProps } from "./Binary.js";
2
- import { DetailedBit, DetailedBitProps, DetailedBitString } from "./Detailed.js";
3
- import { Simple8BitString, SimpleBit } from "./Simple.js";
4
- export { BitElement, BitProps, Bits, DetailedBit, DetailedBitProps, DetailedBitString, EnhancedBitProps, Simple8BitString, SimpleBit };
1
+ import { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps } from "./Binary.js";
2
+ import { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps } from "./Detailed.js";
3
+ import { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps } from "./Simple.js";
4
+ export { BitElement, BitProps, Bits, BitsProps, DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps, EnhancedBitProps, SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Bits as e}from"./Binary.js";import{DetailedBit as t,DetailedBitString as n}from"./Detailed.js";import{Simple8BitString as r,SimpleBit as i}from"./Simple.js";export{e as Bits,t as DetailedBit,n as DetailedBitString,r as Simple8BitString,i as SimpleBit};
1
+ import{Bits as e}from"./Binary.js";import{DetailedBit as t,DetailedBitString as n}from"./Detailed.js";import{SimpleBit as r,SimpleBitString as i}from"./Simple.js";export{e as Bits,t as DetailedBit,n as DetailedBitString,r as SimpleBit,i as SimpleBitString};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitsuyui/react-binary",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Binary representation of number for React",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,6 +27,12 @@
27
27
  "dist",
28
28
  "package.json"
29
29
  ],
30
+ "scripts": {
31
+ "build": "tsdown",
32
+ "dev": "tsdown --no-clean --watch",
33
+ "test": "vitest run",
34
+ "validate": "validate-package-exports --check"
35
+ },
30
36
  "devDependencies": {
31
37
  "@types/react": "^19.2.14",
32
38
  "@types/react-dom": "^19.2.3",
@@ -36,11 +42,5 @@
36
42
  "peerDependencies": {
37
43
  "react": "*",
38
44
  "react-dom": "*"
39
- },
40
- "scripts": {
41
- "build": "tsdown",
42
- "dev": "tsdown --no-clean --watch",
43
- "test": "vitest run",
44
- "validate": "validate-package-exports --check"
45
45
  }
46
- }
46
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Yui KITSU
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.