Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rdunk committed Mar 18, 2021
1 parent 7176b6f commit 7b54bd7
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 46 deletions.
18 changes: 2 additions & 16 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
{
"plugins": [
"@babel/plugin-proposal-class-properties"
],
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
{
"targets": {
"edge": "14"
},
"modules": "commonjs"
}
]
]
}
"extends": "sanipack/babel"
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; editorconfig.org
root = true
charset= utf8

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
55 changes: 53 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
.DS_Store
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
lib
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# macOS finder cache file
.DS_Store

# VS Code settings
.vscode

# Lockfiles
yarn.lock
package-lock.json

# Cache
.cache

# Compiled plugin
/lib

9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/test
/coverage
.editorconfig
.eslintrc
.gitignore
.github
.prettierrc
.travis.yml
.nyc_output
4 changes: 0 additions & 4 deletions .prettierrc.js

This file was deleted.

8 changes: 3 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanity-plugin-table",
"version": "2.1.0",
"version": "2.1.1",
"description": "Table schema type and input component for Sanity CMS",
"main": "lib/TableComponent.js",
"scripts": {
Expand All @@ -19,6 +19,7 @@
],
"license": "MIT",
"peerDependencies": {
"@sanity/uuid": "^3.0.1",
"@sanity/icons": "^1.0.1",
"@sanity/ui": "^0.33.10",
"react": "^17.0.1",
Expand Down
22 changes: 4 additions & 18 deletions src/TableComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, FunctionComponent, forwardRef } from 'react';
import { randomKey } from '@sanity/util/lib/pathUtils';
import { uuid } from '@sanity/uuid';
import FormField from 'part:@sanity/components/formfields/default';
import PatchEvent, { set, unset } from 'part:@sanity/form-builder/patch-event';
import config from 'config:table';
Expand All @@ -8,20 +8,6 @@ import TableInput from './components/TableInput';
import TableMenu from './components/TableMenu';
import { Box, Button, Card, Dialog, Flex, Inline, Text } from '@sanity/ui';

interface RootProps {
level: number;
markers: any[];
type: {
title: string;
description: string;
options: Record<string, any>;
};
value: {
rows: TableRow[];
};
onChange: (...any) => any;
}

// This probably isn't necessary anymore
function deepClone<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj));
Expand All @@ -47,12 +33,12 @@ const TableComponent: FunctionComponent<RootProps> = (props) => {
rows: [
{
_type: config.rowType,
_key: randomKey(),
_key: uuid(),
cells: ['', ''],
},
{
_type: config.rowType,
_key: randomKey(),
_key: uuid(),
cells: ['', ''],
},
],
Expand All @@ -77,7 +63,7 @@ const TableComponent: FunctionComponent<RootProps> = (props) => {
// Add as many cells as we have columns
newValue.rows.push({
_type: config.rowType,
_key: randomKey(),
_key: uuid(),
cells: Array(columnCount).fill(''),
});
}
Expand Down
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
interface RootProps {
level: number;
markers: any[];
type: {
title: string;
description: string;
options: Record<string, any>;
};
value: {
rows: TableRow[];
};
onChange: (...any) => any;
}

interface TableRow {
_type: string;
_key: string;
Expand Down
15 changes: 15 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Note: This config is only used to help editors like VS Code understand/resolve
// parts, the actual transpilation is done by babel. Any compiler configuration in
// here will be ignored.
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"lib": ["ES2019"]
},
"include": [
"./node_modules/@sanity/base/types/**/*.ts",
"./**/*.ts",
"./**/*.tsx"
]
}

0 comments on commit 7b54bd7

Please sign in to comment.