@expo/html-elements 0.3.0 → 0.4.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/README.md CHANGED
@@ -57,6 +57,7 @@ Here is a list of all the currently supported elements and the web feature they
57
57
  | [`<caption />`][html-caption] | [`<Caption />`](#caption) |
58
58
  | [`<code />`][html-code] | [`<Code />`](#code) |
59
59
  | [`<del />`][html-del] | [`<Del />`](#del) |
60
+ | [`<div />`][html-div] | [`<Div />`](#div) |
60
61
  | [`<em />`][html-em] | [`<EM />`](#em) |
61
62
  | [`<footer />`][html-footer] | [`<Footer />`](#footer) |
62
63
  | [`<h1 />`][html-h1] | [`<H1 />`](#h1) |
@@ -76,6 +77,7 @@ Here is a list of all the currently supported elements and the web feature they
76
77
  | [`<q />`][html-q] | [`<Q />`](#q) |
77
78
  | [`<s />`][html-s] | [`<S />`](#s) |
78
79
  | [`<section />`][html-section] | [`<Section />`](#section) |
80
+ | [`<span />`][html-span] | [`<Span />`](#span) |
79
81
  | [`<strong />`][html-strong] | [`<Strong />`](#strong) |
80
82
  | [`<table />`][html-table] | [`<Table />`](#table) |
81
83
  | [`<tbody />`][html-tbody] | [`<TBody />`](#tbody) |
@@ -110,8 +112,8 @@ Other features not implemented in this package can be found in different parts o
110
112
  | `<input type="file" />` | `DocumentPicker` | [`expo-document-picker`][ex-dpick] |
111
113
  | `<canvas />` | `<GLView />` | [`expo-gl`][ex-gl] & [Expo Canvas][ex-canvas] |
112
114
  | `<iframe />` | `<WebView />` | [`<WebView />`][ex-webview]. `@react-native-community/web-view` is not maintained by Expo and doesn't have web support |
113
- | [`<link />`][html-link] | None | Eject the `index.html` with `npx expo customize` and link resources directly with `<link />` |
114
- | [`<noscript />`][html-noscript] | None | Eject the `index.html` with `npx expo customize` and use `<noscript />` directly as HTML |
115
+ | [`<link />`][html-link] | None | Eject the `index.html` with `npx expo customize` and link resources directly with `<link />` |
116
+ | [`<noscript />`][html-noscript] | None | Eject the `index.html` with `npx expo customize` and use `<noscript />` directly as HTML |
115
117
  | `<div />` | `<View />` | `react-native` |
116
118
  | `<img />` | `<Image />` | `react-native` |
117
119
  | `<span />` | `<Text />` | `react-native` |
@@ -253,6 +255,26 @@ Consider the following: in your app you have a basic element at the top which wr
253
255
 
254
256
  Some elements like `Footer` and `Main` have no iOS, or Android enhancements, but they'll still improve web. Using the proper HTML 5 elements will make your layout compliant with the [HTML5 outline algorithm](https://html.spec.whatwg.org/multipage/sections.html#outlines).
255
257
 
258
+ ### `<Div/>`
259
+
260
+ Renders a `<div />` on web and a `View` with no ARIA set on mobile.
261
+
262
+ ```tsx
263
+ import { Div } from '@expo/html-elements';
264
+
265
+ export default () => (
266
+ <Div>
267
+ <P>Some content in the main element</P>
268
+ </Div>
269
+ );
270
+ )
271
+ ```
272
+
273
+ | Platform | Output |
274
+ | -------- | ---------- |
275
+ | Web | `<div />` |
276
+ | Native | `<View />` |
277
+
256
278
  ### `<Nav/>`
257
279
 
258
280
  ```tsx
@@ -413,6 +435,14 @@ Alternate bold text.
413
435
  | --------- | ----------------------------------------- |
414
436
  | Universal | `<Text style={{ fontWeight: 'bold' }} />` |
415
437
 
438
+ ### `<Span/>`
439
+
440
+ Inline text element.
441
+
442
+ | Platform | Output |
443
+ | --------- | ---------- |
444
+ | Universal | `<Text />` |
445
+
416
446
  ### `<S/>`
417
447
 
418
448
  Strike through text.
@@ -712,11 +742,50 @@ Used to caption your table. Excepts text as a child.
712
742
  | Web | `<caption />` |
713
743
  | Native | `<Text style={[Custom]} />` |
714
744
 
715
- ## TODO
745
+ # TODO
716
746
 
717
747
  - Improve relative imports for better tree-shaking.
718
748
 
719
- ## Contributing
749
+ # Babel
750
+
751
+ You can write `react-dom` elements in your code and use the babel plugin to transform them to `@expo/html-elements` elements.
752
+
753
+ ```js
754
+ // babel.config.js
755
+ module.exports = {
756
+ plugins: ['@expo/html-elements/babel'],
757
+ };
758
+ ```
759
+
760
+ ## Input
761
+
762
+ ```js
763
+ export default function Page() {
764
+ return (
765
+ <div>
766
+ <h1>Hello World</h1>
767
+ </div>
768
+ );
769
+ }
770
+ ```
771
+
772
+ ## Output
773
+
774
+ The import is automatically added if it's not already present. All props are passed through without any additional transforms.
775
+
776
+ ```js
777
+ import { Div, H1 } from '@expo/html-elements';
778
+
779
+ export default function Page() {
780
+ return (
781
+ <Div>
782
+ <H1>Hello World</H1>
783
+ </Div>
784
+ );
785
+ }
786
+ ```
787
+
788
+ # Contributing
720
789
 
721
790
  Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
722
791
 
@@ -733,6 +802,7 @@ Contributions are very welcome! Please refer to guidelines described in the [con
733
802
  [html-caption]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption
734
803
  [html-code]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code
735
804
  [html-del]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del
805
+ [html-div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div
736
806
  [html-em]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em
737
807
  [html-footer]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer
738
808
  [html-form]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
@@ -754,6 +824,7 @@ Contributions are very welcome! Please refer to guidelines described in the [con
754
824
  [html-q]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q
755
825
  [html-s]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/s
756
826
  [html-section]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section
827
+ [html-span]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span
757
828
  [html-small]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small
758
829
  [html-strong]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong
759
830
  [html-table]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
@@ -0,0 +1,55 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Converts basic link 1`] = `
4
+ "import { A } from "@expo/html-elements";import { jsx as _jsx } from "react/jsx-runtime";
5
+ function App() {
6
+ return _jsx(A, { href: "#", children: "Link" });
7
+ }"
8
+ `;
9
+
10
+ exports[`Converts fixture 1`] = `
11
+ "import { Main, Article, P, Code, Div } from "@expo/html-elements";import { Image } from 'react-native';import { jsx as _jsx } from "react/jsx-runtime";import { jsxs as _jsxs } from "react/jsx-runtime";
12
+
13
+ export default function App() {
14
+ return (
15
+ _jsx(Main, { className: "flex-1 items-center justify-center", children:
16
+ _jsxs(Article, { className: "md:flex bg-slate-100 rounded-xl p-8 md:p-0 dark:bg-slate-800", children: [
17
+ _jsx(Image, {
18
+ className: "w-24 h-24 md:w-48 md:h-auto md:rounded-none rounded-full mx-auto",
19
+ source: {
20
+ uri: 'https://en.gravatar.com/userimage/120276729/078ee8361156d0e1c37b90e7851fed4b.png'
21
+ },
22
+ width: "384",
23
+ height: "512" }),
24
+
25
+ _jsxs(Main, { className: "pt-6 md:p-8 text-center md:text-left space-y-4", children: [
26
+ _jsxs(P, { className: "text-lg font-medium", children: ["With ",
27
+ _jsx(Code, { children: "@expo/html-elements" }), ", you can write HTML syntax that renders to real native components. Combined with Tailwind CSS, you have an experience that makes web developers feel at home.\\u201D"] }),
28
+
29
+
30
+
31
+ _jsxs(Div, { className: "font-medium", children: [
32
+ _jsx(P, { className: "text-sky-500 dark:text-sky-400 my-0", children: "Evan Bacon" }),
33
+ _jsx(P, { className: "text-slate-700 dark:text-slate-500 my-2", children: "Engineer, Expo" })] })] })] }) }));
34
+
35
+
36
+
37
+
38
+
39
+ }"
40
+ `;
41
+
42
+ exports[`Doesn't support unknowns 1`] = `
43
+ "import { jsx as _jsx } from "react/jsx-runtime";
44
+ function App() {
45
+ return _jsx("foobar", { href: "#", children: "Link" });
46
+ }"
47
+ `;
48
+
49
+ exports[`Skips injecting the import if one is already present 1`] = `
50
+ "import { A } from "@expo/html-elements";
51
+ import { A } from '@expo/html-elements';import { jsx as _jsx } from "react/jsx-runtime";
52
+ function App() {
53
+ return _jsx(A, { href: "#", children: "Link" });
54
+ }"
55
+ `;
@@ -0,0 +1,29 @@
1
+ import { Image } from 'react-native';
2
+
3
+ export default function App() {
4
+ return (
5
+ <main className="flex-1 items-center justify-center">
6
+ <article className="md:flex bg-slate-100 rounded-xl p-8 md:p-0 dark:bg-slate-800">
7
+ <Image
8
+ className="w-24 h-24 md:w-48 md:h-auto md:rounded-none rounded-full mx-auto"
9
+ source={{
10
+ uri: 'https://en.gravatar.com/userimage/120276729/078ee8361156d0e1c37b90e7851fed4b.png',
11
+ }}
12
+ width="384"
13
+ height="512"
14
+ />
15
+ <main className="pt-6 md:p-8 text-center md:text-left space-y-4">
16
+ <p className="text-lg font-medium">
17
+ With <code>@expo/html-elements</code>, you can write HTML syntax that renders to real
18
+ native components. Combined with Tailwind CSS, you have an experience that makes web
19
+ developers feel at home.”
20
+ </p>
21
+ <div className="font-medium">
22
+ <p className="text-sky-500 dark:text-sky-400 my-0">Evan Bacon</p>
23
+ <p className="text-slate-700 dark:text-slate-500 my-2">Engineer, Expo</p>
24
+ </div>
25
+ </main>
26
+ </article>
27
+ </main>
28
+ );
29
+ }
@@ -0,0 +1,63 @@
1
+ const babel = require('@babel/core');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const plugin = require('../../babel');
6
+
7
+ const options = {
8
+ babelrc: false,
9
+ presets: [
10
+ [
11
+ require.resolve('metro-react-native-babel-preset'),
12
+ {
13
+ useTransformReactJSXExperimental: false,
14
+ disableImportExportTransform: true,
15
+ },
16
+ ],
17
+ ],
18
+ minified: false,
19
+ plugins: [plugin],
20
+ compact: false,
21
+
22
+ filename: 'unknown',
23
+ // Snapshot sanity
24
+ retainLines: true,
25
+ cwd: __dirname,
26
+ babelrcRoots: false,
27
+ };
28
+
29
+ it(`Doesn't support unknowns`, () => {
30
+ const sourceCode = `
31
+ function App() {
32
+ return <foobar href="#">Link</foobar>;
33
+ }`;
34
+ const { code } = babel.transform(sourceCode, options);
35
+ expect(code).toMatchSnapshot();
36
+ expect(code).not.toMatch(`@expo/html-elements`);
37
+ });
38
+
39
+ it(`Converts basic link`, () => {
40
+ const sourceCode = `
41
+ function App() {
42
+ return <a href="#">Link</a>;
43
+ }`;
44
+ const { code } = babel.transform(sourceCode, options);
45
+ expect(code).toMatchSnapshot();
46
+ expect(code).toMatch(`import { A } from "@expo/html-elements";`);
47
+ });
48
+
49
+ it(`Skips injecting the import if one is already present`, () => {
50
+ const sourceCode = `
51
+ import '@expo/html-elements';
52
+ function App() {
53
+ return <a href="#">Link</a>;
54
+ }`;
55
+ const { code } = babel.transform(sourceCode, options);
56
+ expect(code).toMatchSnapshot();
57
+ });
58
+
59
+ it(`Converts fixture`, () => {
60
+ const sourceCode = fs.readFileSync(path.join(__dirname, 'fixtures/one.js'), 'utf8');
61
+ const { code } = babel.transform(sourceCode, options);
62
+ expect(code).toMatchSnapshot();
63
+ });
@@ -0,0 +1,12 @@
1
+ const path = require('path');
2
+
3
+ const roots = ['.'];
4
+
5
+ module.exports = {
6
+ testEnvironment: 'node',
7
+ testRegex: './__tests__/.*(test|spec)\\.[jt]sx?$',
8
+ watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
9
+ rootDir: path.resolve(__dirname),
10
+ displayName: require('../package').name,
11
+ roots,
12
+ };
package/babel.js CHANGED
@@ -7,6 +7,7 @@ const elementToComponent = {
7
7
  br: 'BR',
8
8
  caption: 'Caption',
9
9
  code: 'Code',
10
+ div: 'Div',
10
11
  footer: 'Footer',
11
12
  h1: 'H1',
12
13
  h2: 'H2',
@@ -36,8 +37,17 @@ const elementToComponent = {
36
37
  tr: 'TR',
37
38
  ul: 'UL',
38
39
  strong: 'Strong',
40
+ span: 'Span',
39
41
  aside: 'Aside',
40
42
  tfoot: 'TFoot',
43
+ blockquote: 'BlockQuote',
44
+ q: 'Q',
45
+
46
+ html: 'Div',
47
+ body: 'Div',
48
+
49
+ // TODO: img
50
+ // NOTE: head, meta, link should use some special component in the future.
41
51
  };
42
52
 
43
53
  module.exports = ({ types: t }, { expo }) => {
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ViewProps } from '../primitives/View';
3
+ export declare const Div: React.ComponentType<ViewProps>;
3
4
  export declare const Nav: React.ComponentType<ViewProps>;
4
5
  export declare const Footer: React.ComponentType<ViewProps>;
5
6
  export declare const Aside: React.ComponentType<ViewProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/elements/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAGzD,OAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQrD,eAAO,MAAM,GAAG,gCAMf,CAAC;AACF,eAAO,MAAM,MAAM,gCAMlB,CAAC;AACF,eAAO,MAAM,KAAK,gCAMjB,CAAC;AACF,eAAO,MAAM,MAAM,gCASlB,CAAC;AACF,eAAO,MAAM,IAAI,gCAMhB,CAAC;AACF,eAAO,MAAM,OAAO,gCAMnB,CAAC;AACF,eAAO,MAAM,OAAO,gCAElB,CAAC"}
1
+ {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/elements/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAGzD,OAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQrD,eAAO,MAAM,GAAG,gCAAe,CAAC;AAEhC,eAAO,MAAM,GAAG,gCAMf,CAAC;AACF,eAAO,MAAM,MAAM,gCAMlB,CAAC;AACF,eAAO,MAAM,KAAK,gCAMjB,CAAC;AACF,eAAO,MAAM,MAAM,gCASlB,CAAC;AACF,eAAO,MAAM,IAAI,gCAMhB,CAAC;AACF,eAAO,MAAM,OAAO,gCAMnB,CAAC;AACF,eAAO,MAAM,OAAO,gCAElB,CAAC"}
@@ -6,6 +6,7 @@ function createView(nativeProps = {}) {
6
6
  return React.createElement(View, { ...nativeProps, ...props, ref: ref });
7
7
  });
8
8
  }
9
+ export const Div = createView();
9
10
  export const Nav = createView(Platform.select({
10
11
  web: {
11
12
  accessibilityRole: 'navigation',
@@ -1 +1 @@
1
- {"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../src/elements/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,UAAU,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,IAAmB,MAAM,oBAAoB,CAAC;AAErD,SAAS,UAAU,CAAC,cAAyB,EAAE;IAC7C,OAAO,UAAU,CAAC,CAAC,KAAgB,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,oBAAC,IAAI,OAAK,WAAW,KAAM,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;IACxD,CAAC,CAA6B,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,UAAU,CAC3B,QAAQ,CAAC,MAAM,CAAC;IACd,GAAG,EAAE;QACH,iBAAiB,EAAE,YAAY;KAChC;CACF,CAAC,CACH,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAC9B,QAAQ,CAAC,MAAM,CAAC;IACd,GAAG,EAAE;QACH,iBAAiB,EAAE,aAAa;KACjC;CACF,CAAC,CACH,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAC7B,QAAQ,CAAC,MAAM,CAAC;IACd,GAAG,EAAE;QACH,iBAAiB,EAAE,eAAe;KACnC;CACF,CAAC,CACH,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAC9B,QAAQ,CAAC,MAAM,CAAC;IACd,GAAG,EAAE;QACH,iBAAiB,EAAE,QAAQ;KAC5B;IACD,OAAO,EAAE;QACP,iBAAiB,EAAE,QAAQ;KAC5B;CACF,CAAC,CACH,CAAC;AACF,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC5B,QAAQ,CAAC,MAAM,CAAC;IACd,GAAG,EAAE;QACH,iBAAiB,EAAE,MAAM;KAC1B;CACF,CAAC,CACH,CAAC;AACF,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAC/B,QAAQ,CAAC,MAAM,CAAC;IACd,GAAG,EAAE;QACH,iBAAiB,EAAE,SAAS;KAC7B;CACF,CAAC,CACH,CAAC;AACF,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC;IAChC,iBAAiB,EAAE,SAAS,EAAE,UAAU;CACzC,CAAC,CAAC","sourcesContent":["import React, { ComponentType, forwardRef } from 'react';\nimport { Platform } from 'react-native';\n\nimport View, { ViewProps } from '../primitives/View';\n\nfunction createView(nativeProps: ViewProps = {}): ComponentType<ViewProps> {\n return forwardRef((props: ViewProps, ref) => {\n return <View {...nativeProps} {...props} ref={ref} />;\n }) as ComponentType<ViewProps>;\n}\n\nexport const Nav = createView(\n Platform.select({\n web: {\n accessibilityRole: 'navigation',\n },\n })\n);\nexport const Footer = createView(\n Platform.select({\n web: {\n accessibilityRole: 'contentinfo',\n },\n })\n);\nexport const Aside = createView(\n Platform.select({\n web: {\n accessibilityRole: 'complementary',\n },\n })\n);\nexport const Header = createView(\n Platform.select({\n web: {\n accessibilityRole: 'banner',\n },\n default: {\n accessibilityRole: 'header',\n },\n })\n);\nexport const Main = createView(\n Platform.select({\n web: {\n accessibilityRole: 'main',\n },\n })\n);\nexport const Article = createView(\n Platform.select({\n web: {\n accessibilityRole: 'article',\n },\n })\n);\nexport const Section = createView({\n accessibilityRole: 'summary', // region?\n});\n"]}
1
+ {"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../src/elements/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,UAAU,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,IAAmB,MAAM,oBAA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GAAG,UAAU,CAAC;IAChC,iBAAiB,EAAE,SAAS,EAAE,UAAU;CACzC,CAAC,CAAC","sourcesContent":["import React, { ComponentType, forwardRef } from 'react';\nimport { Platform } from 'react-native';\n\nimport View, { ViewProps } from '../primitives/View';\n\nfunction createView(nativeProps: ViewProps = {}): ComponentType<ViewProps> {\n return forwardRef((props: ViewProps, ref) => {\n return <View {...nativeProps} {...props} ref={ref} />;\n }) as ComponentType<ViewProps>;\n}\n\nexport const Div = createView();\n\nexport const Nav = createView(\n Platform.select({\n web: {\n accessibilityRole: 'navigation',\n },\n })\n);\nexport const Footer = createView(\n Platform.select({\n web: {\n accessibilityRole: 'contentinfo',\n },\n })\n);\nexport const Aside = createView(\n Platform.select({\n web: {\n accessibilityRole: 'complementary',\n },\n })\n);\nexport const Header = createView(\n Platform.select({\n web: {\n accessibilityRole: 'banner',\n },\n default: {\n accessibilityRole: 'header',\n },\n })\n);\nexport const Main = createView(\n Platform.select({\n web: {\n accessibilityRole: 'main',\n },\n })\n);\nexport const Article = createView(\n Platform.select({\n web: {\n accessibilityRole: 'article',\n },\n })\n);\nexport const Section = createView({\n accessibilityRole: 'summary', // region?\n});\n"]}
@@ -17,5 +17,6 @@ export declare const Time: React.ComponentType<TimeProps>;
17
17
  export declare const Strong: React.ComponentType<TextProps>;
18
18
  export declare const Del: React.ComponentType<TextProps>;
19
19
  export declare const EM: React.ComponentType<TextProps>;
20
+ export declare const Span: React.ComponentType<TextProps>;
20
21
  export {};
21
22
  //# sourceMappingURL=Text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/elements/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAIzD,OAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAA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gCAEa,CAAC;AAM/B,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtC,eAAO,MAAM,GAAG,+BAKa,CAAC;AAG9B,eAAO,MAAM,IAAI,gCAEa,CAAC;AAE/B,eAAO,MAAM,MAAM,gCAAI,CAAC;AACxB,eAAO,MAAM,GAAG,gCAAI,CAAC;AACrB,eAAO,MAAM,EAAE,gCAAI,CAAC;AACpB,eAAO,MAAM,IAAI,gCAAO,CAAC"}
@@ -49,6 +49,7 @@ export const Time = forwardRef(({ dateTime, ...props }, ref) => {
49
49
  export const Strong = B;
50
50
  export const Del = S;
51
51
  export const EM = I;
52
+ export const Span = Text;
52
53
  const styles = StyleSheet.create({
53
54
  p: {
54
55
  marginVertical: em(1),
@@ -1 +1 @@
1
- {"version":3,"file":"Text.js","sourceRoot":"","sources":["../../src/elements/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,UAAU,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,IAAmB,MAAM,oBAAoB,CAAC;AACrD,OAAO,IAAmB,MAAM,oBAAoB,CAAC;AAGrD,MAAM,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAa,EAAE,GAAG,EAAE,EAAE;IAClE,OAAO,oBAAC,IAAI,OAAK,KAAK,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AACjE,CAAC,CAA6B,CAAC;AAE/B,MAAM,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAa,EAAE,GAAG,EAAE,EAAE;IAClE,OAAO,oBAAC,IAAI,OAAK,KAAK,EAAE,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BAAmB,EAAE,OAAO;KAC7B;IACD,IAAI,EAAE;QACJ,eAAe,EAAE,QAAQ;QACzB,KAAK,EAAE,OAAO;KACf;IACD,CAAC,EAAE;QACD,SAAS,EAAE,QAAQ;KACpB;CACF,CAAC,CAAC","sourcesContent":["import React, { ComponentType, forwardRef } from 'react';\nimport { StyleSheet, Platform } from 'react-native';\n\nimport { em } from '../css/units';\nimport Text, { TextProps } from '../primitives/Text';\nimport View, { ViewProps } from '../primitives/View';\nimport { BlockQuoteProps, QuoteProps, TimeProps } from './Text.types';\n\nexport const P = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.p, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const B = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.b, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const S = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.s, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const I = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.i, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const Q = forwardRef(({ children, cite, style, ...props }: QuoteProps, ref) => {\n return (\n <Text {...props} style={[styles.q, style]} ref={ref}>\n \"{children}\"\n </Text>\n );\n}) as ComponentType<QuoteProps>;\n\nexport const BlockQuote = forwardRef(({ style, cite, ...props }: BlockQuoteProps, ref) => {\n return <View {...props} style={[styles.blockQuote, style]} ref={ref} />;\n}) as ComponentType<BlockQuoteProps>;\n\nexport const BR = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.br, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const Mark = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.mark, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const Code = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.code, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nfunction isTextProps(props: any): props is TextProps {\n return typeof props.children === 'string';\n}\n\ntype PreProps = TextProps | ViewProps;\n\nexport const Pre = forwardRef((props: PreProps, ref: any) => {\n if (isTextProps(props)) {\n return <Text {...props} style={[styles.code, styles.pre, props.style]} ref={ref} />;\n }\n return <View {...props} style={[styles.pre, props.style]} ref={ref} />;\n}) as ComponentType<PreProps>;\n\n// Extract dateTime to prevent passing it to the native Text element\nexport const Time = forwardRef(({ dateTime, ...props }: TimeProps, ref) => {\n return <Text {...props} ref={ref} />;\n}) as ComponentType<TimeProps>;\n\nexport const Strong = B;\nexport const Del = S;\nexport const EM = I;\n\nconst styles = StyleSheet.create({\n p: {\n marginVertical: em(1),\n },\n b: {\n fontWeight: 'bold',\n },\n q: {\n fontStyle: 'italic',\n },\n code: {\n fontFamily: Platform.select({ default: 'Courier', ios: 'Courier New', android: 'monospace' }),\n fontWeight: '500',\n },\n pre: {\n marginVertical: em(1),\n },\n blockQuote: {\n marginVertical: em(1),\n },\n br: {\n width: 0,\n height: em(0.5),\n },\n s: {\n textDecorationLine: 'line-through',\n textDecorationStyle: 'solid',\n },\n mark: {\n backgroundColor: 'yellow',\n color: 'black',\n },\n i: {\n fontStyle: 'italic',\n },\n});\n"]}
1
+ {"version":3,"file":"Text.js","sourceRoot":"","sources":["../../src/elements/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,UAAU,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,IAAmB,MAAM,oBAAoB,CAAC;AACrD,OAAO,IAAmB,MAAM,oBAAoB,CAAC;AAGrD,MAAM,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAa,EAAE,G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AC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;QAC7F,UAAU,EAAE,KAAK;KAClB;IACD,GAAG,EAAE;QACH,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC;KACtB;IACD,UAAU,EAAE;QACV,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC;KACtB;IACD,EAAE,EAAE;QACF,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC;KAChB;IACD,CAAC,EAAE;QACD,kBAAkB,EAAE,cAAc;QAClC,mBAAmB,EAAE,OAAO;KAC7B;IACD,IAAI,EAAE;QACJ,eAAe,EAAE,QAAQ;QACzB,KAAK,EAAE,OAAO;KACf;IACD,CAAC,EAAE;QACD,SAAS,EAAE,QAAQ;KACpB;CACF,CAAC,CAAC","sourcesContent":["import React, { ComponentType, forwardRef } from 'react';\nimport { StyleSheet, Platform } from 'react-native';\n\nimport { em } from '../css/units';\nimport Text, { TextProps } from '../primitives/Text';\nimport View, { ViewProps } from '../primitives/View';\nimport { BlockQuoteProps, QuoteProps, TimeProps } from './Text.types';\n\nexport const P = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.p, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const B = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.b, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const S = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.s, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const I = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.i, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const Q = forwardRef(({ children, cite, style, ...props }: QuoteProps, ref) => {\n return (\n <Text {...props} style={[styles.q, style]} ref={ref}>\n \"{children}\"\n </Text>\n );\n}) as ComponentType<QuoteProps>;\n\nexport const BlockQuote = forwardRef(({ style, cite, ...props }: BlockQuoteProps, ref) => {\n return <View {...props} style={[styles.blockQuote, style]} ref={ref} />;\n}) as ComponentType<BlockQuoteProps>;\n\nexport const BR = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.br, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const Mark = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.mark, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nexport const Code = forwardRef(({ style, ...props }: TextProps, ref) => {\n return <Text {...props} style={[styles.code, style]} ref={ref} />;\n}) as ComponentType<TextProps>;\n\nfunction isTextProps(props: any): props is TextProps {\n return typeof props.children === 'string';\n}\n\ntype PreProps = TextProps | ViewProps;\n\nexport const Pre = forwardRef((props: PreProps, ref: any) => {\n if (isTextProps(props)) {\n return <Text {...props} style={[styles.code, styles.pre, props.style]} ref={ref} />;\n }\n return <View {...props} style={[styles.pre, props.style]} ref={ref} />;\n}) as ComponentType<PreProps>;\n\n// Extract dateTime to prevent passing it to the native Text element\nexport const Time = forwardRef(({ dateTime, ...props }: TimeProps, ref) => {\n return <Text {...props} ref={ref} />;\n}) as ComponentType<TimeProps>;\n\nexport const Strong = B;\nexport const Del = S;\nexport const EM = I;\nexport const Span = Text;\n\nconst styles = StyleSheet.create({\n p: {\n marginVertical: em(1),\n },\n b: {\n fontWeight: 'bold',\n },\n q: {\n fontStyle: 'italic',\n },\n code: {\n fontFamily: Platform.select({ default: 'Courier', ios: 'Courier New', android: 'monospace' }),\n fontWeight: '500',\n },\n pre: {\n marginVertical: em(1),\n },\n blockQuote: {\n marginVertical: em(1),\n },\n br: {\n width: 0,\n height: em(0.5),\n },\n s: {\n textDecorationLine: 'line-through',\n textDecorationStyle: 'solid',\n },\n mark: {\n backgroundColor: 'yellow',\n color: 'black',\n },\n i: {\n fontStyle: 'italic',\n },\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/html-elements",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Universal semantic HTML React components for iOS, Android, web, and desktop",
5
5
  "main": "build/Elements.js",
6
6
  "types": "build/Elements.d.ts",
@@ -9,7 +9,9 @@
9
9
  "build": "expo-module build",
10
10
  "clean": "expo-module clean",
11
11
  "lint": "expo-module lint",
12
- "test": "expo-module test",
12
+ "test": "yarn test:babel && yarn test:src",
13
+ "test:src": "expo-module test",
14
+ "test:babel": "jest --config babel/jest.config.js",
13
15
  "prepare": "expo-module prepare",
14
16
  "prepublishOnly": "expo-module prepublishOnly",
15
17
  "expo-module": "expo-module"
@@ -35,17 +37,27 @@
35
37
  "jest": {
36
38
  "projects": [
37
39
  {
38
- "preset": "jest-expo/ios"
40
+ "preset": "jest-expo/ios",
41
+ "modulePathIgnorePatterns": [
42
+ "<rootDir>/babel/"
43
+ ]
39
44
  },
40
45
  {
41
- "preset": "jest-expo/android"
46
+ "preset": "jest-expo/android",
47
+ "modulePathIgnorePatterns": [
48
+ "<rootDir>/babel/"
49
+ ]
42
50
  },
43
51
  {
44
- "preset": "jest-expo/web"
52
+ "preset": "jest-expo/web",
53
+ "modulePathIgnorePatterns": [
54
+ "<rootDir>/babel/"
55
+ ]
45
56
  }
46
57
  ]
47
58
  },
48
59
  "devDependencies": {
49
60
  "expo-module-scripts": "^3.0.0"
50
- }
61
+ },
62
+ "gitHead": "1815e2eaad8c753588c7b1eb74420174a28e01f4"
51
63
  }