Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/primefaces/primereact int…
Browse files Browse the repository at this point in the history
…o master
  • Loading branch information
mcandu committed Jan 11, 2022
2 parents be04111 + fffe2e2 commit 622af3a
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 40 deletions.
12 changes: 12 additions & 0 deletions components/doc/datatable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,18 @@ export const DataTableDemo = () => {
<td>null</td>
<td>Inline style of the column filter overlay.</td>
</tr>
<tr>
<td>align</td>
<td>string</td>
<td>null</td>
<td>Aligns the content of the column, valid values are left, right and center.</td>
</tr>
<tr>
<td>alignHeader</td>
<td>string</td>
<td>null</td>
<td>Aligns the header of the column, valid values are left, right and center.</td>
</tr>
<tr>
<td>alignFrozen</td>
<td>string</td>
Expand Down
4 changes: 4 additions & 0 deletions components/lib/column/Column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type ColumnSortOrderType = 1 | 0 | -1 | undefined | null;

type ColumnDataType = 'text' | 'numeric' | 'date' | string;

type ColumnAlignType = 'left' | 'right' | 'center' | undefined | null;

type ColumnAlignFrozenType = 'left' | 'right';

type ColumnFilterOperatorType = 'and' | 'or';
Expand Down Expand Up @@ -200,6 +202,8 @@ export interface ColumnProps {
maxConstraints?: number;
filterMenuClassName?: string;
filterMenuStyle?: object;
align?: ColumnAlignType;
alignHeader?: ColumnAlignType;
alignFrozen?: ColumnAlignFrozenType;
hidden?: boolean;
onFilterClear?(): void;
Expand Down
4 changes: 4 additions & 0 deletions components/lib/column/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export class Column extends Component {
maxConstraints: 2,
filterMenuClassName: null,
filterMenuStyle: null,
align: null,
alignHeader: null,
alignFrozen: 'left',
hidden: false,
onFilterClear: null,
Expand Down Expand Up @@ -108,6 +110,8 @@ export class Column extends Component {
maxConstraints: PropTypes.number,
filterMenuClassName: PropTypes.string,
filterMenuStyle: PropTypes.object,
align: PropTypes.string,
alignHeader: PropTypes.string,
alignFrozen: PropTypes.string,
hidden: PropTypes.bool,
onFilterClear: PropTypes.func,
Expand Down
2 changes: 2 additions & 0 deletions components/lib/datatable/BodyCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export class BodyCell extends Component {
const body = this.getColumnProp('body');
const editor = this.getColumnProp('editor');
const frozen = this.getColumnProp('frozen');
const align = this.getColumnProp('align');
const value = this.resolveFieldData();
const cellClassName = ObjectUtils.getPropValue(this.props.cellClassName, value, { props: this.props.tableProps, rowData: this.props.rowData, column: this.props.column });
const className = classNames(this.getColumnProp('bodyClassName'), this.getColumnProp('class'), cellClassName, {
Expand All @@ -517,6 +518,7 @@ export class BodyCell extends Component {
'p-frozen-column': frozen,
'p-selectable-cell': this.props.allowCellSelection,
'p-highlight': cellSelected,
[`p-align-${align}`]: !!align
});
const style = this.getStyle();
const title = this.props.responsiveLayout === 'stack' && <span className="p-column-title">{ObjectUtils.getJSXElement(header, { props: this.props.tableProps })}</span>;
Expand Down
22 changes: 22 additions & 0 deletions components/lib/datatable/DataTable.css
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,25 @@
top: 0;
left: 0;
}

/* Alignment */
.p-datatable .p-datatable-thead > tr > th.p-align-left > .p-column-header-content,
.p-datatable .p-datatable-tbody > tr > td.p-align-left,
.p-datatable .p-datatable-tfoot > tr > td.p-align-left {
text-align: left;
justify-content: flex-start;
}

.p-datatable .p-datatable-thead > tr > th.p-align-right > .p-column-header-content,
.p-datatable .p-datatable-tbody > tr > td.p-align-right,
.p-datatable .p-datatable-tfoot > tr > td.p-align-right {
text-align: right;
justify-content: flex-end;
}

.p-datatable .p-datatable-thead > tr > th.p-align-center > .p-column-header-content,
.p-datatable .p-datatable-tbody > tr > td.p-align-center,
.p-datatable .p-datatable-tfoot > tr > td.p-align-center {
text-align: center;
justify-content: center;
}
4 changes: 4 additions & 0 deletions components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ export class DataTable extends Component {
.p-datatable[${this.attributeSelector}] .p-datatable-tbody > tr > td:nth-child(${index + 1}) {
flex: 0 0 ${width}px;
}
.p-datatable[${this.attributeSelector}] .p-datatable-tfoot > tr > td:nth-child(${index + 1}) {
flex: 0 0 ${width}px;
}
`
});

Expand Down
4 changes: 3 additions & 1 deletion components/lib/datatable/FooterCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ export class FooterCell extends Component {

render() {
const style = this.getStyle();
const align = this.getColumnProp('align');
const className = classNames(this.getColumnProp('footerClassName'), this.getColumnProp('className'), {
'p-frozen-column': this.getColumnProp('frozen')
'p-frozen-column': this.getColumnProp('frozen'),
[`p-align-${align}`]: !!align
});
const colSpan = this.getColumnProp('colSpan');
const rowSpan = this.getColumnProp('rowSpan');
Expand Down
4 changes: 3 additions & 1 deletion components/lib/datatable/HeaderCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,16 @@ export class HeaderCell extends Component {
const isSortableDisabled = this.isSortableDisabled();
const sortMeta = this.getSortMeta();
const style = this.getStyle();
const align = this.getColumnProp('alignHeader') || this.getColumnProp('align');
const className = classNames(this.getColumnProp('headerClassName'), this.getColumnProp('className'), {
'p-sortable-column': this.getColumnProp('sortable'),
'p-resizable-column': this.props.resizableColumns,
'p-highlight': sortMeta.sorted,
'p-frozen-column': this.getColumnProp('frozen'),
'p-selection-column': this.getColumnProp('selectionMode'),
'p-sortable-disabled': this.getColumnProp('sortable') && isSortableDisabled,
'p-reorderable-column': this.props.reorderableColumns && this.getColumnProp('reorderable')
'p-reorderable-column': this.props.reorderableColumns && this.getColumnProp('reorderable'),
[`p-align-${align}`]: !!align
});
const tabIndex = this.getColumnProp('sortable') && !isSortableDisabled ? this.props.tabIndex : null;
const colSpan = this.getColumnProp('colSpan');
Expand Down
32 changes: 16 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ var gulp = require('gulp'),

gulp.task('build-css', function () {
return gulp.src([
'src/components/common/Common.css',
'src/components/**/*.css'
process.env.INPUT_DIR + 'common/Common.css',
process.env.INPUT_DIR + '**/*.css'
])
.pipe(concat('primereact.css'))
.pipe(gulp.dest('dist/resources'))
.pipe(gulp.dest(process.env.OUTPUT_DIR + 'resources'))
.pipe(uglifycss({ "uglyComments": true }))
.pipe(rename('primereact.min.css'))
.pipe(gulp.dest('dist/resources'));
.pipe(gulp.dest(process.env.OUTPUT_DIR + 'resources'));
});

gulp.task('build-themes', function () {
Expand All @@ -31,18 +31,18 @@ gulp.task('build-themes', function () {
'!public/themes/nano/**/*'
])
//.pipe(uglifycss({"uglyComments": true}))
.pipe(gulp.dest('dist/resources/themes'));
.pipe(gulp.dest(process.env.OUTPUT_DIR + 'resources/themes'));
})

gulp.task('images', function () {
return gulp.src(['src/components/**/images/*.png', 'src/components/**/images/*.gif'])
return gulp.src([process.env.INPUT_DIR + '**/images/*.png', process.env.INPUT_DIR + '**/images/*.gif'])
.pipe(flatten())
.pipe(gulp.dest('dist/resources/images'));
.pipe(gulp.dest(process.env.OUTPUT_DIR + 'resources/images'));
});

gulp.task('build-exports', function () {
return gulp.src(['exports/*.js', 'exports/*.d.ts'])
.pipe(gulp.dest('dist'));
.pipe(gulp.dest(process.env.OUTPUT_DIR));
});

gulp.task('build-meta', function () {
Expand All @@ -52,33 +52,33 @@ gulp.task('build-meta', function () {
path.basename = path.basename.replace('package-build', 'package');
}
}))
.pipe(gulp.dest('dist'));
.pipe(gulp.dest(process.env.OUTPUT_DIR));
});

gulp.task('copy-css', function () {
return gulp.src([
'src/components/**/Common.css',
'src/components/**/*.css'
process.env.INPUT_DIR + '**/Common.css',
process.env.INPUT_DIR + '**/*.css'
])
.pipe(uglifycss({ "uglyComments": true }))
.pipe(rename(function (path) {
path.basename = path.basename.toLowerCase();
path.extname = '.min' + path.extname;
}))
.pipe(gulp.dest('./dist'));
.pipe(gulp.dest('./' + process.env.OUTPUT_DIR));
});

gulp.task('copy-d.ts', function () {
return gulp.src('src/components/**/*.d.ts')
return gulp.src(process.env.INPUT_DIR + '**/*.d.ts')
.pipe(rename(function (path) {
path.basename = path.basename.toLowerCase();
}))
.pipe(gulp.dest('./dist'));
.pipe(gulp.dest('./' + process.env.OUTPUT_DIR));
});

gulp.task('copy-package.json', function () {
return gulp.src('src/components/**/package.json')
.pipe(gulp.dest('./dist'));
return gulp.src(process.env.INPUT_DIR + '**/package.json')
.pipe(gulp.dest('./' + process.env.OUTPUT_DIR));
});

//Building project with run sequence
Expand Down
47 changes: 35 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,50 @@
"scripts": {
"dev": "next dev",
"build": "next build && next export",
"build-lib": "NODE_ENV=production INPUT_DIR=components/lib/ OUTPUT_DIR=dist/ npm run build-package",
"build-package": "rollup -c && gulp build-resources && npm run build-api",
"build-api": "node ./api-generator/build-api.js",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.16.8",
"@babel/preset-env": "^7.16.8",
"@babel/preset-react": "^7.16.7",
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"chart.js": "3.3.2",
"file-saver": "^2.0.5",
"final-form": "^4.20.2",
"formik": "^2.2.6",
"fs-extra": "^10.0.0",
"gulp": "^4.0.2",
"gulp-concat": "^2.6.1",
"gulp-flatten": "^0.4.0",
"gulp-rename": "^2.0.0",
"gulp-uglify": "^3.0.2",
"gulp-uglifycss": "^1.1.0",
"jspdf": "^2.4.0",
"jspdf-autotable": "^3.2.5",
"next": "12.0.4",
"primeflex": "2.0.0",
"primeicons": "^5.0.0",
"quill": "1.3.7",
"react": "17.0.2",
"react-dom": "17.0.2",
"primeicons": "^5.0.0",
"primeflex": "2.0.0",
"react-final-form": "^6.5.3",
"react-hook-form": "^7.8.4",
"react-transition-group": "^4.4.1",
"rollup": "^2.52.1",
"rollup-plugin-postcss": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"sass": "^1.32.8",
"chart.js": "3.3.2",
"quill": "1.3.7",
"formik": "^2.2.6",
"final-form": "^4.20.2",
"react-hook-form": "^7.8.4",
"react-final-form": "^6.5.3",
"jspdf": "^2.4.0",
"jspdf-autotable": "^3.2.5",
"xlsx": "^0.15.1",
"file-saver": "^2.0.5"
"xlsx": "^0.15.1"
},
"devDependencies": {
"eslint": "7.32.0",
Expand Down
17 changes: 7 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import { terser } from 'rollup-plugin-terser';
import fs from 'fs-extra';
import path from 'path';

const INPUT_DIR = 'src/components/';
const OUTPUT_DIR = 'dist/';

let entries = [];

let core = {};
Expand Down Expand Up @@ -80,7 +77,7 @@ const RESOLVE_PLUGIN_OPTIONS = {
};

const COMMONJS_PLUGIN_OPTIONS = {
exclude: 'src/**',
exclude: process.env.INPUT_DIR + '**',
sourceMap: false
};

Expand Down Expand Up @@ -211,14 +208,14 @@ function addCore() {
}

function addComponent() {
fs.readdirSync(path.resolve(__dirname, INPUT_DIR), { withFileTypes: true })
fs.readdirSync(path.resolve(__dirname, process.env.INPUT_DIR), { withFileTypes: true })
.filter(dir => dir.isDirectory())
.forEach(({ name: folderName }) => {
fs.readdirSync(path.resolve(__dirname, INPUT_DIR + folderName)).forEach(file => {
fs.readdirSync(path.resolve(__dirname, process.env.INPUT_DIR + folderName)).forEach(file => {
let name = file.split(/(.js)$/)[0].toLowerCase();
if (name === folderName) {
const input = INPUT_DIR + folderName + '/' + file;
const output = OUTPUT_DIR + folderName + '/' + name;
const input = process.env.INPUT_DIR + folderName + '/' + file;
const output = process.env.OUTPUT_DIR + folderName + '/' + name;

addEntry('primereact.' + folderName, input, output, true);
}
Expand All @@ -227,8 +224,8 @@ function addComponent() {
}

function addPrimeReact() {
const input = INPUT_DIR + 'primereact.all.js';
const output = OUTPUT_DIR + 'primereact.all';
const input = process.env.INPUT_DIR + 'primereact.all.js';
const output = process.env.OUTPUT_DIR + 'primereact.all';

addEntry('primereact', input, output, false);
}
Expand Down

0 comments on commit 622af3a

Please sign in to comment.